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
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更新分区表
使用命令cat /proc/partitions查看是否新增扩展分区/dev/sda3
使用fdisk /dev/sda进行分区,新增30G空间进来/dev/sda5