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

 找回密码
 立即注册
查看: 2573|回复: 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 D( m) v) _  `' g; t9 ~
      or: fdisk /dev/sdc  (for the third SCSI disk)- ]! O$ B) n, m8 j5 h6 p
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)1 ^" M" r% B& z& W; o" F8 _  z3 O# m
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)! S% x) U* b7 J- w
      ...
+ L8 [3 Y" G9 Q& ?4 k  |( O, y/ l
  1. df -k
    * }. c( @* U$ q5 F  e
  2. df -lh) X' y  _1 r( W/ |4 l5 x7 R3 K. f
  3. 查看有几块硬盘:fdisk -l1 k8 P  V. G0 r3 a/ c. Q
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
" q$ n$ m# v8 U) ~. G0 t, a    /dev/sda3              3723848    705968   2828716  20% // {' l! r! u* ?- P
    /dev/sda1               101089      9274     86596  10% /boot% E$ A* Y1 p1 D& X2 q0 h7 f( L' ^3 v
    none                     14520         0     14520   0% /dev/shm
" }& v/ s  J. L  \, Y2 \( a' k    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
3 ?7 ]6 E6 M' x' l
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
, `  m3 n8 |. {8 d3 A    Building a new DOS disklabel. Changes will remain in memory only,5 ]) W! g3 p3 c! J5 H$ X
    until you decide to write them. After that, of course, the previous8 g7 ?. g1 B, N. `: P
    content won't be recoverable.
) t% C7 a9 g" s+ B: a/ \5 c    The number of cylinders for this disk is set to 8322.2 F; e5 Y1 L8 m3 K! ]) U
    There is nothing wrong with that, but this is larger than 1024,
/ `2 F( r! N* X    and could in certain setups cause problems with:7 Y+ p8 P9 o8 A  g
    1) software that runs at boot time (e.g., old versions of LILO)5 b2 I1 ]- F. c# T7 |+ i. ]
    2) booting and partitioning software from other OSs
' D$ H* D/ O- z/ T       (e.g., DOS FDISK, OS/2 FDISK)
% k. j( L; p& |1 g  u* r    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)0 W% P8 P. o, r5 q
    Command (m for help): p
* }  u6 u: I. A- w1 z# o) G    Disk /dev/hda: 4294 MB, 4294967296 bytes
: }- Y& t7 g! a    16 heads, 63 sectors/track, 8322 cylinders
5 a: E* R3 n1 h    Units = cylinders of 1008 * 512 = 516096 bytes
. ~) r/ l. H& X2 ?       Device Boot    Start       End    Blocks   Id  System
5 m9 p% s1 w9 G  C    Command (m for help): m& a: B# I6 E; Y; Q* L+ Q
    Command action7 _7 l0 h; s# d9 I1 a
       a   toggle a bootable flag
% O' t$ _! t  W  l       b   edit bsd disklabel* b# Y- I  Z4 a9 Q2 q9 i/ G  l, `# v
       c   toggle the dos compatibility flag2 U1 |. O; U. e. q) P: {
       d   delete a partition
8 [7 B0 u7 T8 d- J; a. O; p       l   list known partition types: g+ x: L0 z8 Q4 b% Y7 e
       m   print this menu: \: i" ~' T. s' K# {/ M
       n   add a new partition# t7 j% I, `6 X( I
       o   create a new empty DOS partition table0 K, T7 y8 Q/ S2 u
       p   print the partition table
, }6 N! Q: L: P4 F  Q, m. ?2 r       q   quit without saving changes! G8 Y7 O2 c. y# s
       s   create a new empty Sun disklabel+ B, q: Z/ l, R: @: X
       t   change a partition's system id, @3 Q. n6 i7 I, `/ [
       u   change display/entry units. o' X3 u' Y/ F. j; G$ [
       v   verify the partition table
+ b2 E8 m: C+ v( z1 c& j. T       w   write table to disk and exit; r0 {8 e& Q) I% Z
       x   extra functionality (experts only)
% J( _) w8 S& r3 M    Command (m for help): n
4 e0 j- h$ N- o    Command action) f/ n$ ~- z) b
       e   extended# Q. \# o- W* j' Q; V, g% a
       p   primary partition (1-4)4 j; X; a! V2 J) y! Q5 d
    p& e4 v+ a7 A1 M
    Partition number (1-4): 1  A3 M  d# H# |2 X# |
    First cylinder (1-8322, default 1):
