|
Usage: fdisk [-l] [-b SSZ] [-u] device E.g.: fdisk /dev/hda (for the first IDE disk)
# |# _( O" I5 S or: fdisk /dev/sdc (for the third SCSI disk)* m: Q5 C& |4 N1 e/ j$ A
or: fdisk /dev/eda (for the first PS/2 ESDI drive), Q+ t+ \: H2 U4 L% M1 d
or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)
) d0 \ ^! p. s# m* \7 z4 |& M ...
7 w4 O( n6 N6 n8 w; @: L0 b& @- df -k
$ Y, ]& m3 A# C" V4 f/ U' t! V - df -lh
& w2 B! J2 m# ~$ V% v Z& s0 W/ S - 查看有几块硬盘:fdisk -l- Y: v. s* |! @1 [
复制代码 文件系统 1K-块 已用 可用 已用% 挂载点
, Z3 e9 W: P) p /dev/sda3 3723848 705968 2828716 20% /, j% d- _" G0 C8 H g% I! t8 s9 ^
/dev/sda1 101089 9274 86596 10% /boot+ R5 x9 k& D$ Z& {
none 14520 0 14520 0% /dev/shm4 @$ A, Q0 ?! o
对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用1 {! U5 \, f) w9 M# f
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
, C9 _) p2 Y& Y+ v+ t4 e9 h" w Building a new DOS disklabel. Changes will remain in memory only,
* C* Y+ [' {: U; t& C7 y until you decide to write them. After that, of course, the previous
) Y2 L1 e1 Y; c. U( u content won't be recoverable.. D+ _4 U+ R+ m) C
The number of cylinders for this disk is set to 8322. l. x: e8 B# C5 z
There is nothing wrong with that, but this is larger than 1024,2 G. w: f) A9 g) N7 D2 n. {) _/ w
and could in certain setups cause problems with:( n: I3 _% A* z9 k# F( `
1) software that runs at boot time (e.g., old versions of LILO)& F% c# U' e* `1 _
2) booting and partitioning software from other OSs
% R' z; A$ f+ \+ F: t (e.g., DOS FDISK, OS/2 FDISK)( _, F% x, S2 B4 _: D) u2 H2 p0 v
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)* G4 B2 K" h0 ?- o8 J, u, x3 K* Y
Command (m for help): p
! J. h% W- w( |& X Disk /dev/hda: 4294 MB, 4294967296 bytes
: `8 Y$ T Q) S4 S3 y( Z+ U 16 heads, 63 sectors/track, 8322 cylinders
: V8 v2 G- P( ? Units = cylinders of 1008 * 512 = 516096 bytes
/ k5 z( _& _/ ^0 ?( D. H Device Boot Start End Blocks Id System) ?2 }9 ~1 T8 Q: H% S( f6 g
Command (m for help): m& R7 m' j4 V) C6 X
Command action7 ]; }$ k; A6 M9 I, d, t: c0 s
a toggle a bootable flag m/ o" n' D$ a4 p$ E
b edit bsd disklabel
6 Q# D$ G3 I3 e: I- d c toggle the dos compatibility flag! C7 b! R! t/ ?1 ?
d delete a partition
8 ^, l- A6 @% ? l list known partition types
& W, r. s" g& r4 K3 e; Z m print this menu
. a* ?: B1 n7 y9 o" r- P n add a new partition5 m, d" i( `2 L0 O( ~( J5 L
o create a new empty DOS partition table
7 m3 k4 x2 C1 S q3 @ p print the partition table) |8 `* q- h1 }; x4 }! T4 g3 \+ S0 G
q quit without saving changes+ Z" ]$ v5 @) ]
s create a new empty Sun disklabel
$ r+ X+ r5 c$ \+ Q$ P t change a partition's system id. V6 ^4 s/ Q* Z3 D2 Q# L
u change display/entry units2 U3 Y: g+ E: l/ P" h! y
v verify the partition table. i" x0 K. [5 j* c0 a( O' [
w write table to disk and exit8 J3 |- z( I9 ?) {( r
x extra functionality (experts only)
& }1 A8 _0 C* h5 A Command (m for help): n
0 q# p0 p5 t2 j/ J6 a# B' z# \ Command action
0 B+ `& ?0 b" y e extended
% a1 w, _: o1 ?$ R+ N W( o4 s p primary partition (1-4)
/ Q) y) ]) e( x9 b p0 ^+ N* z, e8 o, A8 ?8 J
Partition number (1-4): 1
) a4 b* m$ h" `. u First cylinder (1-8322, default 1):
% S% g. l' F# I Using default value 10 a4 M# Y8 u" x# i, s
Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G
+ L3 M" X3 n- B. W Command (m for help): p; M8 c$ f, z; ~ n( Z( @3 m5 I7 a. m
Disk /dev/hda: 4294 MB, 4294967296 bytes$ R7 z; Z; C* w6 l1 I0 u
16 heads, 63 sectors/track, 8322 cylinders
: `: ~& h2 F; [5 D$ F( g% Q. Y1 S Units = cylinders of 1008 * 512 = 516096 bytes
/ c* F/ D% u, D+ w7 p Device Boot Start End Blocks Id System
5 X! R3 P0 U3 U+ ]/ B. J: U /dev/hda1 1 1000 503968+ 83 Linux" w5 g* n6 b, {0 m2 b' V$ Y$ A
Command (m for help): w- m. G5 T+ T9 J' X8 y; s
The partition table has been altered!$ u0 a) B, p: W- B o2 {
Calling ioctl() to re-read partition table.. j& K, |" b# [0 q9 \
Syncing disks.3 g: `" z' R! g6 T( a
//格式化新分区
5 F0 Z# Y4 r& `* M# ^' i2 f. }mke2fs 1.32 (09-Nov-2002)
2 B: N: i) E/ \ Filesystem label=
* J* F, H# ~9 H/ {9 Z" w) P' v9 U/ p1 t OS type: Linux$ u5 X! M& y. |/ j$ ?) M
Block size=1024 (log=0)
# _ t; d% K' ~" i" ? ~ c/ K Fragment size=1024 (log=0)0 ?' m' z7 K0 e; |4 w, |0 f, I. u$ }
126480 inodes, 503968 blocks( J( | o6 a, m" Y3 g
25198 blocks (5.00%) reserved for the super user6 f- X5 s" J, r/ w, Y
First data block=15 Q+ { c$ E/ }" I3 K; z% F9 ~
62 block groups& @( c2 A8 e1 \0 |
8192 blocks per group, 8192 fragments per group
, {7 \% E( l0 L& b 2040 inodes per group
( o$ Q0 L; o' k' [ i9 b% H Superblock backups stored on blocks: ) ^' N& W' v* m1 C
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
0 v* S- v: T. q' i) R6 x1 Q! V* D( s Writing inode tables: done ( R- u, Z$ Z* Q8 n$ [& u8 Q9 U$ M& _
Creating journal (8192 blocks): done( y; A- _/ ~5 D% k: X
Writing superblocks and filesystem accounting information: done: j" W) k0 ^4 c9 E9 i% d& I
This filesystem will be automatically checked every 30 mounts or
8 _( }' A) j3 {$ Y8 O' R 180 days, whichever comes first. Use tune2fs -c or -i to override.
7 `9 s- D3 _" F' |( Y1 g3 `% g/ V文件系统 1K-块 已用 可用 已用% 挂载点
6 Q- e$ T& U, E& W0 {7 _. ] /dev/sda3 3723848 705992 2828692 20% /
7 r$ K* n% \/ C1 I$ T9 j9 h6 n /dev/sda1 101089 9274 86596 10% /boot- u8 h9 y8 f5 A1 C. y
none 14520 0 14520 0% /dev/shm0 C: e9 ~" Q2 z. g
//挂上新分区; W) t$ C8 e2 ], H( \
- mount /dev/hda1 /home" o3 G, l" A3 y$ P P- ` I, j
- df -k
复制代码 文件系统 1K-块 已用 可用 已用% 挂载点
( i, O- N$ A6 }8 N /dev/sda3 3723848 705992 2828692 20% /
T. ^5 z' K* k% Q6 X$ E, V9 T# B& J( t /dev/sda1 101089 9274 86596 10% /boot
; k! l; v2 ]* K% N7 [) Y none 14520 0 14520 0% /dev/shm
( P" h3 Z- e4 {/ f /dev/hda1 488006 8239 454569 2% /home8 Q1 J. v' B! c H
: p0 R) j4 g4 L& s自动挂载:! [6 I! Q0 b' i8 ?
- vi /etc/fstab
6 y7 a1 F5 Q5 x0 j0 m) f7 M - / i3 D: @; Y5 I
- /dev/sdb5 /mnt/ljp1 ext3 defaults 0 0) `: p/ D3 u# L r* i$ j
1 b9 a& U z% l1 _- /dev/sdb6 /mnt/ljp2 ext3 defaults 0 0
复制代码 手动挂载:% [) J+ z U; o) _' S! _
- mount /dev/sdb5 /mnt/ljp1
2 P4 Y/ f& X1 J2 c - ) i) ]0 J) n' w# ]$ N
- mount /dev/sdb6 /mnt/ljp2
复制代码
" _$ @. h' h3 I& r& a, s1 }) ?/ m1 _1 a8 M: _2 @. H+ a" p, [9 F
2 Q# H" ~9 A- ]& V5 Y @* I) I |
|