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

 找回密码
 立即注册
查看: 2564|回复: 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)
# K% Q0 R6 t& a1 G+ {8 D      or: fdisk /dev/sdc  (for the third SCSI disk)
  y9 j0 v; m% @9 P$ i      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
( U' r$ J0 a1 [      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
$ x. A' C8 \( a) s! G# A. g      ...
% m2 h& A( g& j8 x, O, x
  1. df -k
    ; u* R4 L/ G7 O4 G3 K9 U" B
  2. df -lh9 _" I0 f9 I! T, ]* F
  3. 查看有几块硬盘:fdisk -l
    5 b+ L- I  q! V. |
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
$ L( h8 G! F7 O' T+ `5 f4 d    /dev/sda3              3723848    705968   2828716  20% /7 J; u$ t& A0 F- R
    /dev/sda1               101089      9274     86596  10% /boot% s) }8 Z8 y, n% a
    none                     14520         0     14520   0% /dev/shm
3 ?4 A  F4 {* ]0 _    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用9 B" W5 W6 F! S' Y" @/ H! X  L
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel1 Z) Q" k) E; A, _/ H1 N
    Building a new DOS disklabel. Changes will remain in memory only," J0 K, \9 X( a- X; w
    until you decide to write them. After that, of course, the previous7 V. s, y$ s9 ]8 A- Z2 B4 J
    content won't be recoverable.8 v2 X+ M9 T0 J
    The number of cylinders for this disk is set to 8322.
0 `3 y" u* Q2 u* I* J" G7 e/ \, r    There is nothing wrong with that, but this is larger than 1024,
1 ~* ^: M* T. L( @2 s, M8 U: g6 ?& |    and could in certain setups cause problems with:# R2 R2 F7 v3 |: @* T
    1) software that runs at boot time (e.g., old versions of LILO)
" Y! o$ ?( z) r# E3 y$ X* _    2) booting and partitioning software from other OSs9 _# P1 v- ^& W
       (e.g., DOS FDISK, OS/2 FDISK)! H( G: J2 _/ K) ?
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)( g+ u6 t5 L3 p4 U! @. |* l
    Command (m for help): p
) H& ~* @% J. `# z+ s; J* r: I    Disk /dev/hda: 4294 MB, 4294967296 bytes
) {& Y7 ]# t9 n. {9 O    16 heads, 63 sectors/track, 8322 cylinders
; I: D8 n8 i' U, P$ p% u    Units = cylinders of 1008 * 512 = 516096 bytes
) `. g# E% n6 P+ b# f6 c3 o+ L       Device Boot    Start       End    Blocks   Id  System
# f2 S# B- ^; z" Q6 ]8 e! p8 y    Command (m for help): m
3 {1 z/ }8 e0 E    Command action
$ F4 J' |1 z" r& j& N0 T       a   toggle a bootable flag
  n* k1 k( w( W3 T- ^       b   edit bsd disklabel9 p' q( }2 ?9 M9 s
       c   toggle the dos compatibility flag# b8 n- M% e; t0 S' W& w) s2 v, g
       d   delete a partition/ u) W7 ~! I- ~4 S- W4 c' n% ~0 n
       l   list known partition types( a" |8 b5 t: t5 N
       m   print this menu- K" x- `3 i5 Y
       n   add a new partition8 [7 I/ [9 t0 x+ S+ ?+ Z
       o   create a new empty DOS partition table
$ E* k. v3 k% ~       p   print the partition table
6 i$ p: b/ g9 k9 h! P       q   quit without saving changes3 @4 X1 K9 z0 b9 a. g  ?6 X2 i
       s   create a new empty Sun disklabel
( u2 m! k# S7 w       t   change a partition's system id7 E4 O. v% Q/ z( l' h
       u   change display/entry units
& r! H9 Q/ |& \' ]9 |       v   verify the partition table
# y" u) K' o  Q) M: e, m6 o* d0 \# H  |3 {       w   write table to disk and exit/ M! y& [/ Q( u0 w& p
       x   extra functionality (experts only): w3 t2 d3 l* O6 e) `) I
    Command (m for help): n
6 [8 w$ u8 H, l/ V    Command action( {9 I" _/ Y7 n; C# [$ `$ ]
       e   extended
$ q* _" Z; d1 L& {1 C/ B9 Y       p   primary partition (1-4)
7 e+ j& ~, ^( t    p
' B. O/ p* m& \2 V; J6 B, b    Partition number (1-4): 1
) y+ H( J- z# t# D7 }- b! w: ]5 x2 A    First cylinder (1-8322, default 1):
$ H; w$ U( H/ b    Using default value 1+ _. r5 d  a1 {
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
2 |1 F/ Z" Y9 {3 f6 x8 ]    Command (m for help): p6 n$ @& Z. @6 I) U. O+ M0 F
    Disk /dev/hda: 4294 MB, 4294967296 bytes
  U5 O# U. ^2 d; h' a4 `    16 heads, 63 sectors/track, 8322 cylinders
- X" w- y! e$ N6 G5 h    Units = cylinders of 1008 * 512 = 516096 bytes
: _/ b' t3 f8 l- A! n       Device Boot    Start       End    Blocks   Id  System
0 ]/ o8 @2 k/ ^4 V    /dev/hda1             1      1000    503968+  83  Linux7 \& @0 V% y7 f' q* ^# V' ]
    Command (m for help): w
- E4 {8 k# u8 }4 `2 P    The partition table has been altered!
  O6 W8 w) S" W3 N7 B4 ?1 \    Calling ioctl() to re-read partition table.
8 D" _" b* y( h  n2 U    Syncing disks.; p' W+ _" X; Y4 Q& b; ~9 X
    //格式化新分区9 Z! j( e( a& t2 `* T
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)0 j9 m9 T  V' ~5 q
    Filesystem label=
8 h9 U4 o' _% ?* I    OS type: Linux
6 w% C/ E) C. o$ K1 n    Block size=1024 (log=0)
) e8 u- r+ f! z+ I    Fragment size=1024 (log=0)
( s) c5 Y1 }% E: i  Z7 n, L    126480 inodes, 503968 blocks. N* {8 D6 I0 w! a" u1 g
    25198 blocks (5.00%) reserved for the super user
$ J: S) m) L" N' R    First data block=1
# M, E. Q4 \: N5 d    62 block groups
/ n/ O& |* z) |# Y5 [    8192 blocks per group, 8192 fragments per group
# m$ g! m+ p5 m" y* w5 t# u7 w/ J    2040 inodes per group6 F; L1 ~( e' j* b4 k- s
    Superblock backups stored on blocks: 8 T  O; T" N, I- v1 M! T2 c( g
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014098 b* \  b6 {# |' L
    Writing inode tables: done                           
7 E+ z; o' I  y, ^$ S    Creating journal (8192 blocks): done1 Z9 C% e! X4 s) G: `& ~3 @# k
    Writing superblocks and filesystem accounting information: done0 r! y4 n( T, A) p0 y9 z  |
    This filesystem will be automatically checked every 30 mounts or
' b( F3 E" ~' V  E/ \8 l/ k; r& _9 k    180 days, whichever comes first.  Use tune2fs -c or -i to override.) u0 D( ]+ E, h
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点( \4 h% }! K7 K& ~+ u' h
    /dev/sda3              3723848    705992   2828692  20% /
