Photon OS 4.0 Grow Filesystem using Logical Volume Management (LVM)

I recently needed to grow the file system on a Linux VM. I remembered writing a post on this before, so I headed here:

Unfortunately this previous post assumed a non-LVM disk setup.

I needed to increase the size of the /data mountpoint using the filesystem /dev/mapper/data_vg-data and the earlier instructions did not work. My VM had three disks. To figure out which one I needed to grow, I used the Linux lsblk command. This showed three disks, sda, sdb, and sdc. The /data mountpoint went to sdb, which was 60GB in size. Looking at the VM, Hard Disk 2 was the only one that was 60 GB. I increased it to the necessary size in the vCenter UI.

Back in the VM I needed to resize the filesystem to match the new disk size. To do this I first ran pvresize /dev/sdb which returned the message that 1 physical volume(s) resized or updated.

I then ran lvdisplay looking for the ‘data’ volume group, specifically the LV Path property, which in this case was /dev/data_vg/data.

From here I ran lvextend -l +100%FREE /dev/data_vg/data which returned a message that the size of logical volume had changed to the new size of the disk.

Finally I ran resize2fs /dev/data_vg/data which confirmed that the filesystem was resized on-line.

The command df -h now shows the expected size for the mount.

This entry was posted in Lab Infrastructure, Virtualization. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


Notify me of followup comments via e-mail. You can also subscribe without commenting.