blog.minskio.co.uk

Content and theme behind minskio.co.uk
Log | Files | Refs

compacting-vdi-image.md (720B)


      1 ---
      2 title: "Compacting a VirtualBox VDI image"
      3 date: 2018-09-06T12:26:00
      4 tags: ["Formats", "Guides", "Linux", "Snippets", "Software", "Windows"]
      5 ---
      6 
      7 Firstly, you'll need to install `zerofree` on your Linux image, then mount the root partition as a read only volume. This can be done via:
      8 
      9 ```
     10 sudo apt-get install zerofree
     11 sudo apt-get clean
     12 sudo reboot
     13 # interrupt grub boot and boot into recovery mode
     14 mount -n -o remount,ro -t ext4 /dev/sda1 /
     15 zerofree /dev/sda1
     16 shutdown -h now
     17 ```
     18 
     19 And now on the Windows Host:
     20 ```
     21 "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyvdi "VirtualBox VMs\server\server.vdi" compact
     22 ```
     23 
     24 This should make the VirtualBox image more in line with the calculated size it should be.