When encountering a virtual machine using ESXI at work that requires disk expansion, simulate the expansion process by installing an ESXI environment locally.
The size of the virtual machine's hard disk can be dynamically adjusted without shutting down the virtual machine, while the CPU and memory must be adjusted with the virtual machine turned off.
Scenario: Expand the existing disk directly without adding a new disk#
Adjust the virtual machine's hard disk size to 24G.
After the adjustment, the size of the virtual machine's disk has not changed. Enter
echo 1 > /sys/block/sda/device/rescan
to notify the kernel to rescan the disk, and after a moment, the disk size will change.
Use the parted command to adjust the disk size. First, check the total space and allocated space.
In the parted command line, use the resizepart
command to adjust the partition size. After the adjustment, the size of the second partition changes.
Since a logical volume is used, the physical volume size needs to be adjusted using pvresize
.
Expand the logical volume.