RedHat系統下fdisk命令不能使用全部分區怎么處理?

RedHat是非常流行的一款Linux系統 , RedHat包括其他Linux系統都可以用fdisk命令對磁盤進行重新分區 。某些情況下fdisk命令無法使用全部的分區 , 這是怎么回事呢?

RedHat系統下fdisk命令不能使用全部分區怎么處理?


Linux在RedHat7上原有四個主分區 , 分別為sda1 , sda2 , sda3 , sda4 , 其中sda1為主分區 , 200M , 后面三個主分區共40G , 后三個主分區為lvm , 目前磁盤空間緊張 , 由于linux只能劃分四個主分區 , 目前四個主分區已經全部占用了 , 如果直接刪除會導致數據丟失 , 還好前期分區時做的lvm , 為了拓展/dev/rhel/root根分區的空間 , /dev/sda3空間最小 , 使用pvmove命令 , 將/dev/sda3里的數據全部移到/dev/sda2 , 然后將/dev/sda3 移除:
pvmove /dev/sda3 /dev/sda2
pvremove /dev/sda3
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 63916031 31752192 8e Linux LVM
/dev/sda4 64530432 68724735 2097152 8e Linux LVM
移動完成后 , 系統空出300M空間 , 在vmware中擴展硬盤空間到100G , 使用partprobe /dev/sda , 使用fdisk -l查看硬盤空間 , 已經顯示為107.4G 。
Disk /dev/sda: 107.4 GB ,  107374182400 bytes ,  209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
【RedHat系統下fdisk命令不能使用全部分區怎么處理?】 I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c5098
接著使用fdisk /dev/sda添加擴展分區 , 使用n , 選擇擴展分區 , 初始塊直接回車 , 結束塊時 , 不能輸入209715200這個結束扇區 , 只能輸入以前系統默認提供的300M空間 , 重啟后問題依舊 , 無法識別后加的60G空間 , 懷疑問題是因為這個分區是在中間 , 無法與后續行成連續分區
使用parted工具進行分區
[root@server ~]# parted
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) help
align-check TYPE N check partition N for TYPE(min|opt) alignment
help [COMMAND] print general help ,  or help on COMMAND
mklabel , mktable LABEL-TYPE create a new disklabel (partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list , all|NUMBER] display the partition table ,  available devices ,  free space ,  all found partitions ,  or a
particular partition
quit exit program
rescue START END rescue a lost partition near START and END
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected device
disk_toggle [FLAG] toggle the state of FLAG on selected device
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number and copyright information of GNU Parted
(parted)
使用命令print list , 看到結束分區為35.6G , 使用命令mkpart extended  , 輸入起始分區36G , 輸入結束分區107G , 使用partprobe /dev/sda更新分區表

推薦閱讀