稳定互联,中美互联,站长交流,虚拟主机,香港主机,美国主机,虚拟空间,免费空间,免费VPS,免费域名

 找回密码
 立即注册
查看: 2734|回复: 0

[经验] linux下添加新硬盘方法

[复制链接]
发表于 2014-2-9 19:20:26 | 显示全部楼层 |阅读模式
  1. fdisk
复制代码
Usage: fdisk [-l] [-b SSZ] [-u] device    E.g.: fdisk /dev/hda  (for the first IDE disk)
* r0 }8 b9 a2 L7 z. }      or: fdisk /dev/sdc  (for the third SCSI disk)
) I; x, B' p; z2 z/ H$ `      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)# T& x/ f8 n! q
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
+ I/ b% U$ L' m* }2 x      ...
& X& V% |, [/ k
  1. df -k3 R! D( u3 o0 _- ^' Y
  2. df -lh
    6 b3 h2 Y. q+ s* y$ R9 X
  3. 查看有几块硬盘:fdisk -l
    - X& q) ^: I. i8 S9 ?% q
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
  y- I, G8 D- {; d  M" [9 ?    /dev/sda3              3723848    705968   2828716  20% /6 ]9 u1 z* l' y" E, M2 _, n& H
    /dev/sda1               101089      9274     86596  10% /boot
5 _" c4 Q: _0 Y    none                     14520         0     14520   0% /dev/shm
0 P- C/ L* }3 T& `. F% @    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用- }$ r, X3 Y* b$ A$ ~( V
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
6 r8 R6 V6 A: I  n6 T    Building a new DOS disklabel. Changes will remain in memory only,- y' Y+ ?, k; K/ P$ ?& {9 X: s
    until you decide to write them. After that, of course, the previous# u; ~1 s! Q/ N2 M3 y9 G- z' }
    content won't be recoverable.
9 q, b! l+ z: {( H7 H+ G1 Z) _% l" @. @    The number of cylinders for this disk is set to 8322.
9 l/ j6 x4 Z3 B2 H    There is nothing wrong with that, but this is larger than 1024,+ j; O! i$ s; U1 q, C! b0 s+ a  C
    and could in certain setups cause problems with:
: D2 F* q) ^# v6 Y    1) software that runs at boot time (e.g., old versions of LILO)0 s/ L, o& M. F7 I$ K
    2) booting and partitioning software from other OSs
1 F! @5 N  i+ o, R- X7 [       (e.g., DOS FDISK, OS/2 FDISK)4 _  K& b9 D/ G' i
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)# k0 b/ Q+ C3 a: i" ?4 h! k1 U
    Command (m for help): p2 a$ V3 a- d5 a8 g4 Q7 p  p
    Disk /dev/hda: 4294 MB, 4294967296 bytes8 X2 X/ X$ i! W6 Y
    16 heads, 63 sectors/track, 8322 cylinders, Y5 W1 R% g& s, A' k
    Units = cylinders of 1008 * 512 = 516096 bytes
4 o4 O  R* w# `# F       Device Boot    Start       End    Blocks   Id  System
- W) [' e% K. I$ X    Command (m for help): m1 s, k5 r# V( C, P7 J- c& L8 |
    Command action
% G# T& g9 d, z! g       a   toggle a bootable flag$ C3 t6 h  _5 T  N, K# M8 f
       b   edit bsd disklabel- i  _2 F$ p4 {7 S, F
       c   toggle the dos compatibility flag
) w$ C2 H1 S3 K# ]) S4 ~, |2 C       d   delete a partition
. V4 B5 Y' B1 _       l   list known partition types
7 P- B2 Z4 y' y) a: D       m   print this menu% g6 N/ g# w% V( v: `* ?; @
       n   add a new partition- K7 J' g5 w8 Z! Z& a8 w* }
       o   create a new empty DOS partition table
( n/ T  _  Q5 p5 U       p   print the partition table
0 N' ~0 `8 x$ R& Y  k& j       q   quit without saving changes
+ x! S2 ^3 n4 Y9 E& W& e       s   create a new empty Sun disklabel5 b1 n% }8 c% I. [( c! L
       t   change a partition's system id7 l: ~6 t$ H* I0 f2 }8 z
       u   change display/entry units
$ U2 G- b2 d' f. I) D       v   verify the partition table8 V. v8 [+ l5 Y4 t2 R0 M# V
       w   write table to disk and exit
# }" Y8 l  |0 X+ ?! i& K" n; C# ~       x   extra functionality (experts only)* R5 G& J$ X" {9 ^: n
    Command (m for help): n
0 ?- \. T( o- p. L' f2 I+ W  z- o    Command action
' c/ @7 A# ~% [3 T       e   extended
1 e& T4 I( V4 u1 Y5 ?9 }       p   primary partition (1-4)
  U  Z0 m+ x% I1 o0 H6 y3 R: t4 d8 F    p1 L8 }* @! P- _5 u
    Partition number (1-4): 1
6 Q$ O% F2 d: B! I0 e2 b% D    First cylinder (1-8322, default 1):
! g& W* Q3 _4 l/ k8 q- k    Using default value 16 \; f: [+ Z5 W' d: y* l: `
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G( \/ @! N) Q/ R0 d! m
    Command (m for help): p
0 S0 @2 O" }% |    Disk /dev/hda: 4294 MB, 4294967296 bytes+ |  w  X8 i. k- W  ?
    16 heads, 63 sectors/track, 8322 cylinders
* p5 w8 _' z8 n! O$ o. z& n    Units = cylinders of 1008 * 512 = 516096 bytes4 F3 g) _) \3 g  A, O, k  L
       Device Boot    Start       End    Blocks   Id  System
/ V$ t# X9 a: I/ I" y/ J& D    /dev/hda1             1      1000    503968+  83  Linux
3 p) A, D2 I2 W3 Y$ G    Command (m for help): w
0 e: `$ o; Z5 v7 e6 j' \1 S    The partition table has been altered!7 k, ^1 U0 ]& V' ]2 `
    Calling ioctl() to re-read partition table.
+ z. u; @* F$ u8 C+ B    Syncing disks.
* F* ?5 f1 k( h. o; D: f    //格式化新分区
+ [5 W6 G' L9 g% ?9 }' @
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
6 F4 Y7 o( s$ f1 S  s' s    Filesystem label=
" P" j6 B- l' w    OS type: Linux3 R" r! p/ ]5 y3 {. X+ }
    Block size=1024 (log=0); H8 q1 A% s, L8 q& r( P8 K
    Fragment size=1024 (log=0)3 C4 K. c8 J; t) \
    126480 inodes, 503968 blocks
! F2 a( S+ z; s/ z! K    25198 blocks (5.00%) reserved for the super user
5 b" A' Z/ t  ^! X    First data block=1' X$ h1 c, S6 P5 k" a$ x" m
    62 block groups
+ n8 |  F9 D" |0 K8 L    8192 blocks per group, 8192 fragments per group  j+ o3 q9 u! u# r
    2040 inodes per group% V# Z& e+ F5 V8 ?) [6 v
    Superblock backups stored on blocks: 5 x! T; }! M% W+ N0 e" v
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
" m; l" u. P. C0 C    Writing inode tables: done                            - P% y% H' X6 a9 ?5 m+ P4 i
    Creating journal (8192 blocks): done5 V3 r* N+ |5 z) V/ A, @. Z3 Z
    Writing superblocks and filesystem accounting information: done
1 k" d( {% G# _8 r% t- I* ?    This filesystem will be automatically checked every 30 mounts or5 f& m; t* B/ |3 T* H! V' o
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
, ]8 v3 w/ S8 ^2 ^6 O
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
  p4 n1 \5 m5 D1 P    /dev/sda3              3723848    705992   2828692  20% /$ h+ ]$ |4 x5 e  ~
    /dev/sda1               101089      9274     86596  10% /boot
0 }8 @5 M5 n+ R0 Y    none                     14520         0     14520   0% /dev/shm
1 n, x1 ?) m2 {- \; w    //挂上新分区" U% `9 K8 h* {5 Y1 {- z" T
  1. mount /dev/hda1 /home- G4 @) B4 ]+ i" w( h4 D. z* J
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点- H# t  E. J* ]# O) E% Q& S
    /dev/sda3              3723848    705992   2828692  20% /
/ V/ n+ W% N7 n/ ~* ]3 D    /dev/sda1               101089      9274     86596  10% /boot) f  ^4 a) }; e
    none                     14520         0     14520   0% /dev/shm
4 X9 q. C5 W( n1 O; M* d    /dev/hda1               488006      8239    454569   2% /home( K5 l! V. Y5 T# ~8 }% a
* Q; o- @& v7 y, v  G3 S
自动挂载:
% ~& r  k5 e& x
  1.           vi /etc/fstab( K0 Z! v; O& z; g# a
  2. 6 c% p+ m# v0 p6 {( S6 v  J' {
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    " J. o6 O! i) y* F

  4. ' k  U& O, V0 m  N, Z$ N# D  d* _6 N
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:- |2 y$ A0 I3 X1 U
  1.           mount /dev/sdb5 /mnt/ljp13 K1 J0 C! s( A# Y7 ~  _
  2. " M$ u% z6 G; Y9 `
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
4 Y+ w; W3 @- Y- D
+ k1 k' k1 y9 E+ j

: Z' t! G# W; ?' e' `8 X
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|WdidcNet ( 苏ICP备17005075号-1 )

GMT+8, 2026-1-4 03:25 , Processed in 0.013576 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

快速回复 返回顶部 返回列表