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

 找回密码
 立即注册
查看: 2789|回复: 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)
5 k4 X5 X/ F- j6 Q) X      or: fdisk /dev/sdc  (for the third SCSI disk)
0 ~3 g5 a' ?& u: I6 e% ?) x      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
. z& u" E" O& h3 z$ ?' a5 \: ?/ m4 U      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)7 s* t0 h- c  S4 J7 C- K/ C8 u
      ...6 c* f* q' ~8 Z% \
  1. df -k. V% b* }  r  h3 O3 A7 _; U7 G
  2. df -lh
      }0 ]  Y3 U% g; ^$ K9 U( O& V
  3. 查看有几块硬盘:fdisk -l! T5 t( D5 l9 }! O4 @. i
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点# x8 H$ W; [4 B3 q1 N, a- q
    /dev/sda3              3723848    705968   2828716  20% /. \% [' N. G9 v, k6 u7 z
    /dev/sda1               101089      9274     86596  10% /boot
# N3 \# \1 i$ t, [, P3 i0 `( O    none                     14520         0     14520   0% /dev/shm( \  a- I7 k$ S) U/ }
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用! E9 R& f4 @! y  m2 N' n) D# n
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel3 F- v* j( T" i1 j3 p* l( D5 h
    Building a new DOS disklabel. Changes will remain in memory only,
6 t8 ^. d- U8 O. Q. l    until you decide to write them. After that, of course, the previous1 q# @' z0 v4 A
    content won't be recoverable.. a, G4 e: ?& |7 z( p0 o
    The number of cylinders for this disk is set to 8322.. |4 r0 @- P" H2 L* {/ j7 l' b5 N
    There is nothing wrong with that, but this is larger than 1024,) s3 i; u# a+ i0 F
    and could in certain setups cause problems with:3 e  G; I, ?, i! @
    1) software that runs at boot time (e.g., old versions of LILO)
1 ~1 x2 N, O6 {  h* ?1 E9 A    2) booting and partitioning software from other OSs& Z! Q; T7 X- @9 ~7 B9 c6 T
       (e.g., DOS FDISK, OS/2 FDISK)- Y3 K1 F1 X/ ]5 J9 u' I
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
' a" z2 c% N* j8 S' S( n    Command (m for help): p6 a& O, E! g6 {9 ?2 z) @
    Disk /dev/hda: 4294 MB, 4294967296 bytes, I& j1 e. d% z7 _: Y( o& v
    16 heads, 63 sectors/track, 8322 cylinders9 ~4 B# t4 c- C
    Units = cylinders of 1008 * 512 = 516096 bytes. N( o0 [" ]. Z
       Device Boot    Start       End    Blocks   Id  System4 p; k' P# w5 `3 Y4 _( p
    Command (m for help): m$ b7 W* `) O1 @/ `  ]
    Command action- Y$ S& ?% h/ P# H8 j4 S; m0 t
       a   toggle a bootable flag
; ]8 M! l' t: }. q8 _       b   edit bsd disklabel  n+ V7 S' i2 Z6 X' ]0 n4 N
       c   toggle the dos compatibility flag
! H- B+ t# x  l# S" W8 v       d   delete a partition5 Y' G2 S( ?# j9 z0 j  i! E8 l
       l   list known partition types
* v8 P; \; z/ B# H       m   print this menu
1 c: k* h5 C6 C  t       n   add a new partition
$ V. I0 @' L- L8 Z$ \+ p) B, H: O: J       o   create a new empty DOS partition table: g) d0 t5 X4 O- j. {4 B
       p   print the partition table
) F; w8 |2 p1 Q3 p9 q# |, q       q   quit without saving changes
5 Q4 i2 C8 _3 m* q; U6 j       s   create a new empty Sun disklabel  Y9 X; G6 n/ G$ Z) a# I
       t   change a partition's system id
$ R9 T6 I, e) Y5 e& c- ^0 r       u   change display/entry units/ l% T+ a( t! I6 W# {$ ~6 [2 N( D
       v   verify the partition table
! q9 m, L8 i) F2 z, b5 r       w   write table to disk and exit# ?9 ]  p  r; D( f4 l! R9 v
       x   extra functionality (experts only)/ |; P7 W. ^6 ~$ Z* g3 V4 R3 N, f3 T
    Command (m for help): n# M% }. Y* s5 h4 b1 R) }( ]
    Command action
