|
|
Usage: fdisk [-l] [-b SSZ] [-u] device E.g.: fdisk /dev/hda (for the first IDE disk)- W$ W- w* V. P* [- I
or: fdisk /dev/sdc (for the third SCSI disk)
5 C" y) t( q6 W) c- [; e' I or: fdisk /dev/eda (for the first PS/2 ESDI drive)% D' w8 t0 f" b' E- j
or: fdisk /dev/rd/c0d0 or: fdisk /dev/ida/c0d0 (for RAID devices)2 Z0 k3 n" b' [0 q
...% B( g3 a1 Z; \/ ]
- df -k
6 I a: L" _" [ - df -lh# H& b9 K2 ^. r7 i8 l7 |
- 查看有几块硬盘:fdisk -l
7 T; v; [ ]! L0 X8 v1 x" h
复制代码 文件系统 1K-块 已用 可用 已用% 挂载点
. V% Z& R. f( N) t/ ~& w /dev/sda3 3723848 705968 2828716 20% /! A3 ^% s. q/ f6 |+ z5 c
/dev/sda1 101089 9274 86596 10% /boot
9 `" O/ l. j( D none 14520 0 14520 0% /dev/shm
2 U+ Y* d, N; }' }. |' D 对新硬盘分区,4G硬盘中划出1G作为新分区。给/home使用
# y1 e2 a1 c" FDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
* T+ k1 j' q( r* X4 a; t& l Building a new DOS disklabel. Changes will remain in memory only,' `" }9 w9 C3 E, t4 [1 M8 v: e; y
until you decide to write them. After that, of course, the previous. Q2 i0 g; U6 V8 `) f5 c
content won't be recoverable.9 q; p: h# k! ?. r' A
The number of cylinders for this disk is set to 8322.
2 n3 t; H) E% i. ]" c There is nothing wrong with that, but this is larger than 1024,& C% J* ~5 b. v. k
and could in certain setups cause problems with:
2 f+ u/ m3 w2 P; w0 f1 p: ^3 ? 1) software that runs at boot time (e.g., old versions of LILO)
5 B# A' a' o! m5 g 2) booting and partitioning software from other OSs B& r3 F9 M* R1 r$ ` n: r
(e.g., DOS FDISK, OS/2 FDISK)% y+ ]" n- I4 R# ?
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
$ J( i- E* @7 S8 V+ D7 t Command (m for help): p! e# [7 |6 z, D h4 D+ h+ m7 \
Disk /dev/hda: 4294 MB, 4294967296 bytes. [: b, g" j1 J+ W% s
16 heads, 63 sectors/track, 8322 cylinders
1 Z/ W9 S" b+ y! x9 G2 N' S Units = cylinders of 1008 * 512 = 516096 bytes
- K% i- N% w% w7 S8 u) l# o. T3 w% w3 n Device Boot Start End Blocks Id System- O& @; g+ ~2 ^' c. ]% _; v% t
Command (m for help): m
2 c4 \' }! F+ D) {8 K9 h Command action9 B1 y# B. o" G
a toggle a bootable flag. r, n9 M( [3 o; V' Z6 `% x0 `. D
b edit bsd disklabel
% N4 g7 u$ U$ Z4 d% a0 L5 p, f$ j c toggle the dos compatibility flag
h# b$ i2 |4 Y/ A; f d delete a partition
9 e6 H& U, _& p' T l list known partition types
5 j9 O. Y8 c+ Y( o; L; A m print this menu- J+ g) T/ W) s5 n+ V m
n add a new partition
J' t; C% w+ E' Q* ]6 ` o create a new empty DOS partition table
$ J, A, [+ R4 X' h2 L3 g9 _ p print the partition table
6 m2 w1 W' h* C. ^. l: t0 n- X q quit without saving changes Q6 `& O* ?: Q/ F6 |! H$ N& q
s create a new empty Sun disklabel
, d' q5 P$ w6 [. d% `0 a t change a partition's system id
|* m2 W, E+ a u change display/entry units
. N- J8 p: P$ N% X( G) ^% ~: P% j v verify the partition table
. F A, x* |" \, M# P w write table to disk and exit
, ?6 d* h* K9 h4 F, M( u6 d x extra functionality (experts only)
8 }$ S# S4 k/ n8 E6 g; Y Command (m for help): n
5 o- ]7 s! @% a/ F8 J/ y Command action
! \4 y% L) U ?6 [( c e extended/ B6 n/ U' `: j& J
p primary partition (1-4)
( N, `+ ] q8 X6 g p
, U$ F$ q( U& d2 K Partition number (1-4): 10 ?2 o( _& {& \- q" y9 x% ~: W
First cylinder (1-8322, default 1):
' \) e9 ]' B1 v Using default value 1
9 I5 W9 v$ S, L; c Last cylinder or +size or +sizeM or +sizeK (1-8322, default 8322): 1000G. B' s* i, A% x. S9 H3 v- n E# B o" T
Command (m for help): p
, k5 I. b+ Q, {7 ^4 }: k Disk /dev/hda: 4294 MB, 4294967296 bytes. s4 x) u$ R' e8 k7 n
16 heads, 63 sectors/track, 8322 cylinders
, M2 u3 s& k4 a Units = cylinders of 1008 * 512 = 516096 bytes' \/ h- B7 @" R! W/ }
Device Boot Start End Blocks Id System
5 x/ d4 _6 o" o3 c3 Q0 e /dev/hda1 1 1000 503968+ 83 Linux' T2 `! O0 Q9 w- Q9 d
Command (m for help): w, i6 @' Z! v g) \/ [: k# ~$ ]
The partition table has been altered!
) K5 ^! k' P1 k4 N Calling ioctl() to re-read partition table.4 \1 u7 N/ z2 S4 Z
Syncing disks.
( E6 k. O# d/ |# d0 `* v //格式化新分区$ C$ a/ d- V; a( ]/ j0 f
mke2fs 1.32 (09-Nov-2002)
4 ]2 o+ n0 ]7 p+ T. b/ h- u, l Filesystem label=
( {- S4 J! _2 H% n( ]3 g' [( C OS type: Linux
2 k& x$ D( B- w+ X/ Q: J G Block size=1024 (log=0)6 W2 F+ k, m' A8 h1 ^* J, {+ v
Fragment size=1024 (log=0)
3 C* I- _1 @# W V 126480 inodes, 503968 blocks
0 \2 m0 D1 v' ]; s% r w% J6 x' T/ @0 s 25198 blocks (5.00%) reserved for the super user
$ r& b1 y: \) D' } First data block=1
0 W8 t9 i+ }0 D 62 block groups
! T2 q8 }, q# ?' D( S 8192 blocks per group, 8192 fragments per group8 C% V6 N: e& W7 T, G3 i
2040 inodes per group8 E q6 x' g( U" ^3 D
Superblock backups stored on blocks:
9 j# K9 a: E, ^' M 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
+ B3 p% Q. o7 j# J, L6 R4 @* ^0 O Writing inode tables: done ! b% g# C8 K1 h- f# G
Creating journal (8192 blocks): done/ Q8 r3 J3 i9 S& L4 u4 g* V( T" Y
Writing superblocks and filesystem accounting information: done9 T& Z7 t+ T- X6 v; U+ v: S
This filesystem will be automatically checked every 30 mounts or9 z+ \3 e2 d2 A3 o
180 days, whichever comes first. Use tune2fs -c or -i to override.
- J* x6 T+ G2 h* t+ t文件系统 1K-块 已用 可用 已用% 挂载点
2 }* B' ?+ A2 A. v) v @" y9 g /dev/sda3 3723848 705992 2828692 20% /
/ N( ~# M0 A3 b3 |: X /dev/sda1 101089 9274 86596 10% /boot
% W H0 ], c# Y2 P" | none 14520 0 14520 0% /dev/shm0 p: L9 [1 f3 s5 P. j
//挂上新分区
' N, u* ~4 h; \, V& e" b- mount /dev/hda1 /home" \* I2 J% _- k& ?: V" l
- df -k
复制代码 文件系统 1K-块 已用 可用 已用% 挂载点
! Z0 J# Q* f# y5 L6 a1 s! \3 I /dev/sda3 3723848 705992 2828692 20% /2 Z* C0 E& x5 N: y- q6 U
/dev/sda1 101089 9274 86596 10% /boot( I; L( o! N& X2 t4 X: \4 e3 Y
none 14520 0 14520 0% /dev/shm8 d( A/ ^& a& B" o( K
/dev/hda1 488006 8239 454569 2% /home: _" M. H" p/ l/ O& w/ X
5 n! [- v% I8 m! g: }! C* x自动挂载:
- |5 e" g6 D& H1 L2 F- vi /etc/fstab+ ?- L M. J6 d5 | z! o0 w: H
- 7 L; [- z2 _4 e* }
- /dev/sdb5 /mnt/ljp1 ext3 defaults 0 0 V4 m$ [* a" b8 G5 o, i
- $ L4 T }; q; j) F
- /dev/sdb6 /mnt/ljp2 ext3 defaults 0 0
复制代码 手动挂载:0 f& D" A: J o- A1 |9 u
- mount /dev/sdb5 /mnt/ljp1( l9 ?3 b- [9 M
" O3 q, ]( [0 E3 E- O+ ~1 n+ Y- mount /dev/sdb6 /mnt/ljp2
复制代码 ( E: |! D; q" _% I6 x% [ z
' e+ G! G2 ?8 ]6 U4 R
8 T; ~' f* y1 D6 s7 m
|
|