Linux fdisk命令创建逻辑分区


[root@localhost ~]# fdisk /dev/sdb
…省略部分输出…
Command (m for help): n
#建立新分区
Command action
l logical (5 or over)
#由于在前面章节中,扩展分区已经建立,所以这里变成了l(logic)
p primary partition (1-4)
l
#建立逻辑分区
First cylinder (655-2610, default 655):
#不用指定分区号,默认会从5开始分配,所以直接选择起始柱面
#注意:逻辑分区是在扩展分区内部再划分的,所以柱面是和扩展分区重叠的
Using default value 655
Last cylinder, +cylinders or +size{K, M, G} (655-2610, default 2610):+2G
#分配2GB大小
Command (m for help): n
#再建立一个逻辑分区
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (917-2610, default 917):
Using default value 917
Last cylinder, +cylinders or +size{K, M, G} (917-2610, default 2610):+2G
Command (m for help): p
#查看一下已经建立的分区
Disk /dev/sdb: 21.5GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xb4b0720c
Device Boot Start End Blocks id System
/dev/sdb1 1 654
5253223+ 83 Linux
#主分区
/dev/sdb2 655 2610 15711570
5 Extended
#扩展分区
/dev/sdb5 655 916
2104483+ 83 Linux
#逻辑分区 1
/dev/sdb6 917 1178
2104483+ 83 Linux
#逻辑分区2
Command (m for help): w
#保存并退出
The partition table has been altered!
Calling ioctl。to re-read partition table.
Syncing disks.
[root@localhost -]#
#退回到提示符界面

有时因为系统的分区表正忙,所以需要重新启动系统才能使新的分区表生效。命令如下:

Command (m for help): w
#保存并退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16:
Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
#要求重新启动,才能格式化
Syncing disks.

如果不想重新启动,则可以使用 partprobe 命令

[root@localhost ~]# partprobe

如果这个命令不存在,则请安装 parted-2.1-18.el6.i686 这个软件包。partprobe 命令不是必需的,如果没有提示重启系统,则直接格式化即可。

原文地址:https://www.cnblogs.com/bky-lwyh930214/p/10222318.html