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

 找回密码
 立即注册
查看: 2730|回复: 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)& q5 m7 \( j5 ?; Q5 f
      or: fdisk /dev/sdc  (for the third SCSI disk), u. ]& F4 J' B, C8 B) E- X" B
      or: fdisk /dev/eda  (for the first PS/2 ESDI drive)0 G: V! N" x+ i8 Z
      or: fdisk /dev/rd/c0d0  or: fdisk /dev/ida/c0d0  (for RAID devices)! v5 s6 p9 a4 z2 O- `3 N- K
      ...
- T% ?2 a4 f, d8 Q
  1. df -k) ]  \' N0 i; }+ i" u  M
  2. df -lh) f' X3 d; c. k) q9 ~2 V5 C
  3. 查看有几块硬盘:fdisk -l
    & |5 K9 Y& H8 ^" f
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
6 r! `4 ^9 Z# B% `9 B    /dev/sda3              3723848    705968   2828716  20% /- ~7 F! |( Y% K
    /dev/sda1               101089      9274     86596  10% /boot
) b  C0 Y$ z  R    none                     14520         0     14520   0% /dev/shm% X- K$ `' e* n7 n- H
    对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用! I7 R$ h9 R; x4 n6 U# @
  1. fdisk /dev/hda
复制代码
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
) Z( P5 h( B6 B- S8 o' ^( |    Building a new DOS disklabel. Changes will remain in memory only,
& S. h# i! ?& @# Y) x    until you decide to write them. After that, of course, the previous, \$ p) O; G% J  E  Q2 w
    content won't be recoverable.
7 r3 X& E  ]$ N/ q8 V! e9 `    The number of cylinders for this disk is set to 8322.& w- a2 y; b  y; g2 p
    There is nothing wrong with that, but this is larger than 1024,
