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

 找回密码
 立即注册
查看: 2594|回复: 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 ?: T) n" y. {+ X1 F
      or: fdisk /dev/sdc  (for the third SCSI disk)2 K1 u9 L, A1 z! f1 M
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)
) A- G! j( C/ _- _# |1 p" ~      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)
: u8 Q2 r+ c* I& x7 ~* \( e      ...
4 k7 C1 T+ w4 N/ X! N6 o" F8 g
  1. df -k
    " }' L6 |6 P! r; D
  2. df -lh* J/ a  S) `! b1 Y, b+ X$ w
  3. 查看有几块硬盘:fdisk -l
    5 t9 L+ \" F1 m8 T" }! H5 S
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点0 n0 i* Z4 E) @
    /dev/sda3              3723848    705968   2828716  20% /- P6 f) s- H8 c; J- e4 R# w% z$ {
    /dev/sda1               101089      9274     86596  10% /boot! s' D! q9 |) y/ m  H& y1 }4 {
    none                     14520         0     14520   0% /dev/shm
3 M. ~0 X# f0 o    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
9 J- X& ]9 b0 X4 _8 w
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel5 X, y5 y+ h# {" S% A7 l" \
    Building a new DOS disklabel. Changes will remain in memory only,! L( b- e/ D' x% b
    until you decide to write them. After that, of course, the previous2 ^' F6 P# b; @) ?& e* t& H& O
    content won't be recoverable.* ]& b" {$ E3 d8 O1 x/ D0 C
    The number of cylinders for this disk is set to 8322.
9 {! o  i% V! y1 E/ W9 s1 R. B    There is nothing wrong with that, but this is larger than 1024,
, B: k' U, D" Q5 L, ]6 B3 ?; p    and could in certain setups cause problems with:$ @# C; C1 L- B& u
    1) software that runs at boot time (e.g., old versions of LILO)4 i& |  B# B6 a
    2) booting and partitioning software from other OSs$ ]' z' ~& F+ t! f3 ^) X
       (e.g., DOS FDISK, OS/2 FDISK)) }: J1 c! z$ m4 n$ ?
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)3 }/ ]+ {. a! ^& v
    Command (m for help): p8 o+ L1 o7 A  i6 J& f5 t: p5 Y
    Disk /dev/hda: 4294 MB, 4294967296 bytes
( j2 ~/ c" b2 q( w    16 heads, 63 sectors/track, 8322 cylinders
  t) t: i9 z: a7 [- B( x    Units = cylinders of 1008 * 512 = 516096 bytes
# X: t* r: J! }( {1 W       Device Boot    Start       End    Blocks   Id  System8 k* X8 N" Y' V5 t
    Command (m for help): m) a: |7 @+ V% u  o" E9 m/ \
    Command action1 C8 b& o& b; r6 p( k
       a   toggle a bootable flag6 y3 H+ y/ U- g# y; @
       b   edit bsd disklabel
( t1 H' z2 G, f       c   toggle the dos compatibility flag
) ~; S! u- G/ y       d   delete a partition
8 o% I, [" _% N: n1 x& V9 G       l   list known partition types
! W6 i, G. P  o2 h% F       m   print this menu& T2 t  f* J* K2 w
       n   add a new partition; y: @- X( c" _( W; r
       o   create a new empty DOS partition table% x6 D" W5 d# H0 t5 Z
       p   print the partition table$ {- \' E. \3 d1 W
       q   quit without saving changes2 L0 K- O6 e) s6 h1 m
       s   create a new empty Sun disklabel5 J5 b. x0 S9 f
       t   change a partition's system id
9 d4 f/ W! Z5 g+ A1 B       u   change display/entry units
2 B  ]' O3 C6 e7 I3 Y       v   verify the partition table
% E/ x8 y- z( b       w   write table to disk and exit- C3 K( K1 z: [7 C2 ?" |" C
       x   extra functionality (experts only)
4 d' A3 T$ _. {; ^% _' l/ u    Command (m for help): n* Y; }) J( _2 K2 k. M; z6 x
    Command action
5 P8 @! i& ^  o- X2 g' C       e   extended3 Y4 G2 I# j- j7 v8 \( |! x
       p   primary partition (1-4)
4 ?. e* m) a. Y    p5 g/ b9 w( }+ i2 A0 o5 w; M# Q
    Partition number (1-4): 17 S" \3 [) r$ h# l$ ^
    First cylinder (1-8322, default 1): ) I8 ?1 f' u3 h# n7 Y/ u* y
    Using default value 1
: ?) T* e2 Y9 s& W8 ^% U4 _    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G, ?% n1 d& t# {6 L3 G* F
    Command (m for help): p
" c5 g! P# v" f; G- v3 U    Disk /dev/hda: 4294 MB, 4294967296 bytes& q- u) U( b2 Y6 `" b9 F# y2 V
    16 heads, 63 sectors/track, 8322 cylinders
- C& d" ^- R: V: V$ @    Units = cylinders of 1008 * 512 = 516096 bytes
1 l$ Z3 v' J# G1 \' Z       Device Boot    Start       End    Blocks   Id  System0 ^2 D+ P9 V' O# h
    /dev/hda1             1      1000    503968+  83  Linux" Z7 t  u& _5 h& z) Z0 h
    Command (m for help): w
; n9 }- B+ _8 I5 U8 l" M, h! }    The partition table has been altered!
  \7 @7 t3 R) P) D7 N2 {$ K    Calling ioctl() to re-read partition table.
) |+ {3 J0 l  J8 X, b    Syncing disks.3 H2 O* s  l# V7 C1 y
    //格式化新分区
4 Y/ w, g: g, e9 p
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)! r/ o6 q( F7 q. Y: f' |* \
    Filesystem label=
) F; D5 r! ~. t    OS type: Linux0 A7 R- n) q: d6 |9 I9 M
    Block size=1024 (log=0)" a; a) S* J# a# F0 J
    Fragment size=1024 (log=0)  u% {6 I: n5 t" _
    126480 inodes, 503968 blocks
6 K2 V  I; C* r2 N3 E& @    25198 blocks (5.00%) reserved for the super user
0 q- B- w( h/ K, Z) I    First data block=1# k+ g: ~1 \$ J; Y7 R
    62 block groups
5 ~8 ~8 g" y" g6 b) E2 ~; H    8192 blocks per group, 8192 fragments per group( o5 }  \4 X) n4 h( b# {
    2040 inodes per group
+ Q2 t$ o, k' F    Superblock backups stored on blocks: % r$ Q! m" x  B1 a2 r
            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409$ l5 w9 X# e! C, K- [
    Writing inode tables: done                           
6 m2 ?) l% `1 G7 O2 j( J$ M: q    Creating journal (8192 blocks): done) e, l0 B3 s& C% M
    Writing superblocks and filesystem accounting information: done( ]2 Z/ T) S7 U+ b1 D0 ], x
    This filesystem will be automatically checked every 30 mounts or
6 r: L5 g4 r( q* a2 M* B    180 days, whichever comes first.  Use tune2fs -c or -i to override.
/ l( H4 ]% K9 E5 c
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
( f  Z6 ^' |, ^5 z    /dev/sda3              3723848    705992   2828692  20% /
5 {& f) d$ i" |8 Z% S" M& }* n    /dev/sda1               101089      9274     86596  10% /boot
& Y7 H" w/ P1 P8 W1 V" {! B    none                     14520         0     14520   0% /dev/shm
4 v8 S+ a% D) a/ l    //挂上新分区
* j$ r! k, s$ H2 b1 y5 ?
  1. mount /dev/hda1 /home1 G# [3 }! C/ U/ @
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
3 K8 P8 c# K3 j: D; O1 i; D    /dev/sda3              3723848    705992   2828692  20% /, ~" z$ V2 X, E5 r
    /dev/sda1               101089      9274     86596  10% /boot. z+ t- f$ J" F7 P0 G
    none                     14520         0     14520   0% /dev/shm2 T8 w3 B$ k7 ~8 d5 h: Q
    /dev/hda1               488006      8239    454569   2% /home, @3 f1 C: @3 A1 _
, K5 X' c0 d' C2 o7 K
自动挂载:
6 ~) D% |+ r' l& A' p5 u
  1.           vi /etc/fstab
    0 Z6 T9 I- t7 l8 A* A
  2. 8 X8 ^# v+ u: j5 R; z( o5 ]. M5 ~( ~
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 06 _7 m0 T; `% b7 `7 s  ]
  4. 3 Z9 f4 x' v" R
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:8 w& f$ l: ?; |( r
  1.           mount /dev/sdb5 /mnt/ljp1
    % M# d  c1 w0 j  U9 x8 n7 i

  2.   P! u6 F# b7 m. ?8 G4 F
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码
0 l0 [0 ^- y; H2 r6 J1 R0 N) d
8 |2 h1 f2 @+ T& F: F/ d
, W. f% K6 |1 ~  }6 C- n  c' i
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-25 06:31 , Processed in 0.025487 second(s), 7 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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