This article mainly shares a simple and fast method to expand the disk size of the root directory of the ubuntu system under the virtualbox virtual machine, which can also be extended to the vm virtual machine and the windows client system.
The whole process can be divided into two major steps:
- vboxmanager expands the size of the virtual machine disk (xxx.vid)
- gparted allocates the new space to the primary partition (sda) 1. Expand the size of the virtual machine disk (xxx.vid) Mainly Use the following command of vboxmanager.exe: As shown in the figure below: It should be noted that if a failure message such as "unsupported format" is displayed in this step, format conversion is required. Generally, if your virtual machine file is in xxx.vmdk format, it needs to be converted to XXX.vdi. What's more pitiful is that my virtual machine file is in .vdi format, and it also failed at this step. It took a long time to toss, and I occasionally tried to convert it before I got it. The command is as follows:
.\VBoxManage.exe modifyhd ***.vid --resize 30720
.\VBoxManage.exe clonehd XXX.vmdk XXX.vdi --format VDI
References:
- virtualbox extended virtual machine disk
- vboxmanage official website documentation
2. Allocate the newly added space to the ubuntu main partition
. The cross-platform gparted partition management software is mainly used. The tutorial is as follows:
- gparted tutorial
- gparted windows partition operation
Implement partitioning. Also, unlike the tutorial, gparted can be
installed
sudo apt-get install gparted
sudo gparted
It should be noted that
only adjacent partitions can be merged. Therefore, to merge the new partition (unmount) into the sda partition, it needs to span the extended and linux-swap partitions. The method is: first close the linux-swap partition (swapoff), and delete the linux-swap partition. Then expand and squeeze the extended partition, then expand the sda partition, and finally rebuild the linux-swap partition.
The very concise steps are given in the first tutorial, so I won't repeat them here.