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 -]#
#退回到提示符界面

所有的分区立过程中如果不保存并退出是不会生效的,所以建立错了也没有关系,使用 q 命令不保存退出即可。如果使用了 w 命令,就会保存退出。有时因为系统的分区表正忙,所以需要重新启动系统才能使新的分区表生效。命令如下:

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 命令不是必需的,如果没有提示重启系统,则直接格式化即可。

本文标题:Linux fdisk命令创建逻辑分区过程详解

本文地址:http://www.hosteonscn.com/3270.html

评论

0条评论

发表评论

邮箱地址不会被公开。 必填项已用*标注