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

 找回密码
 立即注册
查看: 2649|回复: 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)  E6 b3 v" c# M. n* z  G
      or: fdisk /dev/sdc  (for the third SCSI disk)
7 A' }0 G) x+ G& L! V, F      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)1 R% j2 E& @" }- Q7 t
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
" S6 P+ P6 O2 N7 y5 _      ...
  x2 J+ E, [% g9 |0 g  p5 t
  1. df -k
    : @5 Y. k( f6 u3 t3 |1 e/ y/ ~8 c
  2. df -lh8 F1 u. k6 k7 X
  3. 查看有几块硬盘:fdisk -l; y& K" O* K/ b9 r9 B. V
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点; J" r. [0 i( l
    /dev/sda3              3723848    705968   2828716  20% /3 {& O4 u- I- z$ o" r
    /dev/sda1               101089      9274     86596  10% /boot: L) I7 n2 j( z* A
    none                     14520         0     14520   0% /dev/shm$ N0 n8 ^1 O8 _& X
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用# N1 W% j4 a6 P  W. J* [
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel, n# D5 r) l, ]" Q+ F
    Building a new DOS disklabel. Changes will remain in memory only,6 t- Z! C' M0 R. a- I. r
    until you decide to write them. After that, of course, the previous
  i: R. C+ \+ A( b' [. `8 _    content won't be recoverable.4 H; ?3 f/ Z& f$ |; v
    The number of cylinders for this disk is set to 8322.' Q0 Q- U4 }. y
    There is nothing wrong with that, but this is larger than 1024,' \+ l6 O7 \# ~& S- o" }& _
    and could in certain setups cause problems with:, h  n  k1 R/ J3 Y- x* [3 u3 H
    1) software that runs at boot time (e.g., old versions of LILO)
7 U# A5 j! I7 C3 P, B  W  c! T% R    2) booting and partitioning software from other OSs$ b: d- [5 A2 G' ^
       (e.g., DOS FDISK, OS/2 FDISK)
! j7 ?$ l; E. h- k& k7 L    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)1 e( h7 Y: o/ {$ L7 x, `
    Command (m for help): p- f. O3 s% V' I+ [) T! j
    Disk /dev/hda: 4294 MB, 4294967296 bytes
. U( q" K$ K0 k9 @    16 heads, 63 sectors/track, 8322 cylinders' [3 O  x9 s6 ~  F1 u" G
    Units = cylinders of 1008 * 512 = 516096 bytes
! D/ g6 x( _2 r& K( e- q: d! d       Device Boot    Start       End    Blocks   Id  System
$ {. ?6 g: s3 R$ q: }- o" ~    Command (m for help): m+ P% T6 X) U2 g3 q
    Command action( T& h2 V3 M7 W& }3 e5 ?) T
       a   toggle a bootable flag+ Q. t" M+ D8 P9 i- \+ v& l# _
       b   edit bsd disklabel6 d3 c4 P' N# D% q
       c   toggle the dos compatibility flag8 m6 l+ N4 f; ~( z2 s
       d   delete a partition! T# p6 r  P( p, W9 D5 y! i5 x
       l   list known partition types
& t% x9 @* h$ X0 P( Z3 y4 Q5 @8 A       m   print this menu
% e( \3 w) W, d7 I+ [       n   add a new partition
8 O' i7 j8 @" C) U% r; M- G% h       o   create a new empty DOS partition table2 S" o$ b) j6 w( ?" y$ e
       p   print the partition table
. l/ x1 P- E* y, z% D       q   quit without saving changes
( P; d2 C9 d+ U4 y7 _       s   create a new empty Sun disklabel2 V* i2 E+ Y& G4 H" a, u+ \
       t   change a partition's system id
' s" ]7 L0 s, B# s# X       u   change display/entry units% L0 z+ @1 z3 E* ^) X
       v   verify the partition table
8 A) [3 c; M7 W9 m       w   write table to disk and exit; ]0 [9 v/ w7 \# K2 s$ f( {5 i( b& ?
       x   extra functionality (experts only)/ ]6 f" R' d) t
    Command (m for help): n
6 L/ Y3 M3 _' _( f    Command action! Y- M! l# w" M6 k0 e5 C1 g5 M
       e   extended
# R& H  \8 Y, z# i0 v, _" B       p   primary partition (1-4)
$ o( I4 Z2 V" c6 F" Z8 h    p( ]  l, h( k, V0 J; W
    Partition number (1-4): 17 N7 L. a; A8 W" ~
    First cylinder (1-8322, default 1):
$ a/ `! y/ |- r" m    Using default value 1: x( c+ z$ w% H  y# B' a7 Y* C- j
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
/ o! |" o; E9 X7 _$ U( Z$ h    Command (m for help): p
% H4 ~( m% l" K! v    Disk /dev/hda: 4294 MB, 4294967296 bytes7 l( l0 L, f+ K. f( q/ h/ |. ]& G! z: R
    16 heads, 63 sectors/track, 8322 cylinders
( {) J: v: b% }+ @; }7 b    Units = cylinders of 1008 * 512 = 516096 bytes" X5 s9 n# d# }3 V* o' t
       Device Boot    Start       End    Blocks   Id  System$ ]6 U$ x: @' s1 {$ A/ C! q7 P8 h8 a
    /dev/hda1             1      1000    503968+  83  Linux$ {5 I) w4 ~: \% n0 {+ f
    Command (m for help): w
" {) C* k, f6 B$ A; D- F    The partition table has been altered!
0 s6 S1 u) W3 N: t# p; M    Calling ioctl() to re-read partition table.
6 S0 B* F( y7 g; y. C3 ], [+ l    Syncing disks.
0 U: L' Z" P# P  }3 t+ S    //格式化新分区+ _  L, d+ M) T, H% P+ n. `3 O
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)
4 X/ V$ X" b. {9 y( A) a    Filesystem label=
5 Z# J9 ]) L  p! L    OS type: Linux3 t9 a8 Y; Z; h$ l* @
    Block size=1024 (log=0)
  x6 F' W' Z; j0 p* ]) W1 y    Fragment size=1024 (log=0)0 }# q) E! f6 f, @
    126480 inodes, 503968 blocks
. c9 u& q" A9 D; y3 Z4 ~    25198 blocks (5.00%) reserved for the super user
+ |* z" m, Q4 M0 y! x, ^    First data block=16 Q! }3 h  y, k
    62 block groups
/ X3 D5 j2 ]/ C) O2 j$ C5 h    8192 blocks per group, 8192 fragments per group
; \6 ?/ U7 [" u    2040 inodes per group
  g2 A7 `, r( Z3 {# W' k    Superblock backups stored on blocks:
+ a" h: y1 @* S  y            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409% Z" u" C/ Q0 f9 H3 u
    Writing inode tables: done                           
2 F: V4 m2 I9 r! I* ]8 @% E6 g    Creating journal (8192 blocks): done  F( |' H: b! o7 n
    Writing superblocks and filesystem accounting information: done, Y3 U9 R  L5 Z6 }( c* w5 D
    This filesystem will be automatically checked every 30 mounts or6 S0 a: h; z# A) D
    180 days, whichever comes first.  Use tune2fs -c or -i to override.9 c+ M* ?$ L/ @6 k+ r/ a! ^5 S" d
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
! z! t$ O; i8 s/ k$ M8 S    /dev/sda3              3723848    705992   2828692  20% /
6 S+ }' [2 N4 G1 f    /dev/sda1               101089      9274     86596  10% /boot3 B, m& @. U- _8 ^* _# F: F4 I
    none                     14520         0     14520   0% /dev/shm
* l) G; Q7 _3 P    //挂上新分区
5 d& E' J* V/ w' e
  1. mount /dev/hda1 /home2 ~* l2 k8 A2 g% o* U6 G
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点1 O$ X  T( R0 {9 T* v. G
    /dev/sda3              3723848    705992   2828692  20% /
) X- k7 q$ @6 s' {0 e1 j; s    /dev/sda1               101089      9274     86596  10% /boot  j; I6 v$ p$ [, O* D% e9 U
    none                     14520         0     14520   0% /dev/shm: D9 q: O" e5 n/ z
    /dev/hda1               488006      8239    454569   2% /home
6 P7 G- ~. l8 D8 L( j- `; {: `# b8 J3 C9 x
自动挂载:" b2 U& Z5 U. ]3 l& G& o5 {2 }7 u
  1.           vi /etc/fstab# H0 y: j7 `; N+ R( t/ R

  2. 8 g( P4 t# e5 c3 S3 {
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    , N- b8 \3 V, N* i7 ]& K
  4. ! K$ S- |1 l$ E- a& g7 Y3 b9 r
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:
7 |; O! Z9 j9 k7 _( x
  1.           mount /dev/sdb5 /mnt/ljp1
    ! \3 a9 D& H" p  I" ?! h
  2. & q0 F; ?$ B7 N0 w; v
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

! I; a: U' I& W# U: h2 [; ?; p! D- e" L6 R  Z
5 ?! k) ?3 ~8 o& d3 y
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

Powered by Discuz!

© 2010-2023.

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