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

 找回密码
 立即注册
查看: 3042|回复: 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)
) u4 U$ _) N3 o9 u( e) K      or: fdisk /dev/sdc  (for the third SCSI disk)
* K- e3 t  L" i7 Z/ V      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
  Z2 d# D! K+ y8 Q      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)$ ^& ?6 E! ~# n) x4 |) m* j
      ...0 c1 ?! x: t/ u9 a9 B* b" I
  1. df -k- J" m' [( C9 c' P
  2. df -lh. d0 e6 Z) w$ S+ t4 \. }) R
  3. 查看有几块硬盘:fdisk -l
    0 Z: C3 k2 h7 [% O$ Z
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点, [0 C, \9 n; m* v6 b
    /dev/sda3              3723848    705968   2828716  20% /" W$ d) L, _5 F- @4 T3 q: N2 Z
    /dev/sda1               101089      9274     86596  10% /boot
! u. b& @% I6 z# ?    none                     14520         0     14520   0% /dev/shm
- F8 f" I0 C: w8 t' b    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
  b+ \: q5 ~; S, ~' I0 P7 Z
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
: ~4 }4 Z' f* g6 F" B9 _0 i    Building a new DOS disklabel. Changes will remain in memory only,6 `* |, k/ c7 F6 k
    until you decide to write them. After that, of course, the previous& }. A. Q7 e; p8 Q' M
    content won't be recoverable.2 g2 V" k# s4 q: \! ^) L; D2 j
    The number of cylinders for this disk is set to 8322.
5 o" I3 ?: w6 m    There is nothing wrong with that, but this is larger than 1024,
3 o( Z5 u7 H5 O& x) u) j    and could in certain setups cause problems with:
# i1 m3 s4 i4 a# F    1) software that runs at boot time (e.g., old versions of LILO)
+ Y" t; U: ~5 A    2) booting and partitioning software from other OSs
9 a: N3 O' a' w  l0 D       (e.g., DOS FDISK, OS/2 FDISK)1 }8 [' B8 j6 z+ o
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
/ g$ y: z/ o  s0 _7 @5 q    Command (m for help): p# s' ~; J. G( S5 v/ n
    Disk /dev/hda: 4294 MB, 4294967296 bytes
' t1 M% g( _0 `  X5 G! w    16 heads, 63 sectors/track, 8322 cylinders; A7 p+ M5 |& y4 P- N4 ?+ B
    Units = cylinders of 1008 * 512 = 516096 bytes
4 Z1 t- r& G+ @6 [* [" X       Device Boot    Start       End    Blocks   Id  System0 @0 C4 H% f5 P' ~1 f  _
    Command (m for help): m
/ k# s! |$ ]6 H- V  U& ]    Command action
6 }6 z  u. g6 W  m5 w  Z) d. I8 h       a   toggle a bootable flag$ d" t0 `4 O3 {& B2 b$ D0 |5 N$ Z
       b   edit bsd disklabel
! T3 Z# P; |. m+ d: P) }# w       c   toggle the dos compatibility flag
) Y$ V. M$ o, Z! m       d   delete a partition
. X  Z) Q' h3 a       l   list known partition types
& A# q/ }" m& ]# A; Y+ U, O- o8 v       m   print this menu
( P( }) O4 }; b) ?1 R3 O) V       n   add a new partition) Z& L- [# O5 F9 B9 G
       o   create a new empty DOS partition table
2 X' ^6 {8 @* C8 t; B$ e$ |       p   print the partition table
+ A: w8 f- H# z9 N0 C& Q       q   quit without saving changes1 ~& p9 {* V) V: H
       s   create a new empty Sun disklabel
  U& t2 _4 V  z% n% i6 ]       t   change a partition's system id
4 q6 T8 F# g5 D       u   change display/entry units
& @. ^1 M% M3 L6 R       v   verify the partition table- R3 }* g' t- x$ `" S& k5 d0 W
       w   write table to disk and exit
6 @5 Q  O7 Y7 w       x   extra functionality (experts only)
& I! y7 ~. E0 c7 Q# `    Command (m for help): n+ V4 e( X3 P/ `# ~: B% H4 R
    Command action
. I" i5 D- S6 I( a) g( K3 s       e   extended
) I1 ~. M! O0 m. s5 ]       p   primary partition (1-4)' F4 t( m. O" ?5 ^  }
    p