$ R$ f( {2 i+ @6 r5 }4 u    /dev/sda1               101089      9274     86596  10% /boot
/ k8 O, F* b" R* \+ B: n# [    none                     14520         0     14520   0% /dev/shm- T- m9 h) D$ X$ [' }; c* R
    //挂上新分区% J6 z  b# ^; Z! W" Y# L
  1. mount /dev/hda1 /home, v& g, J" T# k' L& y, q
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点- o2 M& N% H( p& M! z* e
    /dev/sda3              3723848    705992   2828692  20% /1 u3 O& R' A# M; e
    /dev/sda1               101089      9274     86596  10% /boot
7 F* L7 W1 b" b& z2 A+ l    none                     14520         0     14520   0% /dev/shm: v1 b- z. v  [7 \1 Y& U
    /dev/hda1               488006      8239    454569   2% /home
+ f6 q: C4 ~2 N. b3 A3 `$ k
9 F, A/ p+ Q# b自动挂载:5 \+ Z) z! w% {+ G& B
  1.           vi /etc/fstab( E" h! I9 S8 @) Q

  2. ! D- i$ I7 q* A3 B% e/ K  d
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    8 y$ j1 q. Z, s2 e3 B2 n
  4. ' e/ K5 {6 B3 H& C4 y. s# l7 B
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
- w* l: ?) A# ?
  1.           mount /dev/sdb5 /mnt/ljp1) |& S  k' C- {2 P, [! I9 E

  2. ; B9 J$ x3 `  X0 D, T" S7 e
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

) f1 n3 i0 C% m9 `- N
( W, |) A+ B: C1 m5 R4 m
( k4 o3 ?' K: Z, w
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-15 02:01 , Processed in 0.011525 second(s), 13 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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