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

 找回密码
 立即注册
查看: 2646|回复: 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)
0 n% x8 n  w8 m& L      or: fdisk /dev/sdc  (for the third SCSI disk)- B$ |6 ^; U# m4 c7 C# ^
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
8 f) a6 ]: Q/ `& y7 `      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
( |" U" q1 M& H: D" ]2 c# i      ...
1 t8 ?' G9 r% t# g9 A; E
  1. df -k
    # O. E+ X' y" s, Q2 \1 h+ c  s
  2. df -lh9 Y6 d9 x1 D5 t: D4 B2 z# ~$ A: n
  3. 查看有几块硬盘:fdisk -l$ m7 y$ B; S, E* A" \3 e
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点) I2 t9 C6 c% |0 ^- N1 w  M- O+ m
    /dev/sda3              3723848    705968   2828716  20% /- v: ^" j6 s1 `3 ?* }
    /dev/sda1               101089      9274     86596  10% /boot5 e6 X% d* q$ r
    none                     14520         0     14520   0% /dev/shm
/ D$ {8 `# Q( @    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
& Y6 v& _$ |( d, R8 G+ H# G2 \2 ~8 ^
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel4 Q2 Y( ~* I0 w! P9 v/ E3 Y1 Q* n
    Building a new DOS disklabel. Changes will remain in memory only,* ?% n' A  \/ E! m; W& g: _' y
    until you decide to write them. After that, of course, the previous
7 G7 R3 w$ y" K# b6 c* w; _$ V    content won't be recoverable.9 A8 \8 A  d, f
    The number of cylinders for this disk is set to 8322.
4 `4 f' ^+ q8 w3 y  M0 F    There is nothing wrong with that, but this is larger than 1024,5 v' K- L0 }5 S/ b; D" Z
    and could in certain setups cause problems with:" q) n: i1 w# P" k& j* q0 V
    1) software that runs at boot time (e.g., old versions of LILO)( J! O6 v* U) [, s5 _
    2) booting and partitioning software from other OSs, g1 z2 b+ D9 \; F
       (e.g., DOS FDISK, OS/2 FDISK)
2 T4 Q% [5 |) t, f' m3 a    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
' c' Y6 R0 X" K' t# K1 u    Command (m for help): p4 f; b( T7 ^% m. O: r3 S/ ~
    Disk /dev/hda: 4294 MB, 4294967296 bytes
1 |, A% a" X  |8 J/ d5 h: b    16 heads, 63 sectors/track, 8322 cylinders
& o- ~9 A7 ]2 Y8 s# k    Units = cylinders of 1008 * 512 = 516096 bytes
4 w  K+ t3 O- ]8 i4 r: O4 j       Device Boot    Start       End    Blocks   Id  System
  m1 W- f: C  w" I$ s5 F& I# L    Command (m for help): m
" Q5 U6 k" ]' U! o. p0 m" y' D    Command action2 k+ ~3 b' o+ _0 o
       a   toggle a bootable flag
) ?  g9 b! n' A. V5 `# T8 S# D       b   edit bsd disklabel  J& P$ P! c7 X: \) X, [5 S
       c   toggle the dos compatibility flag' H& \* w+ R- n6 {, @6 V- d3 S- [: Q
       d   delete a partition
