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

 找回密码
 立即注册
查看: 2793|回复: 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)
1 I- B+ j2 N1 g, r      or: fdisk /dev/sdc  (for the third SCSI disk)) g' y+ ?4 W5 N" P6 |, s; S' \0 R
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
! A* K6 Q) j4 u: T3 v      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)/ d* W, s$ b+ ^/ n1 Z  g' z
      ...! P9 X$ B: Z0 C$ W4 T
  1. df -k
    : ~, E* P7 U" {# \
  2. df -lh) K6 U9 U  f4 [$ t; ]
  3. 查看有几块硬盘:fdisk -l
    # e# m% R, v3 P, n; p1 S# ~1 S
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点0 {$ q7 ]  x% M/ z, i  ~+ `
    /dev/sda3              3723848    705968   2828716  20% /
3 }; d- P3 ?2 H# T, O+ b3 f% a    /dev/sda1               101089      9274     86596  10% /boot! s1 b9 ]  R* D* c
    none                     14520         0     14520   0% /dev/shm3 J0 @) f0 q( j
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用) P) t8 y' T4 o- Z7 I4 J0 a
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
' i- f0 m- h/ |8 m3 Z& f7 m8 U    Building a new DOS disklabel. Changes will remain in memory only,) ^2 F1 C5 u3 o0 E
    until you decide to write them. After that, of course, the previous
, j: b0 m' \5 A' F2 e    content won't be recoverable.
5 d% a% N5 m- S) d. w% g    The number of cylinders for this disk is set to 8322.3 O; K+ z) q0 e
    There is nothing wrong with that, but this is larger than 1024,
4 E( ], P9 b9 y0 N    and could in certain setups cause problems with:0 `/ D9 x2 \$ f8 w
    1) software that runs at boot time (e.g., old versions of LILO)
1 e% U! n! ]' _+ Y    2) booting and partitioning software from other OSs4 U5 e0 R. g5 ?. f
       (e.g., DOS FDISK, OS/2 FDISK)' G! i+ J/ ^) v8 _. \0 h) @2 s
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)/ {( P8 a# A" a* F% i6 ?% D
    Command (m for help): p% c$ `9 `1 t1 `! v/ n5 @
    Disk /dev/hda: 4294 MB, 4294967296 bytes
; C7 ]9 e9 _. Y, l% m    16 heads, 63 sectors/track, 8322 cylinders
/ E0 l5 b0 I7 R" a/ b    Units = cylinders of 1008 * 512 = 516096 bytes
2 g0 ]/ }+ d$ v       Device Boot    Start       End    Blocks   Id  System
* l/ V8 _# C' ?    Command (m for help): m
4 p" n+ J% q/ B6 [8 K. m    Command action: h( W( h8 v% c9 p1 v
       a   toggle a bootable flag# y- P+ b1 X( w$ V# G$ f& P! p: X
       b   edit bsd disklabel" n- h5 Y. n6 f' Z
       c   toggle the dos compatibility flag
( o8 P; [; B+ ^3 Y' y       d   delete a partition- y: x) K5 q1 W' u: x0 m1 Q
       l   list known partition types# P3 T& I1 f' A* J- e" h
       m   print this menu; Y3 H3 |* j  V
       n   add a new partition
! c0 q5 q$ K, d( |( @; i- B' O+ ~4 v       o   create a new empty DOS partition table6 w- q8 I6 H. R+ N6 u: v# ?% D' `
       p   print the partition table
, x# @& p( s6 I9 N       q   quit without saving changes0 F; i* J7 c* W0 H1 M
       s   create a new empty Sun disklabel0 a5 z" i) o- l3 O, T$ `
       t   change a partition's system id
# y( l- a4 R; S4 J, ^" E       u   change display/entry units
4 s) T  N0 m/ x2 C5 t       v   verify the partition table
5 `! L. _4 V6 k* G9 c$ l       w   write table to disk and exit9 b( Z; e( K5 D7 b( W5 ]
       x   extra functionality (experts only)
' }5 D2 s+ Z1 C9 d    Command (m for help): n/ z. k9 b& L: o! M
    Command action
4 y0 E% U7 f( ~  t2 T       e   extended% s) [' H/ k) f7 L, N/ s8 ?
       p   primary partition (1-4)
; w2 [2 z1 }+ @! t! D9 A    p5 y# J5 g- G2 n. l0 w
    Partition number (1-4): 1
4 F- {1 E4 ]3 @6 k. z    First cylinder (1-8322, default 1): 5 c5 i; |/ K( O% b* b) C$ f% V3 B
    Using default value 1
$ b2 P- a7 q. W    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
( Q1 i$ c: q  n: n4 S: C' P( V6 I    Command (m for help): p; P8 A# d+ {1 Z3 }& y. X
    Disk /dev/hda: 4294 MB, 4294967296 bytes% I7 w& ~( X( v  o) C) L
    16 heads, 63 sectors/track, 8322 cylinders
( j' Y! `/ K' N% m6 U/ \    Units = cylinders of 1008 * 512 = 516096 bytes& B- n9 V9 F; [& e4 C
       Device Boot    Start       End    Blocks   Id  System. k) z1 T  }* Z; s0 s8 C$ K
    /dev/hda1             1      1000    503968+  83  Linux
