|
|
Usage: fdisk [-l] [-b SSZ] [-u] device E.g.: fdisk /dev/hda (for the first IDE disk)
% R& c# a) b; y$ Z0 _ or: fdisk /dev/sdc (for the third SCSI disk)
1 h9 v3 l+ g4 B# u5 C5 p or: fdisk /dev/eda (for the first PS/2 ESDI drive)' O# `$ i4 g! _7 D# h& z
or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)5 @. D5 s6 U/ [- c* p
...5 S5 }- @8 @" ~& o, D; \8 _
- df -k0 h6 N1 B- x5 h1 j8 J& ~
- df -lh+ p- O8 f. ~$ N3 v* k
- 查看有几块硬盘:fdisk -l
# f! p' N, U( u" ^
复制代码 文件系统 1K-块 已用 可用 已用% 挂载点4 b/ c. F, w: D2 ]% a
/dev/sda3 3723848 705968 2828716 20% /
# R# R! a4 Z, U& H5 v! g# O9 S /dev/sda1 101089 9274 86596 10% /boot n) E1 z& A$ r9 j$ V
none 14520 0 14520 0% /dev/shm, A- O: ~6 n' Z- ]; ?
对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
, i' X: Q2 o: ~! o. I# RDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel; H9 n5 y! r# i( j- l" ~
Building a new DOS disklabel. Changes will remain in memory only,) u$ y3 b; T: O1 G
until you decide to write them. After that, of course, the previous
# p" u& a, \: M& a% X, e6 q content won't be recoverable.
; _6 ^: L5 v" \, K8 C The number of cylinders for this disk is set to 8322.* L$ @7 ]" [7 o" T
There is nothing wrong with that, but this is larger than 1024,
O. z4 M6 o5 g2 J8 u, } and could in certain setups cause problems with:
1 L( a! v' R: x$ T* ?) p2 e1 s 1) software that runs at boot time (e.g., old versions of LILO)
& E9 e# |6 {/ y4 I 2) booting and partitioning software from other OSs
/ z9 {1 p) M4 Z6 | (e.g., DOS FDISK, OS/2 FDISK)
- _* e0 \- E, b6 ?7 ~/ j, D Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
/ p" }, ^8 E* }$ P- H# | Command (m for help): p
8 H9 B: g0 X0 ]0 |5 ]0 T6 x* t Disk /dev/hda: 4294 MB, 4294967296 bytes8 E8 O/ Z1 l* B; `% w: v9 U/ D4 ]
16 heads, 63 sectors/track, 8322 cylinders- J @0 ^; f t/ g
Units = cylinders of 1008 * 512 = 516096 bytes4 Y8 W- o ~( [5 P
Device Boot Start End Blocks Id System
9 g8 y" b o. H, I3 t! l( i# E Command (m for help): m# ~2 O" r6 X* B7 O
Command action
; o* R0 B I! \& W7 Y9 { a toggle a bootable flag M: \* ~4 _' }9 h$ w/ h
b edit bsd disklabel
4 V/ Y3 g8 q5 B$ T6 B, s5 Q c toggle the dos compatibility flag) v1 e* r+ v5 q' E1 B
d delete a partition5 j3 h) @7 F( d0 J; f4 a4 f- _9 o* ^
l list known partition types
- Z, W" L% A3 O% u# B5 [$ x m print this menu9 X6 k2 H/ i. t7 ~
n add a new partition+ ?7 M# q* @& A' B* l
o create a new empty DOS partition table1 I+ h& r+ |8 C
p print the partition table
4 z% Z" i7 s$ H* z9 m5 k. Q q quit without saving changes' q2 E9 g5 v' l$ K% `
s create a new empty Sun disklabel5 W8 i L# T: I4 J6 F
t change a partition's system id0 d# B: z- i* i
u change display/entry units6 R! x: q: r6 q* e& e
v verify the partition table
# d0 ?* D3 H |# A w write table to disk and exit
8 e4 c$ ~& l1 e! s x extra functionality (experts only)
: U) x7 ?" g7 |+ P- o3 g- f Command (m for help): n* h6 T1 e/ ^2 J# Y; c1 w( ]& _& t" |2 E( S
Command action
5 W$ S& B5 I6 D V$ C e extended
4 f* e; c( @2 V K7 x p primary partition (1-4)
+ [! t! F7 u5 D0 |1 Q p) v) O" |# }5 B6 n
Partition number (1-4): 1
& A4 H- T, W' ]% L First cylinder (1-8322, default 1):
# P4 ^1 S& h; Q# Y1 M, e Using default value 1: K# M- E- T, P6 D* q
Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G. v9 i1 P: [: D' L
Command (m for help): p; D! _( A, b) W' a4 Z4 M
Disk /dev/hda: 4294 MB, 4294967296 bytes
2 v' t& |* m" `9 X0 n* c) J6 i 16 heads, 63 sectors/track, 8322 cylinders5 Z" U$ h/ E. A4 x' N& Z! v
Units = cylinders of 1008 * 512 = 516096 bytes4 D5 r3 ?, T. w# _+ }) K
Device Boot Start End Blocks Id System1 ]: [% K( D# i+ J
/dev/hda1 1 1000 503968+ 83 Linux
. e3 D7 A' ^% d) ? Command (m for help): w
, r. a" r' z4 ? The partition table has been altered!3 Q9 g7 F$ @* x4 P1 h0 q7 ]
Calling ioctl() to re-read partition table.
/ W9 I q( V8 b$ f: n( o3 l Syncing disks.
( E4 }9 ]7 R6 {4 l. F* D //格式化新分区
! I8 g4 J* _' I/ _9 Kmke2fs 1.32 (09-Nov-2002)' T$ T0 j$ Q0 J1 R4 |/ o
Filesystem label=
% a7 Q& T- O' r1 g9 `' d( Z OS type: Linux
" T' Y% `8 y! K1 }( o Block size=1024 (log=0)" X; W# a' o* ~4 z& R+ j; v! b$ B3 Q
Fragment size=1024 (log=0)
, p1 J' I+ J0 z. n 126480 inodes, 503968 blocks
( V) ^; |1 {8 S4 g" x 25198 blocks (5.00%) reserved for the super user
( c% w1 f0 P* u1 _: ~ First data block=1
; L- `' A7 W4 [0 i 62 block groups4 ]8 P+ i7 Q* U' W: i! M" d$ U
8192 blocks per group, 8192 fragments per group
1 ]8 i2 p0 z" X, b6 @' L. m 2040 inodes per group9 h# {* B! B/ ~/ t+ }
Superblock backups stored on blocks: 2 G) G6 C! B V" S4 h) l
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
- D y P+ q2 J$ |9 H S Writing inode tables: done 9 K/ s& |9 U4 M& H1 N7 @; X$ ~ v
Creating journal (8192 blocks): done
/ y# o( }8 I$ L Writing superblocks and filesystem accounting information: done
. B' m- {: p9 [ This filesystem will be automatically checked every 30 mounts or1 ]: n7 T" P$ o* p. K: h( m; V! `
180 days, whichever comes first. Use tune2fs -c or -i to override.: f' J" u/ A& L6 _3 Z
文件系统 1K-块 已用 可用 已用% 挂载点
0 o4 o6 m( m7 L$ ?* c/ D$ l, Y /dev/sda3 3723848 705992 2828692 20% /, J2 I7 S2 ] E; J) T+ \
/dev/sda1 101089 9274 86596 10% /boot
& b! x1 c, X3 P. i$ v/ u none 14520 0 14520 0% /dev/shm+ O/ z8 x# R* q3 b
//挂上新分区
( s- C6 N4 @4 m$ i- mount /dev/hda1 /home/ p! x3 }. J# h& k
- df -k
复制代码 文件系统 1K-块 已用 可用 已用% 挂载点
* i+ r8 I- z: C' b2 s- q, ` /dev/sda3 3723848 705992 2828692 20% /, l; e' m, h. Z2 T9 r
/dev/sda1 101089 9274 86596 10% /boot
7 f/ e. ^' }6 r2 K, d( ] none 14520 0 14520 0% /dev/shm
: ?4 C* D, \2 E* W/ c! R# A /dev/hda1 488006 8239 454569 2% /home
2 w. b& m/ d5 S( q% L `5 \, l% a% }$ k
自动挂载:
- P: ]2 ?0 e o# f7 x/ B, N* \4 F- vi /etc/fstab
2 |' t6 J i' k7 t' K2 L/ @
4 z' T6 H3 j% p3 }- /dev/sdb5 /mnt/ljp1 ext3 defaults 0 0
& o4 J5 {* \( R/ f# [" X$ i - : T) ?& k/ w3 U! o: F" v$ m
- /dev/sdb6 /mnt/ljp2 ext3 defaults 0 0
复制代码 手动挂载:' R" |; M5 }# u) s; {
- mount /dev/sdb5 /mnt/ljp10 A/ i7 \3 H$ z: _; E
- 8 b, o' J: b; V2 m: g$ Q
- mount /dev/sdb6 /mnt/ljp2
复制代码
% m9 k' K) l0 @* y
. {/ o v; Q1 V' Y; l4 F
* L+ w1 [" H3 u8 ?. ]& B s6 C8 K |
|