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

 找回密码
 立即注册
查看: 2604|回复: 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)
2 q1 B! D5 y) t& ~$ i3 D5 U      or: fdisk /dev/sdc  (for the third SCSI disk)
5 o: j' v7 M* Z. q/ E8 i4 o      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)* h! R( x3 j" ^  D2 ]8 ~4 j$ a
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
+ ?8 R2 e( \$ E      ...
3 K2 N8 V4 k- d, X6 X8 ~4 p
  1. df -k
    ) e+ b' E* |% ~& y! y2 N/ N+ w9 A% B
  2. df -lh
    5 z$ @; `, T$ Y* U
  3. 查看有几块硬盘:fdisk -l3 w2 i. `$ f9 N/ x* ?" N/ I
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点3 f  T& O* C+ @5 p* I/ g" M
    /dev/sda3              3723848    705968   2828716  20% /7 Y+ o. h1 h- R$ p
    /dev/sda1               101089      9274     86596  10% /boot! A( C, s7 X6 \8 a4 s. g7 |
    none                     14520         0     14520   0% /dev/shm! Q( l8 g7 Y4 q9 {6 p
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
! m, ^& z: C" {% v9 e% K
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel% @5 _5 i2 \5 g# ^
    Building a new DOS disklabel. Changes will remain in memory only,
! P: y# M, U2 R' S* m9 `- F+ G    until you decide to write them. After that, of course, the previous. P/ Q) z+ x$ h0 K
    content won't be recoverable.
6 s7 F2 }9 l+ ~4 y    The number of cylinders for this disk is set to 8322.
9 j4 j% {. c6 \! U4 _4 b( z+ \    There is nothing wrong with that, but this is larger than 1024,6 _" v6 @' t' w1 u) s) u
    and could in certain setups cause problems with:/ T8 O6 x  |% C0 J; U- {
    1) software that runs at boot time (e.g., old versions of LILO)- W4 h7 ~) i1 u6 Z
    2) booting and partitioning software from other OSs
" w, G$ a% V+ E- H       (e.g., DOS FDISK, OS/2 FDISK)! K( J/ |: A9 ~! S
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)( O/ n4 R3 b& {# I+ w+ j
    Command (m for help): p& s) w5 I5 P3 k. X: U
    Disk /dev/hda: 4294 MB, 4294967296 bytes7 b. a9 e! C2 k- M% k* _
    16 heads, 63 sectors/track, 8322 cylinders1 R9 j' W  B4 B2 a8 s
    Units = cylinders of 1008 * 512 = 516096 bytes4 r7 f# f0 O# j$ R# ~' ^) J
       Device Boot    Start       End    Blocks   Id  System- f$ S0 w, |/ a# b" l7 X
    Command (m for help): m3 u# r/ P* {1 T$ x7 B7 D, o) o( x/ v
    Command action& w! }, o) N7 `! y# N: `6 }
       a   toggle a bootable flag
