之前我写过关于分区的博客,但是具体如何给硬盘分区,今天我就简单介绍一下Linux下强大的分区工具fdisk吧!
首先,要查看当前电脑的分区,可以用命令fdisk -l查看,而且命令fdisk只有root有权限使用,普通用户无法使用.
fdisk -l
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc27bc27b
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3917 31463271 7 HPFS/NTFS
/dev/sda2 3918 27268 187563099 f W95 Ext'd (LBA)
/dev/sda3 27268 30402 25171968 83 Linux
/dev/sda5 3918 14361 83891398+ 7 HPFS/NTFS
/dev/sda6 14362 23499 73400953+ 7 HPFS/NTFS
/dev/sda7 23500 27146 29294496 b W95 FAT32
/dev/sda8 27147 27268 975872 82 Linux swap / Solaris
我们可以看到硬盘分区的细节,共六列,依次表示设备文件名,起始扇区,结束扇区,容量大小,文件系统ID,文件系统类型. 这个只是查看分区,要是针对硬盘分区,需要在fdisk后边加上硬盘设备文件名,而不能加上分区名!
fdisk /dev/sda
可以看到如下提示:
Command (m for help):
我们不许要死记硬背fdisk的用法,此时按一下m即可很清晰的命令介绍:
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
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 (experts only)
英文都写的很清楚,使用习惯了我们就会记住常用的命令:
p:显示分区表
n:新增一个分区
d:删除一个分区
w:将之前的操作写入分区表,保存退出
q:退出,不保存之前的操作
如果我们只是做练习,就不许要w保存了,否则它将会变成一条及其危险的命令.