How do I add space to LVM's root partition without shutting down my VM?
- In the VMWare consore, extend the drive
- Use
fdisk
orcfdisk
orparted
to create a new primary partition with type8e/lvm
(we'll call it/dev/sda3
for now) - Tell the system about the new partition:
sudo partprobe /dev/sda3
- Make the new partition an lvm physical volume:
sudo pvcreate /dev/sda3
- Add the new physical volume to your volume group:
sudo vgextend $VGName /dev/sda3
- Increase the size of your logical volume:
sudo lvextend -L+10G /dev/$VGName/root
- Increase the size of your file system:
sudo resize2fs /dev/$VGName/root
It may be easier to simply add additional drives to the VM and use them as physical volumes. That would clutter the VM storage area with more VMDKs. This solution is a bit messier in the vm.