- \3 |. q( J* R1 o3 U) G1 l       l   list known partition types
  |5 n' v2 D1 w9 z' d# m& N       m   print this menu" K; a9 n& V: ^6 z# T' |. t
       n   add a new partition& A: m8 d9 i; K( T3 I$ N' H# e
       o   create a new empty DOS partition table1 g- h- W5 H+ H- |1 w
       p   print the partition table1 c2 Q% d" a" c6 \' B
       q   quit without saving changes
: A( [% c/ R8 }$ N       s   create a new empty Sun disklabel. u! [) }# t7 }: l
       t   change a partition's system id
# W1 x$ L# |% Y% c* d  V; r       u   change display/entry units
8 M+ L5 B, ~, Q4 G( ?' e/ r* x       v   verify the partition table; D7 p/ _& f0 G& W3 h3 ]( ^. ]% c
       w   write table to disk and exit3 L( r+ h- D3 U1 y9 x8 \
       x   extra functionality (experts only)
2 i6 F) ]; O4 h* i* q. F- M/ L    Command (m for help): n6 f. t- i% }8 _( d; ^7 |1 _4 F( _
    Command action% o1 p% f; y$ |3 _* T
       e   extended$ o+ t+ ?  B8 p8 P5 }: I$ k5 |
       p   primary partition (1-4)
$ O/ p8 M) G3 X# I1 |3 ^. S0 p0 S    p
2 E9 i8 W" B8 Q& j' P    Partition number (1-4): 1
6 G9 `" _# Q% L' [* g+ h    First cylinder (1-8322, default 1): ! M- A) @8 f. O
    Using default value 11 u  c3 D0 k. y5 a% K6 G
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
2 @. H" e- l% G  U* y7 x# ?    Command (m for help): p* Y( w6 n1 x# S: C. W* [3 W
    Disk /dev/hda: 4294 MB, 4294967296 bytes
& Q8 C9 C2 n! Z: O* ~: d1 ]    16 heads, 63 sectors/track, 8322 cylinders
0 g+ E8 D4 l( d    Units = cylinders of 1008 * 512 = 516096 bytes
" G9 y) X( O7 d2 t- x6 G( A2 z       Device Boot    Start       End    Blocks   Id  System+ w  ^) C6 [! S
    /dev/hda1             1      1000    503968+  83  Linux
& L& V# p3 m4 j    Command (m for help): w
" O$ a+ c; s; {) K7 e    The partition table has been altered!
$ Q/ q+ Q, F( h  v: T  C2 @5 X    Calling ioctl() to re-read partition table.: M: [/ N4 {. N8 E, c+ ^! `' p3 I
    Syncing disks.# C# M  F8 L3 W( k' n: h) L9 x
    //格式化新分区' p5 `5 d! h% n- y2 j7 G0 J* E4 {- Z
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
, O* `- @3 w; x  W% ]5 L+ t    Filesystem label=- d/ k; Z% }, u! W$ l
    OS type: Linux, F. l. L0 o' V2 t
    Block size=1024 (log=0); @6 c  |( G) ~9 n& }7 c1 c
    Fragment size=1024 (log=0)% M) I/ j5 @% m3 a
    126480 inodes, 503968 blocks
% a9 n$ ~/ a1 B; P; W/ M* r    25198 blocks (5.00%) reserved for the super user/ Z. W( L) u7 H
    First data block=1
6 u- [* \( p& W& n9 O7 i2 X/ s6 B2 W    62 block groups
+ a/ f0 H3 p6 G8 P2 f    8192 blocks per group, 8192 fragments per group2 x" y+ P+ q  V$ K( V. R& {$ A, [
    2040 inodes per group
9 f  o# L( ]7 q4 }/ C2 H0 [    Superblock backups stored on blocks: . E6 k2 G' b( v- ~. t
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409+ x1 B, U  D* T/ B% v5 r1 e3 F
    Writing inode tables: done                           
( ^% O& d- K1 e. Q; u9 g    Creating journal (8192 blocks): done
5 T8 Y, `1 x. J' P0 L( n! ]2 \    Writing superblocks and filesystem accounting information: done% z$ N9 Q* ]* N3 N6 [5 H
    This filesystem will be automatically checked every 30 mounts or
' D( [) T. d5 |7 U7 p# H4 q    180 days, whichever comes first.  Use tune2fs -c or -i to override.
3 [2 B* R3 o! G/ C
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
% I" s) J3 e0 C    /dev/sda3              3723848    705992   2828692  20% /, t* K2 ]6 H; d/ n" Q: a# G! O
    /dev/sda1               101089      9274     86596  10% /boot
# t+ ]9 K# b$ Y1 C; R. ]    none                     14520         0     14520   0% /dev/shm' U1 u, ]4 L/ W4 @0 ^
    //挂上新分区
. T9 w2 q! ^* d( E, C
  1. mount /dev/hda1 /home
    5 e9 R3 Q5 O; y9 F& n
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
0 \5 J( y4 d* B" w* [    /dev/sda3              3723848    705992   2828692  20% /
/ J' G" ^! i. N1 s6 J    /dev/sda1               101089      9274     86596  10% /boot* f3 H; t* i1 S. c
    none                     14520         0     14520   0% /dev/shm9 m: a2 A9 p. S0 n" \( p" r3 d
    /dev/hda1               488006      8239    454569   2% /home
" u/ ^  k8 F7 K# {+ ^* E% a( V1 p: n5 {% _1 o. t- y6 n! k; y6 ]
自动挂载:3 R6 H+ p2 ]" q2 f
  1.           vi /etc/fstab
    # ^/ B9 C% {4 \% W/ J6 A: p
  2. 7 `6 T8 n$ _: G. {
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    / h: C9 z) p- c3 K6 C

  4.   H9 L, K2 F4 E$ }2 e
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
/ f& H4 A: i7 n
  1.           mount /dev/sdb5 /mnt/ljp13 k, \- r4 W. ^. ^8 s

  2. # s( U+ R. V, f3 Z/ `/ M1 S
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
/ y* D' H' i# {1 a- N. ~  S# h5 M! W

7 ]# @& g1 P" M) i3 K: F( C4 U, ]7 \: u( I6 V
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-6 15:48 , Processed in 0.015968 second(s), 9 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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