I started off by getting a view of the current disk space available on the server. I knew that the host had increased the size of disk /dev/sda from 20GB to approximately 100GB, so I used parted to output the unallocated space from the command line.

$ sudo parted /dev/sda print free Model: VMware Virtual disk (scsi) Disk /dev/sda: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 32.3kB 1049kB 1016kB Free Space 1 1049kB 256MB 255MB primary ext2 boot 256MB 257MB 1048kB Free Space 2 257MB 21.5GB 21.2GB extended 5 257MB 21.5GB 21.2GB logical lvm 21.5GB 21.5GB 1049kB Free Space

Next, I used the unallocated space to create a partition using parted.

$ sudo parted -- /dev/sda mkpart primary 21.5GiB -1s

The two dashes right after the parted call keep the -1s from causing an invalid argument error. It tells parted not to expect any more options. -1s tells parted to use the rest of the unallocated space for the partition. Otherwise, I’d have to calculate the end of the partition myself.

Once this was done, I went ahead and ran partprobe to sync the kernel’s partition table with the disk’s. This prevented me from having to reboot the server.

$ sudo partprobe /dev/sda

The next thing to do was use pvcreate to create a physical volume which can be added into the logical volume group for the drive later. Just make sure that your partition number (the 3 at the end of sda3) matches the partition you just created.

$ sudo pvcreate /dev/sda3

In order to add the physical volume to the volume group, I needed to find the volume group’s name.

$ sudo vgdisplay ...snip... --- Volume group --- VG Name ustest-vg ...snip...

In my case the volume group was ustest-vg. This will most likely follow the [hostname]-vg naming convention, so change it appropriately for your server.

I was now ready to extend the logical volume group to include the new physical volume.

$ sudo vgextend ustest-vg /dev/sda3

Next, I had to find the name of the logical volume so I could extend it. Remember that the name of your volume group (ustest-vg) will vary with the hostname. Also notice that you want the LV Path that ends in root, not swap.

$ sudo lvdisplay ...snip... --- Logical volume --- LV Path /dev/ustest-vg/root ...snip...

Extending the logical volume has a similar form to extending the volume group.

$ sudo lvextend /dev/ustest-vg/root /dev/sda3

Lastly, before I could start using this new space, the file system needed to be re-sized.

$ sudo resize2fs /dev/ustest-vg/root

Running df -h should now show the increased space available in that logical volume. In my case this was an increase from about 20GB to approximately 100GB.

$ df -h ...snip... Filesystem Size Used Avail Use% Mounted on /dev/mapper/spwebapps1--vg-root 95G 12G 80G 13% / ...snip...