fdisk交互式划分磁盘分区示例
注:来自Linux系统管理_磁盘分区和格式化的扩展
Linux系统管理_磁盘分区和格式化:
规划磁盘分区:fdisk的常用选项
m :查看帮助信息
p :列表查看分区信息
n :新建磁盘分区
d :删除分区
t :变更分区类型(在使用t的时候,如果不知道)
w :保存分区设置并退出
q :放弃分区设置并退出
示例:
[root@localhost ~]# fdisk -l //查看当前分区
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 2575 20482875 83 Linux
/dev/sda3 2576 3850 10241437+ 83 Linux
/dev/sda4 3851 7832 31985415 5 Extended
/dev/sda5 3851 4111 2096451 82 Linux swap / Solaris
/dev/sda6 4112 5085 7823623+ 83 Linux
[root@localhost ~]# fdisk /dev/sda //规划磁盘/dev/sda
The number of cylinders for this disk isset to 7832.
There is nothing wrong with that, but thisis larger than 1024,
and could in certain setups cause problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): m //查看帮助,可以看到,可以在此模式下执行的命令
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibilityflag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOSpartition table
p print the partition table
q quit without saving changes
s create a new empty Sundisklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (expertsonly)
Command (m for help): p //首先查看当前规划
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 2575 20482875 83 Linux
/dev/sda3 2576 3850 10241437+ 83 Linux
/dev/sda4 3851 7832 31985415 5 Extended
/dev/sda5 3851 4111 2096451 82 Linux swap / Solaris
/dev/sda6 4112 5085 7823623+ 83 Linux
Command (m for help): d //删除一个分区
Partition number (1-6): 6 //删除第六快分区
Command (m for help): p //查看当前磁盘分区,可以看到,刚才删除了/dev/sda6
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 2575 20482875 83 Linux
/dev/sda3 2576 3850 10241437+ 83 Linux
/dev/sda4 3851 7832 31985415 5 Extended
/dev/sda5 3851 4111 2096451 82 Linux swap / Solaris
Command (m for help): n //新划分一块分区
First cylinder (4112-7832, default 4112): //起始不变
Using default value 4112
Last cylinder or +size or +sizeM or +sizeK(4112-7832, default 7832): +10G //新加一块10G的分区
Command (m for help): p //再次查看,可以看到,有新添加了一个逻辑分区
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 2575 20482875 83 Linux
/dev/sda3 2576 3850 10241437+ 83 Linux
/dev/sda4 3851 7832 31985415 5 Extended
/dev/sda5 3851 4111 2096451 82 Linux swap / Solaris
/dev/sda6 4112 5328 9775521 83 Linux
Command (m for help): t //改变一个分区的类型
Partition number (1-6): 6 //指定修改分区类型的分区为第六个分区,/dev/sda6
Hex code (type L to list codes): L //可以输入L查看当前不同分区的编号
0 Empty 1e Hidden W95 FAT1 80 Old Minix bf Solaris
1 FAT12 24 NEC DOS 81 Minix / old Lin c1 DRDOS/sec(FAT-
2 XENIXroot 39 Plan 9 82 Linux swap / So c4 DRDOS/sec(FAT-
3 XENIXusr 3c PartitionMagic 83 Linux c6 DRDOS/sec (FAT-
4 FAT16<32M 40 Venix 80286 84 OS/2 hidden C: c7 Syrinx
5 Extended 41 PPC PReP Boot 85 Linux extended da Non-FS data
6 FAT16 42 SFS 86 NTFS volume set db CP/M / CTOS /.
7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set de Dell Utility
8 AIX 4e QNX4.x 2nd part 88 Linux plaintext df BootIt
9 AIXbootable 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access
a OS/2Boot Manag 50 OnTrack DM 93 Amoeba e3 DOS R/O
b W95FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor
c W95FAT32 (LBA) 52 CP/M 9f BSD/OS eb BeOS fs
e W95FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee EFI GPT
f W95Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/
10 OPUS 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f1 SpeedStor
12 Compaq diagnost 5c PriamEdisk a8 Darwin UFS f4 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f2 DOS secondary
16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot fb VMware VMFS
17 Hidden HPFS/NTF 64 NovellNetware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 70 DiskSecureMult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT
Hex code (type L to list codes): 7 //指定当前分区的类型为7,即NTFS分区
Changed system type of partition 6 to 7(HPFS/NTFS)
Command (m for help): q //若要保存则输如w保存退出
[root@localhost ~]#