跳转至

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#

  1. 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:

    $ sudo apt install pv # if you want to visit the process
    $ dd if=/dev/zero | pv | dd of=/tmp/bigemptyfile bs=4096k; rm -fv /tmp/bigemptyfile
    
  2. 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#

reference

  1. Clear system crash logs:

    xubuntu@xubox:~$ sudo rm -fv /var/crash/*
    removed '/var/crash/_usr_bin_blueman-tray.1000.crash'
    removed '/var/crash/_usr_bin_mugshot.1000.crash'
    removed '/var/crash/_usr_bin_xfce4-power-manager.1000.crash'
    removed '/var/crash/_usr_share_apport_apport.0.crash'
    
  2. Disable the Apport service:

    xubuntu@xubox:~$ cat /etc/default/apport
    # set this to 0 to disable apport, or to 1 to enable it
    # you can temporarily override this with
    # sudo service apport start force_start=1
    enabled=0