& n5 B# m( p+ ]/ j       b   edit bsd disklabel
6 C; A& q( l0 y* h       c   toggle the dos compatibility flag6 W- g- _0 @; T, |/ o
       d   delete a partition
2 ~! @" f3 j5 ^, w" j       l   list known partition types
6 [; o/ r0 V' }/ r5 \; A       m   print this menu
9 H9 E, c1 F) z       n   add a new partition3 Q, _/ {. Z( R, k
       o   create a new empty DOS partition table
: g0 X6 ]9 D, U9 O" X7 @       p   print the partition table
2 A  f8 ^; N- ~* c7 J       q   quit without saving changes
$ q  p" [5 \. y9 W& P       s   create a new empty Sun disklabel
  ~! N8 O  r  Q  [2 G: K* Q       t   change a partition's system id
& S* e1 N& a2 p) s9 }- m4 Z8 C       u   change display/entry units
- Q2 _+ V- ^. W) E" G1 p6 ~       v   verify the partition table+ O0 S- T" `- Z8 K  n6 t# Y
       w   write table to disk and exit
9 P0 t7 S' `8 b$ _  L       x   extra functionality (experts only); [1 l# y1 Z' I
    Command (m for help): n2 B9 g$ S  G  l9 Y
    Command action
! Q3 g' d% h5 s+ m       e   extended* a9 w5 D5 S" q0 U* }2 j
       p   primary partition (1-4)
- J2 Q7 Y( {- |* R) f; A) o1 O* h/ E    p
5 E4 A5 `$ z' G2 t1 S$ G! X; K+ v    Partition number (1-4): 1
: h  P0 F1 V5 X( }3 F    First cylinder (1-8322, default 1): . K9 i3 D$ c% O  M" j% a4 J2 k
    Using default value 1. V& L0 x% M3 o: s
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G7 S6 e1 [& H6 v4 G% o* y
    Command (m for help): p3 B/ P6 E+ h  n- }, A/ {, }6 q5 I
    Disk /dev/hda: 4294 MB, 4294967296 bytes
1 H/ h/ D  G( l7 j! b5 b% p, Z    16 heads, 63 sectors/track, 8322 cylinders1 A! }; b2 [( _  D6 c! u
    Units = cylinders of 1008 * 512 = 516096 bytes+ n, _' A% Y0 R; M4 X( q& y$ _
       Device Boot    Start       End    Blocks   Id  System
1 x" B6 Y" z) K    /dev/hda1             1      1000    503968+  83  Linux* e) l0 h+ L2 X
    Command (m for help): w3 a  T  c) ^1 M* j
    The partition table has been altered!
1 M: _5 K9 J  g* ?! A% _  J    Calling ioctl() to re-read partition table./ P. s8 T- d$ _( @
    Syncing disks., Q& l3 w3 P0 T% z$ J! ?
    //格式化新分区
; N" z! Z0 ~2 a5 M( Y- @
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
& n0 w9 R  h. _& c4 I+ o: Y" _    Filesystem label=
) L5 d$ x) B, @1 I! c- R: }    OS type: Linux
: u8 F( ~8 x( k! j! e8 B  v    Block size=1024 (log=0)
0 I( j5 P9 c3 f# Q    Fragment size=1024 (log=0)  a1 p" }& \% n% k7 ~
    126480 inodes, 503968 blocks
' z8 [( }4 |' p/ ]    25198 blocks (5.00%) reserved for the super user/ ]0 [% Q. [( ]: @2 ]) @1 M; U  p2 L3 q
    First data block=1% A3 t2 q7 R: ~" H( s5 i/ e
    62 block groups
. P7 J( o, _+ q4 I1 R0 Q1 N$ o( S) Y    8192 blocks per group, 8192 fragments per group# ~8 g: Q  C% i& F( P. S8 k
    2040 inodes per group& o5 [2 f$ `, G9 G+ \1 O. I
    Superblock backups stored on blocks: 7 c4 _6 G# N" {
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014091 G5 q; J' I, J0 I9 `
    Writing inode tables: done                           
( [% U, E: @% i0 c% w. J    Creating journal (8192 blocks): done
& j- V4 Y9 Y! v; D& o! j    Writing superblocks and filesystem accounting information: done/ G9 c4 [$ B( j& S1 Q* a2 f% A
    This filesystem will be automatically checked every 30 mounts or+ I9 Y4 P7 ^" z" w
    180 days, whichever comes first.  Use tune2fs -c or -i to override.* ?- z/ [* d+ N' w, e
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
. d3 @9 B9 e( `; b% Y- w0 K    /dev/sda3              3723848    705992   2828692  20% /9 E6 u6 n- ~' r. W6 q0 t! X
    /dev/sda1               101089      9274     86596  10% /boot
5 x8 x+ y" W, O    none                     14520         0     14520   0% /dev/shm9 \) j, N$ U0 E3 T
    //挂上新分区, D7 q7 ]5 F1 T
  1. mount /dev/hda1 /home
    , ~5 B8 T* Q& Z% S% z& G
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点: o0 Q! ^- W- J7 r& ~
    /dev/sda3              3723848    705992   2828692  20% /
7 q' e; U; t* S* N+ W, P9 ~    /dev/sda1               101089      9274     86596  10% /boot  g+ d% L: u! L1 ~
    none                     14520         0     14520   0% /dev/shm
" ^/ O  A2 Y/ {, @* |    /dev/hda1               488006      8239    454569   2% /home
  {9 K- t9 Y% U- g, \
" q$ O) |% [% p6 j7 D0 E! E6 A自动挂载:
) p; n" F" Y9 N4 @4 I9 q- i
  1.           vi /etc/fstab3 x1 \, w3 Y6 u* ~8 a( c( O
  2. , D3 y. {) p) H  {& t
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    8 p) e: Z" m2 N& J; e
  4. # R' D1 c9 W2 L$ w, a& F
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
( u  x3 f2 c; _7 z
  1.           mount /dev/sdb5 /mnt/ljp1
    " ?8 U- q6 p+ T3 c1 {$ a

  2. 3 m1 _. j8 O8 s+ M0 b0 C
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

" r  Q  }( e/ H1 s) u: Q
" @1 `- Y! Y3 u$ j, a+ Q- {9 o/ q& B
* ]5 b3 K* h  f5 c- p! h' `
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-27 19:35 , Processed in 0.028141 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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