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

 找回密码
 立即注册
查看: 2815|回复: 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)( B: s/ z& ?% U6 C. V* n
      or: fdisk /dev/sdc  (for the third SCSI disk)
; x! H! W3 A1 f) l0 p      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
5 H3 I. Z' `, I' r2 z4 q4 q3 a      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
$ a* w$ P/ T0 @) A+ b      ...* \% {3 s( u! Y$ x! k: g  f& {
  1. df -k
    , i' @1 i7 P2 R0 b. ^
  2. df -lh
    , Z" Y5 ]7 Z5 s  O
  3. 查看有几块硬盘:fdisk -l
    0 H) x1 C2 h! U+ s
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点. L( f" p  K1 b7 e1 G
    /dev/sda3              3723848    705968   2828716  20% /
* u: z/ B3 r2 u1 ?3 R    /dev/sda1               101089      9274     86596  10% /boot: v7 x' @1 ]  }) N/ k
    none                     14520         0     14520   0% /dev/shm3 P* P) |& ^8 H) F! ?0 ]
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用$ U% _8 ?3 P( ~3 K
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel" E6 W( c/ d8 s! r0 h2 M
    Building a new DOS disklabel. Changes will remain in memory only,: K+ g2 r7 y; Q8 q* G% w* U0 X
    until you decide to write them. After that, of course, the previous
$ O" C7 ], |1 G4 H    content won't be recoverable.$ f# Y& [$ i4 h0 k+ ^
    The number of cylinders for this disk is set to 8322., z' y, x* o% U
    There is nothing wrong with that, but this is larger than 1024,! Y+ j( E* z9 `% d. h
    and could in certain setups cause problems with:5 Z- Q0 V) C- H' K. g& u
    1) software that runs at boot time (e.g., old versions of LILO)
: t( l7 x# ^3 z* I. {9 n: R    2) booting and partitioning software from other OSs) X# K  z3 @- g" V
       (e.g., DOS FDISK, OS/2 FDISK)/ ~/ i8 l1 u% B& }
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)' k8 N2 N4 }9 E5 P$ ^3 z
    Command (m for help): p( x: T+ k8 ?4 S, Y& T# C4 U
    Disk /dev/hda: 4294 MB, 4294967296 bytes# v; o4 ?+ D; l1 w! [4 b
    16 heads, 63 sectors/track, 8322 cylinders
+ |: s/ n% A0 S  K    Units = cylinders of 1008 * 512 = 516096 bytes. U  O# }6 R$ @# ?/ ?1 I0 E/ K
       Device Boot    Start       End    Blocks   Id  System
9 z; l- v; N9 N# E8 {    Command (m for help): m
" ?4 _6 z2 n$ \! r% X' g# t0 t    Command action8 U; i: H: y* |4 t1 O
       a   toggle a bootable flag
- O( I2 d/ t" e+ e% i2 p9 b3 \       b   edit bsd disklabel0 E; |, F' D3 b! g3 f
       c   toggle the dos compatibility flag; I" F4 z. i% Y: z
       d   delete a partition
8 f# N& W" L7 _# j9 P" ^* [3 D       l   list known partition types
! j8 w  ?) a% F9 Z# R7 z/ @5 [( D       m   print this menu
( q! G7 B% g! }# Q7 C% d: S( q& e) I       n   add a new partition. o: H* u9 T* ]! v+ B: ?
       o   create a new empty DOS partition table3 C& q7 W) b$ Q- t1 `, y
       p   print the partition table
5 v; w. s- W  U/ p5 C& e       q   quit without saving changes
0 Y# q9 B! M2 D1 l! j       s   create a new empty Sun disklabel  J3 U0 P% \& s* \2 |& p+ r
       t   change a partition's system id8 r: n( \+ ~3 g" _4 v
       u   change display/entry units
& p8 I7 \. E9 d& A. b$ z       v   verify the partition table
9 e/ y& h# ]' S3 m$ C       w   write table to disk and exit
7 B1 B" W% ^& h+ U1 R6 T2 E/ I8 P       x   extra functionality (experts only)
# J! ^2 M9 Z4 m$ y- j    Command (m for help): n! ]! X9 v5 @6 j1 O8 c
    Command action+ b( W$ K# z4 a. K) d3 y5 t
       e   extended, X0 `0 P5 N/ q0 w1 `
       p   primary partition (1-4)" l9 a) u# k- P
    p( J$ a) V8 v; h) m
    Partition number (1-4): 19 S5 x, k5 n# k# D! t, J4 a4 |4 R" [
    First cylinder (1-8322, default 1): ) Z( f: ^8 }* n/ w! I- P  K7 U# n
    Using default value 1& U. b, k7 @. n6 v* R9 Z" f3 j
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
# N7 L6 n( g. f  ]/ k    Command (m for help): p' y0 g7 n/ N& c9 a0 J
    Disk /dev/hda: 4294 MB, 4294967296 bytes
: Y/ D! W& v3 f8 o( @    16 heads, 63 sectors/track, 8322 cylinders. h2 _! P* ?8 `5 o- y+ j
    Units = cylinders of 1008 * 512 = 516096 bytes
1 B2 R) r  h: R5 U2 O  q" X6 I       Device Boot    Start       End    Blocks   Id  System
. ^8 V  S8 B6 l& P    /dev/hda1             1      1000    503968+  83  Linux
# |( F  V4 j: d- ?' b7 F( f  t# M    Command (m for help): w" p6 T6 W" z+ {, R0 |6 o/ o5 G9 q3 C
    The partition table has been altered!3 q" T6 {: c. {4 L, [: y
    Calling ioctl() to re-read partition table.
  G4 r% V) F% r. k4 [2 X    Syncing disks.
7 A1 `8 B/ `2 H0 T' K    //格式化新分区
# y6 ?6 K; s0 D9 k! g) b
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
' n3 z( ?3 I" E( A( ^; k5 |    Filesystem label=
9 g' d$ v- r( v  J    OS type: Linux
0 U# H+ s; W- W" i2 B4 {    Block size=1024 (log=0), G$ @  E4 O, i- z1 c5 h5 F. o
    Fragment size=1024 (log=0)
& A# J; f: H( M( U    126480 inodes, 503968 blocks
" |- v( E! p9 t& |2 M6 l" E0 N    25198 blocks (5.00%) reserved for the super user
# l- W" t$ P( _  v3 P, P    First data block=1. V* S' I0 t+ F  T  G0 W
    62 block groups( E) E" [' M9 Z% P, b/ r
    8192 blocks per group, 8192 fragments per group
- U! k4 O5 w  p7 c# P. [4 l. }    2040 inodes per group9 {! h7 v, k) k. ~5 z8 Z
    Superblock backups stored on blocks:
% |+ O# Q  M- O& K) o) i* t            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409: {7 Z! P4 }3 ?. d5 |* B
    Writing inode tables: done                           
; J8 s4 s& k# U( {    Creating journal (8192 blocks): done
7 @# v5 f( m/ c    Writing superblocks and filesystem accounting information: done! B! {! f: Q& Y! ?% [: E2 |
    This filesystem will be automatically checked every 30 mounts or- k  p. w( N7 q- ]9 T4 {
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
9 w% Q+ j) D# j: g
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点' }- N1 d  Q$ m8 R+ [. L; a
    /dev/sda3              3723848    705992   2828692  20% /
4 X, e8 |8 A$ i$ a7 e, d    /dev/sda1               101089      9274     86596  10% /boot
- ?' `8 j9 }9 E7 V$ G    none                     14520         0     14520   0% /dev/shm
& r$ ]( M2 ?9 }  Y6 r) o    //挂上新分区3 |: `7 k( C: J' n0 I6 \
  1. mount /dev/hda1 /home
    $ f) L/ J/ U1 Y
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
2 ]8 q4 r5 {+ P$ S" O* a! @    /dev/sda3              3723848    705992   2828692  20% /7 t6 t2 b: C9 S0 k9 I. T3 V. f
    /dev/sda1               101089      9274     86596  10% /boot7 K2 E; |  f3 K6 |# _  G, L; r
    none                     14520         0     14520   0% /dev/shm
, O* v' j/ R' m! [* o    /dev/hda1               488006      8239    454569   2% /home
4 D7 ]9 `& j* u' V, w
" P5 X: l: L; n5 g. e6 h' m9 p( {自动挂载:9 |7 k! k/ l  B/ ]9 L
  1.           vi /etc/fstab9 g" \' T: J6 h5 x4 X" m' f

  2. + Z$ D3 H+ R$ j; i
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    . S  H( `2 X: J8 X7 Y

  4. & z+ Z6 o& _7 ^. L
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:" E- r, j) ]- ?- K% M$ U  a
  1.           mount /dev/sdb5 /mnt/ljp1% |2 A$ X6 P  v4 }9 k& K
  2. 6 S3 [; ?" X3 a1 @) K
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

+ Y- o' p( v7 c2 d2 O# ]4 C; X( a! [8 `
% Q$ H3 {7 o7 E6 h( K0 P7 d+ u
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-20 05:04 , Processed in 0.023222 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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