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 命令不是必需的,如果沒有提示重啟系統,則直接格式化即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM