VirtualBox Tips#
Shrink VDI File#
When we use the virtual machines for a while, we found that, even if we had deleted the files in the vm, the VDI files still kept growing larger and larger.
Solution#
-
After logging into the virtual machine system, execute the following command to fill the system space with /dev/zero to a temporary file, and then remove it:
-
Shutdown the virtual machine, then execute the following command on the host machine to release the space (~~2022-12-05: Unfortunately... it does not work when the host machine is Windows~~ 2022-12-06: Noticed that the temporary file is located in the /tmp directory, and the /tmp directory in the operating machine occupies a separate partition, which is why it didn't work. Changing the temporary file to /bigemptyfile works. Yeah!):
[16:38]davinci@Monterey:~ % l ~/VMs/xubuntu/xubuntu.vdi -rw------- 1 davinci staff 16G 7 Jul 16:39 /Users/davinci/VMs/xubuntu/xubuntu.vdi [16:39]davinci@Monterey:~ % VBoxManage modifymedium --compact ~/VMs/xubuntu/xubuntu.vdi 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% [16:45]davinci@Monterey:~ % l ~/VMs/xubuntu/xubuntu.vdi -rw------- 1 davinci staff 8.8G 7 Jul 16:45 /Users/davinci/VMs/xubuntu/xubuntu.vdi
Disable Noisy System Program Problem#
-
Clear system crash logs:
-
Disable the Apport service: