How to Expand a Hard Disk on a Linux VM in VMware Online
If you’re using a virtual machine (VM) in VMware and you need to expand the hard disk due to space constraints, you can do so online without having to shut down the VM. Here’s a step-by-step guide on how to expand your hard disk on a Linux VM online.
Step 1: Change the Size of the Hard Disk
- Open the VMware vSphere Client and log in.
- Select the virtual machine you want to expand the hard disk for.
- Click the “Edit Settings” button to open the VM settings.
- Click on the hard disk you want to expand and select “Edit”.
- Change the size of the hard disk and click “OK”.
Step 2: Expand the Partition Online
Notify the kernel that the hard disk size has changed by running the following command:
This command updates the kernel’s partition tables to recognize the new size of the hard disk, enabling the partition to be expanded online.
Install the “cloud-utils” package by running the following command:
sudo apt-get install cloud-utils
Use the “growpart” tool to expand the partition online. To do so, enter the following command, where “/dev/sda1” is the partition to expand:
sudo growpart /dev/sda 1
Verify that the partition has been successfully expanded by running the following command:
The output should show the expanded partition.
Expand the file system to use the new size of the partition by running the following command:
sudo resize2fs /dev/sda1
Step 3: Verify the Size
- Run the command
df -hto display the size of the partition.
- Verify that the size of the partition is displayed correctly.
Congratulations! You have successfully expanded the size of your hard disk on a Linux VM in VMware online, without having to shut down the VM.