6 H' z2 e8 c7 k* b: _; I1 W    Using default value 1% _' u. R6 c& I; g8 [( m3 R
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G! P* ?- ?* m) W* q* _9 D
    Command (m for help): p
. s9 h4 S2 h' ~    Disk /dev/hda: 4294 MB, 4294967296 bytes
. f( i$ G& R3 U; D) o7 k5 }    16 heads, 63 sectors/track, 8322 cylinders! g. e/ d* H4 p* i/ t
    Units = cylinders of 1008 * 512 = 516096 bytes
; z! }. p9 i% j* l       Device Boot    Start       End    Blocks   Id  System5 {2 N/ q; X) c! I" V
    /dev/hda1             1      1000    503968+  83  Linux
$ [, M/ Q$ G" @    Command (m for help): w
# ^$ n4 h1 f$ y; O. _. o! r9 k    The partition table has been altered!
. q0 k8 `8 q4 d) |    Calling ioctl() to re-read partition table.0 m$ F4 {" v5 I, k- n6 r
    Syncing disks.
% u2 o' x( e6 ~9 H6 c: E    //格式化新分区9 K. i% \7 j. a* Q
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)( f% K* u' K! W$ \' K
    Filesystem label=
9 A, L$ [- q0 g! ?9 |! u    OS type: Linux9 m! @9 p9 {6 P& c  {3 [. P
    Block size=1024 (log=0)5 S& m; l. U( Q' z; b* z- r
    Fragment size=1024 (log=0)9 Z; A* O- y, R) o( d! B4 j
    126480 inodes, 503968 blocks. ~& w, B% r' K7 H3 I) y
    25198 blocks (5.00%) reserved for the super user( Y8 c" D# _" ^3 X  L- `
    First data block=1
; U2 q6 z3 F; g0 @) n7 M    62 block groups9 d2 I  j  P6 K9 D& K% Z
    8192 blocks per group, 8192 fragments per group
7 d6 Q9 r: [6 R" C: l    2040 inodes per group
6 l$ g! ?5 |. z- G8 o    Superblock backups stored on blocks:
; O1 g: o2 t4 W5 _; t            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409. F5 J4 U8 d$ Q' D/ T8 j
    Writing inode tables: done                           
1 c9 G7 h3 R' ^! r+ y    Creating journal (8192 blocks): done4 m2 `0 u2 f( J( D4 o
    Writing superblocks and filesystem accounting information: done  x' x+ O5 \/ f& r% }
    This filesystem will be automatically checked every 30 mounts or5 X- g6 l6 m  n) [, e
    180 days, whichever comes first.  Use tune2fs -c or -i to override.0 Q" q0 e+ z2 p: _4 s6 b1 q, \
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
* @$ G' d1 p3 G' e: G    /dev/sda3              3723848    705992   2828692  20% /
1 |; \+ S3 G, P7 o* {. B/ ^    /dev/sda1               101089      9274     86596  10% /boot
8 O9 I7 B/ E8 Q! T9 v    none                     14520         0     14520   0% /dev/shm; a# j8 d# c' T: A8 Y
    //挂上新分区
5 x8 {& o( L! T1 ^9 A* \
  1. mount /dev/hda1 /home
    + D  L# s1 C, a7 q6 ]& W. f
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
2 X& T4 ^$ ^* y! H- @    /dev/sda3              3723848    705992   2828692  20% /5 C# i9 o4 X0 e) o+ T: l
    /dev/sda1               101089      9274     86596  10% /boot
4 }5 @! V" w5 A" u% p; [    none                     14520         0     14520   0% /dev/shm# M/ P8 e1 T# D, L& G
    /dev/hda1               488006      8239    454569   2% /home7 C3 d& R- Y  r% X) ]

5 C( Z; v1 T: E, C自动挂载:
7 G& V4 V* I8 t
  1.           vi /etc/fstab
    ( P) f6 O5 C- G; _& o- m9 a
  2. ; C: ^; V% m9 b' M5 p
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    8 p* J8 H9 K+ L" @" F$ |

  4. 5 |: ?) n0 g- S7 C8 W  f9 }
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:' h; e2 k" D" k4 U9 e  p6 }
  1.           mount /dev/sdb5 /mnt/ljp1* t! R$ d. U' O0 ]3 v

  2. 7 f; J4 w* h0 ~; G3 [
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

1 m2 k6 }6 }, t1 A( }+ q
- d. j2 L& o3 [& M3 U
8 y* q# ?  [9 ~( Z; U( X4 K3 m
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-19 23:55 , Processed in 0.033188 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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