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

 找回密码
 立即注册
查看: 2651|回复: 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)! c3 g, ~6 R( u; v0 o4 R( E; f1 I
      or: fdisk /dev/sdc  (for the third SCSI disk)" V9 L8 W5 ]" u) K& E4 r; Z
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)$ f/ W4 l, H' q3 l+ }- P0 A/ v
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)/ ^/ H! y6 ^- S" p* x# T3 G$ y+ z
      ...  K" F8 E* P  d0 f% C5 G3 d) Q' x
  1. df -k1 C( H, s: h+ ]6 X: O* R3 h
  2. df -lh
    ! |+ a$ N  S" B0 z
  3. 查看有几块硬盘:fdisk -l
    $ |+ B( W6 B! R0 B3 C, G' x# S
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
+ x- k9 t, S) I; V    /dev/sda3              3723848    705968   2828716  20% /
2 W0 |3 W  V! J( o% ~    /dev/sda1               101089      9274     86596  10% /boot6 I& |2 R' X3 |& w2 K! [
    none                     14520         0     14520   0% /dev/shm4 ?  E9 R) u0 H; Z6 R
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用& f! |" E3 p: Y- j
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
) ~6 W6 M  L. \0 L4 G+ _1 {4 K, s    Building a new DOS disklabel. Changes will remain in memory only,
8 G* G) @7 i/ ^; Y- V- G' L- a0 y  |% U    until you decide to write them. After that, of course, the previous9 b& u3 d  x9 S$ t2 ^2 N4 G
    content won't be recoverable.