: ]% Z1 t( ~$ S# k3 V4 a0 R8 z    Command (m for help): w
# f; h  w3 p4 d' w9 z4 H4 h, F    The partition table has been altered!
. {! R5 i' J3 y: b, V$ t    Calling ioctl() to re-read partition table.
! F5 ]# ?5 r7 q# V    Syncing disks.  W; |  J- f+ l& A
    //格式化新分区& R; B6 D$ B, j8 _- C! b* q2 U
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)% J6 _5 S% z" b6 @6 D
    Filesystem label=4 C6 |# A: I# M( L' ]4 @
    OS type: Linux4 E# r: u7 E: X; y/ D5 W. O
    Block size=1024 (log=0)# E) m! B! e& S3 d2 B- ]
    Fragment size=1024 (log=0)9 o1 ^0 ]3 F' [' V9 C+ F4 c) E* z. d
    126480 inodes, 503968 blocks$ u! f* x2 p6 |3 z2 P! Q, x, p: u
    25198 blocks (5.00%) reserved for the super user
, l3 {" H2 `# p7 C) \    First data block=1
1 t. e# o) H# I, X: }    62 block groups
/ Z- u2 o* A. K# r# S* n/ e' C- u    8192 blocks per group, 8192 fragments per group
3 B' S2 C& P5 H6 n1 B* {    2040 inodes per group. T1 z& D3 K# J/ B( N9 `0 t7 _
    Superblock backups stored on blocks: 7 |: v' G# q3 K. n. j  z
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 4014091 @' G; {2 ~" w& V' Q' J  A- }, n
    Writing inode tables: done                           
- L7 Q) O5 W9 n+ n    Creating journal (8192 blocks): done
( y& `2 _, U9 s    Writing superblocks and filesystem accounting information: done
5 @6 M; [& ~3 p. x' W" G3 a    This filesystem will be automatically checked every 30 mounts or
8 J  I) E7 M2 t6 E5 k0 ^    180 days, whichever comes first.  Use tune2fs -c or -i to override.$ Z4 E. _" f+ b1 [7 c
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点# K: @$ h3 @* a+ A  l
    /dev/sda3              3723848    705992   2828692  20% /3 B' J2 L/ p3 U4 I, Z3 d" Z$ b: W
    /dev/sda1               101089      9274     86596  10% /boot
: }/ \7 S( @4 R    none                     14520         0     14520   0% /dev/shm
- `6 J+ n* @" \+ T9 I    //挂上新分区# E9 D! j9 m( Y, i8 v9 M4 |; ^
  1. mount /dev/hda1 /home; P- x7 r. i! ]$ W$ l; p. r
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点) H, z3 ]5 Q6 t( w" {
    /dev/sda3              3723848    705992   2828692  20% /
$ E' ^  i3 v( A' X: H" h    /dev/sda1               101089      9274     86596  10% /boot5 H/ a# x0 U2 o+ j
    none                     14520         0     14520   0% /dev/shm
. s6 ~9 x5 `- a7 M- L6 f! U    /dev/hda1               488006      8239    454569   2% /home& _9 [% m- C" I& i* }& f6 o5 D
8 s% t4 h) a& m
自动挂载:& Y* n- r, |! d! h# e/ b
  1.           vi /etc/fstab; |( J2 l. \1 P

  2. $ A( T, i! g9 I
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0' i  J4 u2 z$ r7 x% s/ K. \. H

  4. + X0 T: l5 \2 k; v; E
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:% u7 l0 V5 e5 g6 b, r
  1.           mount /dev/sdb5 /mnt/ljp1/ H" \# a6 c! O! c2 ^- Y8 n

  2.   I- }: t4 }7 W5 Q
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
; o: e$ `+ a. ]0 \1 u/ O3 |* G% d
. m7 _. V4 |9 O) H; M
1 S* n! y; A" Y9 a' ]$ N1 v
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-16 14:56 , Processed in 0.036069 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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