How-to: VMware Increase Disk Size and Resize an Ubuntu LVM Partition
Introduction
Logical Volume Management (LVM) is a versatile disk management tool used in many Linux distributions, including Ubuntu. In this guide, we’ll explore how to expand a VMware virtual machine’s disk and subsequently increase an Ubuntu LVM partition.
Prerequisites
- A VMware virtual machine with Ubuntu installed and configured with LVM.
- VMware vSphere or VMware Workstation.
- Backup of the virtual machine (always essential before modifying disk structures).
Steps to Increase Disk Size in VMware
- Power off the Virtual Machine: Ensure the VM is powered off before you begin.
- Open VMware vSphere or Workstation: Navigate to the VM’s settings.
- Locate the Hard Disk you want to expand: In the
Hardware
tab, select the disk you wish to enlarge. - Increase Disk Size: Specify the new desired size and confirm the change.
- Power on the Virtual Machine: Start up the VM after adjusting the disk size.
Resizing the Ubuntu LVM Partition
With the VMware VM disk expanded, the next step involves resizing the Ubuntu LVM partition to use the new space.
- Log into Ubuntu: Access the terminal.
- Check Physical Volume:
1
sudo pvdisplay
- Expand the Physical Volume:
1
sudo pvresize /dev/sdaX
- Expand the Physical Volume:
1
sudo pvresize /dev/sdaX
Replace
sdaX
with the appropriate disk identifier from thepvdisplay
output. - Check Volume Group:
1
sudo vgdisplay
- Expand the Logical Volume:
1
sudo lvresize -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Ensure you replace
/dev/ubuntu-vg/ubuntu-lv
with your logical volume path, if different. - Resize the File System:
1
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
Remember to replace the logical volume path if yours differs from the default.
Conclusion
You’ve now successfully enlarged your VMware VM disk and resized the Ubuntu LVM partition to make use of the additional space. Always back up your data and configurations before modifying disk structures, ensuring data integrity and easy recovery if needed.