( T+ E- u6 k- {4 y1 j7 Z    The number of cylinders for this disk is set to 8322.
7 v2 [: ]  y4 X2 J- y; ^) Z+ @. q# z    There is nothing wrong with that, but this is larger than 1024,  c( D* n5 X: K; G
    and could in certain setups cause problems with:
) M* |: Q1 I/ E) x    1) software that runs at boot time (e.g., old versions of LILO): z8 H, r6 O/ I- O$ g
    2) booting and partitioning software from other OSs! x: P5 E# u  y/ h
       (e.g., DOS FDISK, OS/2 FDISK)3 p: e( N, \5 Z5 [- M- r. @# o
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)# t( B8 Z* G! y5 S  k% ^
    Command (m for help): p8 X( B" C! a3 D6 v9 Z" R$ m' J0 j0 K
    Disk /dev/hda: 4294 MB, 4294967296 bytes# h1 K- B- W( f9 z% q7 ^
    16 heads, 63 sectors/track, 8322 cylinders
, b0 l$ B9 Q8 e+ k    Units = cylinders of 1008 * 512 = 516096 bytes5 F% i6 e4 t  n+ F' d) P
       Device Boot    Start       End    Blocks   Id  System
, w9 a1 O% @! v6 W' t( U    Command (m for help): m
% [5 \7 }! F8 q; ^; m# e1 ~& {1 A    Command action
! A, i+ m* h3 `5 ~       a   toggle a bootable flag
, X* |& x* G$ j2 Y9 X       b   edit bsd disklabel
1 e, G  K7 e: x4 C6 c       c   toggle the dos compatibility flag1 ^. T5 p, |' b! |1 s! P
       d   delete a partition
% r9 ^7 x  k7 A. m       l   list known partition types- @! n1 n5 Y- J3 a) w7 H) \& c
       m   print this menu3 z1 @6 V% z% c; Q8 k6 Y0 c0 e
       n   add a new partition3 k5 \4 _0 B% Q! D+ m
       o   create a new empty DOS partition table
1 W! H! K1 G+ W8 z. |       p   print the partition table7 T2 A. _1 {5 L3 }5 ~% x1 i2 E, L
       q   quit without saving changes
8 A; |: y( x0 J! l       s   create a new empty Sun disklabel
, T& S( {2 c+ A, ^: J       t   change a partition's system id
1 J- p( S) K- z; z9 T! S. B       u   change display/entry units2 w' n9 ^+ \: B; L: e0 c; R
       v   verify the partition table4 l- O5 ?: |9 l$ d( q
       w   write table to disk and exit) }" Y$ H3 p. q- O$ _
       x   extra functionality (experts only). ]  R) _% y  Y  Z0 c4 l
    Command (m for help): n
8 S6 t+ O7 M& F/ `    Command action! {4 L: I1 t! T- A
       e   extended: K1 Z: \8 C5 _5 f
       p   primary partition (1-4), K9 q) G8 |6 }2 h1 K8 f
    p
. Y; @* \2 `  h    Partition number (1-4): 1: ^8 ~$ X& E( U2 }9 D# z0 v
    First cylinder (1-8322, default 1): $ ?, V1 Y- q) N3 B3 Z/ I
    Using default value 1: I% g; ^4 k* L# s. Z9 d% @) ~' q
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
+ b3 v2 D& D7 }( F; ^- K/ _& Z: K    Command (m for help): p+ V1 [7 r' D4 Y, z
    Disk /dev/hda: 4294 MB, 4294967296 bytes- F/ V$ l. \. y% n1 s0 Z  W
    16 heads, 63 sectors/track, 8322 cylinders
0 o1 d! g6 _: Y: k    Units = cylinders of 1008 * 512 = 516096 bytes
3 T3 B% T( o4 ?) H" c       Device Boot    Start       End    Blocks   Id  System- ]- s3 n$ Z( t+ F% g' n
    /dev/hda1             1      1000    503968+  83  Linux; Q8 O0 R; B% m, }
    Command (m for help): w3 d+ k% O: P: z* z
    The partition table has been altered!' U) b+ e( D- v' Q
    Calling ioctl() to re-read partition table.
) F. D; M1 g3 L! J. ]* O    Syncing disks.
0 Z/ O( V) N+ C, Q* s" }    //格式化新分区
  O6 i2 s; }. ~( w: |/ m
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
0 i6 |- O- J  x+ S  r7 t& a    Filesystem label=
! V+ {7 Z8 j! _; ^1 n, s7 n0 [$ o    OS type: Linux' U% O6 [, m( C. i1 i' n
    Block size=1024 (log=0)
$ T- F* b8 \, G    Fragment size=1024 (log=0)
! F. p9 y7 S$ }5 f& y    126480 inodes, 503968 blocks6 m# n# y, \3 A9 J6 n1 `6 o8 j- Z
    25198 blocks (5.00%) reserved for the super user* W- F5 s' d8 _- K; }* E4 |$ a
    First data block=11 B5 ^& Y6 y* D* L# `
    62 block groups
6 z" h# U7 r# z& B! Y    8192 blocks per group, 8192 fragments per group
2 `, I+ C+ R7 ]: m  I# I$ V$ g    2040 inodes per group
# G8 D6 ~. c8 }7 ^    Superblock backups stored on blocks:
; l8 ^" `5 O8 Z2 N$ [            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, y+ l, i1 q5 F2 |& o- ?) f; G
    Writing inode tables: done                           
" S. b/ @  s4 b    Creating journal (8192 blocks): done
) t& B' @9 u6 D3 |& B; X    Writing superblocks and filesystem accounting information: done
2 M1 X  l& y# o5 j8 A0 P% r    This filesystem will be automatically checked every 30 mounts or5 F" F6 G! ?. e3 t4 `# j  s. Y! a* X
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
1 a: [2 g! |, K; X9 p. f$ M6 P' t: N
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点  b& f% V' G6 Z) M
    /dev/sda3              3723848    705992   2828692  20% /
( L" A( c8 O" w( Z6 f+ N    /dev/sda1               101089      9274     86596  10% /boot( I1 {( l6 ~* N
    none                     14520         0     14520   0% /dev/shm
4 D. K9 ^0 Q4 Q# N. K- j) q/ y% Y& I    //挂上新分区2 n4 ^. N0 O4 {& a( j  B) _
  1. mount /dev/hda1 /home
    & R# h8 R" L5 p: I" x4 }1 m
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点. N  M1 j1 u% }( j$ L& t+ ?
    /dev/sda3              3723848    705992   2828692  20% /5 A8 a0 b( g  w& ^( Q, _( R
    /dev/sda1               101089      9274     86596  10% /boot
1 {! V( T& G7 A    none                     14520         0     14520   0% /dev/shm) s' n) r6 h8 K4 w6 r8 P6 U6 R/ X
    /dev/hda1               488006      8239    454569   2% /home
+ }' }4 v& P4 x: @$ Z+ ~, \% G2 `) l# e1 [* h4 B7 C' ?1 B
自动挂载:5 W9 @& K5 O+ L6 e
  1.           vi /etc/fstab. @3 b' s' c# p  l

  2. ; r' l0 x9 |+ ^
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    8 m, y% L% i! Y

  4. . Q6 Q( R2 s3 g. A+ G: N
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
3 E% ^% U% e, P5 n' f
  1.           mount /dev/sdb5 /mnt/ljp1) q! k* K& w6 O* P5 v5 |, b+ i
  2. 0 @& F( m8 z9 T+ i( v! A% G0 _. n1 h7 J
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

, u" F9 }& i( l  f& a# M9 a2 S& w  U8 v" m

3 ^+ P, u: N( O6 J  b9 n
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-7 17:41 , Processed in 0.008614 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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