Resize vSphere VM Hard Drive
Resize vSphere VM Hard Drive
If you’re working with a vSphere VM and need to resize the hard drive to allocate more space, this blog post will guide you through the process. We’ll walk you through the steps to resize the hard drive on a vSphere VM. Let’s get started!
Prerequisites
Before proceeding with the resizing process, ensure that you have the following:
- Access to vSphere management interface.
- Administrative privileges to perform VM-related operations.
Resizing Steps
Follow the steps below to resize the vSphere VM hard drive:
- Create a backup directory for the current home files:
mkdir /opt/home.backup
- Move the existing home files to the backup directory:
cd /home mv * /opt/home.backup
- View the logical volumes on the machine to identify the home logical volume:
lvdisplay -v
- Unmount the home directory:
umount home/
- Verify that the home directory is unmounted:
df -h
- Comment out or delete the /home mountpoint in the /etc/fstab file using a text editor:
vi /etc/fstab #/dev/mapper/home /home xfs defaults,nosuid,nodev 0 0
- Remove the logical volume ‘home’:
lvremove /dev/mapper/home
- Extend the logical volume ‘root’ ‘/’:
lvextend -l 100%FREE /dev/mapper/root
- Extend the XFS filesystem:
xfs_growfs -d /dev/mapper/root
- Verify that the ‘root’ ‘/’ partition has reclaimed the space from ‘home’:
df -h
- Move the files from the backup directory back to the home directory:
cd /opt/home.backup mv * /home
- Reboot the VM for the changes to take effect:
reboot
You have successfully resized the hard drive on your vSphere VM. The VM now has more space allocated to the root partition (‘/’), allowing you to utilize the additional storage!