+ x9 z1 g$ W, ], u- z9 l6 M" {# {+ W       e   extended  u4 x% V9 @% |* V: s- H) ]* B
       p   primary partition (1-4)$ Y- `! l: X& K& C3 Z
    p2 J6 a7 ~' B: m# Z$ X- l9 y
    Partition number (1-4): 1
' H0 e0 d. y' k    First cylinder (1-8322, default 1): ) X, Q% D; Z3 q9 _3 g: f9 h3 @
    Using default value 10 i9 R% P  v4 ]; v- |- |6 A
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
$ O! D9 C4 `( m) x    Command (m for help): p& e  J4 `0 g  v$ M' V! ?) a8 R
    Disk /dev/hda: 4294 MB, 4294967296 bytes
! r2 m- s" D7 K  A( Y1 S8 \' ~' }2 j    16 heads, 63 sectors/track, 8322 cylinders8 P+ S0 I' E# j8 u5 K$ y5 \& j
    Units = cylinders of 1008 * 512 = 516096 bytes; l0 W9 _3 h0 x+ Z. I
       Device Boot    Start       End    Blocks   Id  System* h$ x0 S2 d! S; w
    /dev/hda1             1      1000    503968+  83  Linux7 v( E4 m6 W% S- x
    Command (m for help): w
7 e+ {2 U- M2 U1 h; L9 g9 X# Y    The partition table has been altered!
' ^9 F! S) n+ ~. x7 [    Calling ioctl() to re-read partition table.; ?- S) X$ ?6 r, p. K  e9 A3 D
    Syncing disks.
4 w, p" ^& n* B2 G' i6 S5 s    //格式化新分区8 @1 T" Z9 G% x, }* P
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
7 w: k  |7 g) R3 C' |( ~2 D# r    Filesystem label=* x+ l5 ?/ I) ?4 L0 C
    OS type: Linux7 p  @5 h. O7 K2 e  q" ~
    Block size=1024 (log=0)7 A% ^  G( t- i1 E7 \& m, ^
    Fragment size=1024 (log=0)
0 J7 D! l  x' }% I    126480 inodes, 503968 blocks1 h( `1 V( C' t$ n
    25198 blocks (5.00%) reserved for the super user
. E) M! `" f7 a2 p. K) p& @    First data block=14 @* `; u' b, O' t0 E0 E' s
    62 block groups. u( D# g, M! @; ]3 ?& C
    8192 blocks per group, 8192 fragments per group
! e" w& Y0 \/ H& r, P- t  G    2040 inodes per group/ ]. ?2 M+ [+ r. Y. E% o+ m! l2 r2 B8 K# {
    Superblock backups stored on blocks: 6 M/ h7 ^0 L; v# z. S
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, \0 m% f/ O2 `& m! T) _7 u" T3 g
    Writing inode tables: done                           
. g5 P# `9 O* Z5 v  e+ |2 Q    Creating journal (8192 blocks): done
6 O$ ^# R7 B! T' {8 N    Writing superblocks and filesystem accounting information: done
+ K6 p- s  X; ~' }# \& ^6 M* t. w3 }    This filesystem will be automatically checked every 30 mounts or8 |! e4 K2 @) z+ Q  g* e& g- P
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
. E1 j! ]4 i: ?  b3 j
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
8 n2 a7 F. A' O8 ~    /dev/sda3              3723848    705992   2828692  20% /
" e, c( N2 g7 @, L$ T" x    /dev/sda1               101089      9274     86596  10% /boot
% i) Y% |$ t! R9 b5 p5 K    none                     14520         0     14520   0% /dev/shm, O2 w: g; H3 M' M+ P
    //挂上新分区1 j. D- J2 X- k2 `
  1. mount /dev/hda1 /home
    ! a, ]! x' E- V: G  e
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点2 G3 J# C1 S; m+ u9 Y
    /dev/sda3              3723848    705992   2828692  20% /
2 H8 ]' \5 D: J" f! T) n" j; w    /dev/sda1               101089      9274     86596  10% /boot' E, X. h9 p  f+ _) J# Z" I
    none                     14520         0     14520   0% /dev/shm
5 U+ z4 ]! w: M    /dev/hda1               488006      8239    454569   2% /home2 X) Q2 C* N# R% c  H* @; e% [
1 `0 y3 t. u' N. x- k$ r8 U+ L7 o
自动挂载:
, [* {. n4 J3 G& b' v8 b) m8 h
  1.           vi /etc/fstab  M! ?0 ]3 ^( _1 _* k: E
  2. 7 D- m; [; I) i0 a; R" f) @6 t& D
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0" R4 ]% R; ?7 l& Y# m7 F
  4. / r' U5 ~, @) U0 J4 p4 D4 [
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
9 w! h- h+ d' _* F6 R: I
  1.           mount /dev/sdb5 /mnt/ljp1
    4 I  D4 e9 e( x# R

  2. 3 I; J7 N3 n0 u8 i# x3 y
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
: G6 ~" M" g" M  K3 {  v' J

, U# D4 j+ Q7 z7 z. |: ]: D4 ~
' y2 h. V5 u7 I; Q6 z2 E
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-15 09:05 , Processed in 0.014232 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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