& }% N8 U1 r7 F/ ]    and could in certain setups cause problems with:& r1 q; V4 @. G
    1) software that runs at boot time (e.g., old versions of LILO)( h7 D- ]! \3 B5 {, Q8 E) y
    2) booting and partitioning software from other OSs: T$ v" x5 i2 a7 w' j- K+ }
       (e.g., DOS FDISK, OS/2 FDISK)! c! T. [" C8 n; A4 d2 I: i
    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
5 U( t7 J  U% V4 Z% ^" F    Command (m for help): p" b/ c. M6 h* M* b8 z
    Disk /dev/hda: 4294 MB, 4294967296 bytes
1 ]' B# F1 U1 q# r    16 heads, 63 sectors/track, 8322 cylinders
1 c6 R" f) @! q! R    Units = cylinders of 1008 * 512 = 516096 bytes
+ X( ~/ ~: i% b; z2 U$ X/ E       Device Boot    Start       End    Blocks   Id  System0 E  |  j5 d# t6 |
    Command (m for help): m
, i7 {1 ?+ Z" x    Command action1 e* A" G# @# b+ x9 N% @
       a   toggle a bootable flag9 G6 u- A9 J9 _0 s
       b   edit bsd disklabel- i' z" m2 X5 v$ {- c4 i
       c   toggle the dos compatibility flag
9 w& V2 Z5 a1 y' ^* {       d   delete a partition
( O! |; w2 h! J0 s$ Y4 v4 O0 G       l   list known partition types
  L6 \. z# j- ~# m2 c       m   print this menu
2 W, X2 |/ J6 F  G5 Z, T       n   add a new partition
. J% Z" u- I3 g, V       o   create a new empty DOS partition table
, F8 ?  ]  w7 V# g9 D3 g5 ?       p   print the partition table: A4 r6 I: n" S( C# _- S
       q   quit without saving changes
& _$ B9 _/ ~) y: f1 `       s   create a new empty Sun disklabel
) a* B/ B: m$ u1 ]9 R" I7 k       t   change a partition's system id
5 C$ |/ V  j! I& q2 b7 c       u   change display/entry units
4 y9 C+ A5 I( O! A8 v8 A       v   verify the partition table
( _( a3 P- k) h2 g       w   write table to disk and exit) v+ A2 i6 f% F9 S0 ?+ P+ u
       x   extra functionality (experts only). W: c5 v4 l% F$ {* N, {( P7 p* u
    Command (m for help): n; g3 ]+ K1 m5 K  s
    Command action% R* c1 y3 M1 r* p5 W) ?9 k2 Y! I
       e   extended
% Y0 G* ?  u* G( F9 O# Z% W5 q       p   primary partition (1-4)
: }9 [* m0 i1 y: Z    p( P% h4 W1 V5 h" K* }0 q4 M
    Partition number (1-4): 18 Y! X2 i1 n( i; g8 @! T
    First cylinder (1-8322, default 1):
& {% r! {# e9 z! Q* G8 D    Using default value 16 U% M) `2 N+ `3 f
    Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G" Z: e- r' u  f, ~8 l8 }/ [: i+ Z+ r
    Command (m for help): p
2 V+ I* z7 ~8 h$ u    Disk /dev/hda: 4294 MB, 4294967296 bytes
0 [0 h4 E: J. a" ]- m' I7 X. C    16 heads, 63 sectors/track, 8322 cylinders
  p/ _0 R4 B; x% U    Units = cylinders of 1008 * 512 = 516096 bytes
# s5 ?5 ^2 k% ]       Device Boot    Start       End    Blocks   Id  System: B$ ~/ q7 a  C2 P9 U
    /dev/hda1             1      1000    503968+  83  Linux
+ Z+ o3 s- @# S5 c    Command (m for help): w- h. W( Z' b0 v1 v1 x1 n: d; b4 k" j/ R4 O
    The partition table has been altered!
+ B3 E+ _3 ]% e+ t4 L1 u- j7 t    Calling ioctl() to re-read partition table.) P7 }3 Z  _" G- y9 F* ~7 a: t
    Syncing disks.
& O+ H" X1 }7 _9 k" d2 q! _2 `    //格式化新分区% f' y; K$ v) f8 |
  1. mkfs.ext3 /dev/hda1
复制代码
mke2fs 1.32 (09-Nov-2002)7 u! K' O9 C$ i( p/ T
    Filesystem label=0 f. s" K" l7 z
    OS type: Linux7 k4 R1 S; E: j) q% l  u3 R
    Block size=1024 (log=0)
+ Y: z* n8 D( R4 S0 }! m    Fragment size=1024 (log=0)
. V/ O8 x, [  L. L+ K0 d" \8 ]8 U# D    126480 inodes, 503968 blocks1 k+ K) p8 ?$ k5 o; f: q& z
    25198 blocks (5.00%) reserved for the super user2 K" {$ n6 o1 c
    First data block=1  C2 g' t. Q9 Q( Q- Q  z  `3 W
    62 block groups
9 e- Y% H  x$ i, ~4 y    8192 blocks per group, 8192 fragments per group
, x: R  P/ H& R% ?* ~    2040 inodes per group
) d, n6 Y1 E0 g( F    Superblock backups stored on blocks:
$ S8 x. n" O$ J            8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
/ c% j- Y0 e1 ~2 S    Writing inode tables: done                            3 p) Q, E: t0 \9 b! B( j" [
    Creating journal (8192 blocks): done4 d( ~: m  s/ f+ @& U4 ~
    Writing superblocks and filesystem accounting information: done* I9 Q) C& V( B6 @1 D! \
    This filesystem will be automatically checked every 30 mounts or
  H- N6 `6 n4 O7 w+ u4 y    180 days, whichever comes first.  Use tune2fs -c or -i to override.- l; C2 R, i8 T% W6 E
  1. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点. {/ V: |( Y$ w4 A& a
    /dev/sda3              3723848    705992   2828692  20% /* }5 c( X9 w/ \
    /dev/sda1               101089      9274     86596  10% /boot
4 r/ Q5 ]- q" T! q& X    none                     14520         0     14520   0% /dev/shm" p$ x- n" ], K, c' L
    //挂上新分区
/ L; z( ^9 l0 ]
  1. mount /dev/hda1 /home  t$ ?0 T4 L- V' {
  2. df -k
复制代码
文件系统               1K-块        已用     可用 已用% 挂载点
0 [1 n7 P! J/ \- j$ g    /dev/sda3              3723848    705992   2828692  20% /! |2 {3 ^4 A% q7 Q0 s
    /dev/sda1               101089      9274     86596  10% /boot
0 K" y: ?3 T3 ?, n" w' S& I* A1 P! ^    none                     14520         0     14520   0% /dev/shm" V4 Y7 r1 `: ]( Z: b) B( n$ x! @3 W
    /dev/hda1               488006      8239    454569   2% /home* l  K8 N' V$ q

. ]( s4 `+ z" b% V( d自动挂载:# h9 w3 |5 R" R# j% H8 q- s  [
  1.           vi /etc/fstab  D* R& B+ T" _1 J5 J7 y" ]5 @7 ]
  2. 7 Q3 t. U- ?; y) z& t2 g: k
  3.           /dev/sdb5 /mnt/ljp1  ext3     defaults     0 0
    3 @: T: _9 |) m6 N6 i
  4. / m# G) i* y; ]& b  ]
  5.           /dev/sdb6 /mnt/ljp2  ext3     defaults     0 0
复制代码
手动挂载:4 ?0 H% t$ Q; }1 `
  1.           mount /dev/sdb5 /mnt/ljp1$ i! u$ A: ]% l% ^
  2. + t7 d) E" X# c& X/ V7 r3 Q
  3.           mount /dev/sdb6 /mnt/ljp2
复制代码

! f3 x; z  a" p- x1 B1 M
2 b6 z- H9 u* l/ F3 n6 H- W2 C) m6 D( D; V
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-2 17:04 , Processed in 0.013367 second(s), 8 queries , APCu On.

Powered by Discuz!

© 2010-2023.

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