[root@linux-xl ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x189fc246.
Command (m for help): n #创建一个新的分区(这里通常使用的是 n:创建一个新的分区;p:罗列出分区;w:保存并退出;d:删除一个分区;q:不保存直接退出)
Partition type:
p primary (0 primary, 0 extended, 4 free) #主分区:如果想都用分区,最多只能划分四个
e extended #扩展分区:包含逻辑分区
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048): #这里起始扇区都使用默认,直接回车即可。
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):+2G #划分2个G的空间。
Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): p #列出分区
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x189fc246
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux # 此时可以看到刚划分的分区
Command (m for help): n #主分区分完过后,再新建分区就不会提示了
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): #默认回车
Using default response p
Partition number (2-4, default 2): #默认回车
First sector (4196352-20971519, default 4196352): #默认回车
Using default value 4196352
Last sector, +sectors or +size{K,M,G} (4196352-20971519, default 20971519): +2G #新建2G的主分区
Partition 2 of type Linux and of size 2 GiB is set
Command (m for help): p #列出分区
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x189fc246
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 8390655 2097152 83 Linux
Command (m for help): n #新建一个分区
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): #回车默认主分区
Using default response p
Partition number (3,4, default 3): #默认回车从3开始
First sector (8390656-20971519, default 8390656): #默认回车
Using default value 8390656
Last sector, +sectors or +size{K,M,G} (8390656-20971519, default 20971519): +1G #划分1个G的主分区
Partition 3 of type Linux and of size 1 GiB is set
Command (m for help): p #列出分区
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x189fc246
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 8390655 2097152 83 Linux
/dev/sdb3 8390656 10487807 1048576 83 Linux
Command (m for help): n #新建分区
Partition type:
p primary (3 primary, 0 extended, 1 free)
e extended
Select (default e): e #划分扩展分区
Selected partition 4
First sector (10487808-20971519, default 10487808): #默认回车
Using default value 10487808
Last sector, +sectors or +size{K,M,G} (10487808-20971519, default 20971519): #默认回车划分剩余空间给扩展分区
Using default value 20971519
Partition 4 of type Extended and of size 5 GiB is set
Command (m for help): p #列出分区
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x189fc246
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 8390655 2097152 83 Linux
/dev/sdb3 8390656 10487807 1048576 83 Linux
/dev/sdb4 10487808 20971519 5241856 5 Extended
Command (m for help): n #可以看到提示变了,只能是划分逻辑分区了。
All primary partitions are in use
Adding logical partition 5
First sector (10489856-20971519, default 10489856):
Using default value 10489856
Last sector, +sectors or +size{K,M,G} (10489856-20971519, default 20971519): +1G #划分1G大小的逻辑分区
Partition 5 of type Linux and of size 1 GiB is set
Command (m for help): p #列出分区
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x189fc246
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 8390655 2097152 83 Linux
/dev/sdb3 8390656 10487807 1048576 83 Linux
/dev/sdb4 10487808 20971519 5241856 5 Extended
/dev/sdb5 10489856 12587007 1048576 83 Linux
Command (m for help): n #再划分一个逻辑分区
All primary partitions are in use
Adding logical partition 6
First sector (12589056-20971519, default 12589056):
Using default value 12589056
Last sector, +sectors or +size{K,M,G} (12589056-20971519, default 20971519): +1G #划分1G大小的逻辑分区
Partition 6 of type Linux and of size 1 GiB is set
Command (m for help): p #列出分区
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x189fc246
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 8390655 2097152 83 Linux
/dev/sdb3 8390656 10487807 1048576 83 Linux
/dev/sdb4 10487808 20971519 5241856 5 Extended
/dev/sdb5 10489856 12587007 1048576 83 Linux
/dev/sdb6 12589056 14686207 1048576 83 Linux
Command (m for help): d #删掉一个分区6
Partition number (1-6, default 6): 6 #回车默认是6
Partition 6 is deleted
Command (m for help): p #列出分区
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x189fc246
Device Boot Start End Blocks Id System
/dev/sdb1 2048 4196351 2097152 83 Linux
/dev/sdb2 4196352 8390655 2097152 83 Linux
/dev/sdb3 8390656 10487807 1048576 83 Linux
/dev/sdb4 10487808 20971519 5241856 5 Extended
/dev/sdb5 10489856 12587007 1048576 83 Linux
Command (m for help): w #保存并退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.