Expand Linux VM Logical Volume Partition or Mount Logical Volume
- ROOT
- HOME
- SWAP
- Power off the virtual machine.
- Edit the virtual machine settings and extend the virtual disk size.
- Power on the virtual machine.
- Identify the device name, which is by default /dev/sda, and confirm the new size by running the command
- Now execute this below command to initialize the expanded space and mount it.
- Press p to print the partition table to identify the number of partitions.
- Press n to create a new primary partition.
- Press p for primary.
- Press 3 for the partition number, depending on the output of the partition table print.
- Press Enter two times.
- Press 3 to select the newly creation partition.
- Type 8e to change the Hex Code of the partition for Linux LVM.
- Press w to write the changes to the partition table.
- Reboot the virtual machine.
- Now we need to create physical & logical volumes execute below command to create physical volume.
pvcreate /dev/sda3
- Execute below command to get the name of current Volume Group
vgdisplay
Note Down the VG Name from output of command for further commands.- Execute below command to extend the Volume Group with /dev/sda3. replace VG Name with the VG name displayed by above command.
vgextend <VG Name> /dev/sda3
- Execute below command to get Logical Volume path.
lvdisplay
This command will give you LV Path & will be used in next command.
- Execute below command to extend the Logical Volume with /dev/sda3. replace <LV Path> with the output value of above command.
- Execute below command to update the Logical Volume
xfs_growfs /dev/VolGroup/lv_root
- Check for the new disk space.
df -h
Here you are done with expanding & mounting partition.