- Extend the disk in your cloud or virtualization platform first.
- Run a fdisk -l to check the extended disk is available to the OS
As you can see from the below output the size of the physical disk is set to 171.78 GB while the Disk /dev/mapper/vg_root-lv_root is still set as 41.9
You may need to reboot the VM if it does not recognize the new disk space you added to it.
3. You can run the following commands to gather some information about your Volumes:
pvdisplay
vgdisplay
lvdisplay
As you can see from the above we have 1 Physical Volume, 1 Volume Group and 1 Logical Volume.
Run fdisk to create a new partition
fdisk /dev/sda
- press p to list partitions
- To Create new partition Press n.
- Choose primary partition use p.
- Set the partition number to 3
- press enter twice to use defaults for cylinders
- Change the type using t.
- Type 8e to change the partition type to Linux LVM.
- Use p to print the create partition
- Press w to write the changes.
As you can see from the above we now have a third partition (/dev/sda3)
type w to write the changes then reboot to finish the changes
Reconnect to the server after the reboot. The next steps will be to extent the Volume Group, Logical Volume and file system using the new partition we just created:
- vgextend vg_root /dev/sda3
- lvextend -l +100%FREE /dev/mapper/vg_root-lv_root
- resize2fs /dev/vg_root-lv_root
Finally run fdisk -l again to verify the disk has been extended
As you can see the disk is now showing as 170.8 GB when it was set to 41.9 at the beginning.
Please post a comment below if you like the article or have any questions.