; L6 E9 M* r0 ^$ n/ q! X( r# ?    Partition number (1-4): 12 p4 q5 o8 O  y
    First cylinder (1-8322, default 1): 6 k6 d# E& r: @( q, q  N' w) X
    Using default value 1
  i( k- S3 ^8 j' }    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
1 z7 C* r4 C4 u9 H. ~( `/ W    Command (m for help): p* Z; f" A; y- ^+ u0 }0 A
    Disk /dev/hda: 4294 MB, 4294967296 bytes
; ^6 n+ x% h% e1 h% a. u1 c    16 heads, 63 sectors/track, 8322 cylinders3 z# b+ l- U( Z9 s; y% J$ H) q7 m' l  w
    Units = cylinders of 1008 * 512 = 516096 bytes
7 ~* n" E) G- c2 e. a       Device Boot    Start       End    Blocks   Id  System# b2 r0 f/ S& c) y  W
    /dev/hda1             1      1000    503968+  83  Linux7 W7 a+ [, U1 t8 T4 C
    Command (m for help): w; Q" C9 Q( ]! W, X9 g2 `
    The partition table has been altered!' s7 G- s" Q( U) ~+ w8 f1 ?8 N, \
    Calling ioctl() to re-read partition table.
9 w% y* Z9 |; j, d: N" n4 I    Syncing disks.
4 H0 }: u1 Q* C' z! ^2 @) v" F    //格式化新分区
1 c1 |4 G$ g1 r
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
3 n( M0 T  G* W" t  \# L' ^    Filesystem label=
: }1 ~* G$ d: [! X; \    OS type: Linux
: r5 e% v6 o* K5 m+ @4 q" X% ]    Block size=1024 (log=0)% C2 z2 R" V/ G2 o& V, E
    Fragment size=1024 (log=0)+ Y% E- \7 T9 p5 Z; C3 i
    126480 inodes, 503968 blocks
% C# T4 S" U) Y& W    25198 blocks (5.00%) reserved for the super user
6 D  R; E9 C# \( i) ^    First data block=16 l9 u, v9 U" c5 R7 S
    62 block groups
8 @  C: Y0 y6 \3 x    8192 blocks per group, 8192 fragments per group, l4 o" R5 D3 y- g1 L0 I% J/ M/ l
    2040 inodes per group
- V- l' g+ P' I1 J4 H4 z$ S4 U    Superblock backups stored on blocks:
+ {2 E6 }  P: p6 j* i$ B4 b2 H            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
7 f$ c9 Z8 }/ K1 x    Writing inode tables: done                           
8 E' d2 L* n% p; G    Creating journal (8192 blocks): done
3 _" {1 w& Y  S    Writing superblocks and filesystem accounting information: done" [. T6 r9 \, V& W. D9 P
    This filesystem will be automatically checked every 30 mounts or
% V3 m! C% N6 z    180 days, whichever comes first.  Use tune2fs -c or -i to override.  `( C) J9 E1 ]1 ?
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
2 p, D+ F! R7 r. D    /dev/sda3              3723848    705992   2828692  20% /
9 O8 i* Z% a- C. R    /dev/sda1               101089      9274     86596  10% /boot
) v3 f2 T/ m5 F+ C8 z& T* E8 S5 C    none                     14520         0     14520   0% /dev/shm
1 J" n) o- p% b" S7 f# {" R9 ?    //挂上新分区
) r  C$ D4 A! v7 |) k
  1. mount /dev/hda1 /home
    " Y- j9 t3 d* a
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点7 ^$ J5 C+ C8 G& ^/ u
    /dev/sda3              3723848    705992   2828692  20% /& ^2 x/ O3 D8 C8 ?3 g) O9 ~
    /dev/sda1               101089      9274     86596  10% /boot
$ R! i" i: N( T- z% a    none                     14520         0     14520   0% /dev/shm' D# i9 d0 \1 ]6 s1 r
    /dev/hda1               488006      8239    454569   2% /home( g0 H2 _$ }  j* H. N4 d$ ?8 O

& L3 ^$ ^, M! v  i自动挂载:
) z' u2 l, b9 E5 s
  1.           vi /etc/fstab
    $ |. ]1 G" N2 V% _

  2. - z- p6 n# R9 I: e1 v
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    : ^1 J/ C. b! a. d* i6 @* V# a: g

  4. 5 k" U. p, a% w, a
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:1 T9 ^4 A7 G: ~! I
  1.           mount /dev/sdb5 /mnt/ljp1
    ! J- s/ N+ R1 L% u/ |& {

  2. 2 i6 F' ^( x# D5 Z6 A8 d
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
% o2 y* x; ~0 m

0 E- m/ [, V' F  _3 r. w# g) x' J/ j# \2 W2 H
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-6-21 19:26 , Processed in 0.025513 second(s), 6 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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