summaryrefslogtreecommitdiffstats
path: root/content/posts/compacting-vdi-image.md
blob: 449b5ecf528c73e13d3d5d04fbb26ba5fd4a9788 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
title: "Compacting a VirtualBox VDI image"
date: 2018-09-06T12:26:00
tags: ["Formats", "Guides", "Linux", "Snippets", "Software", "Windows"]
---

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:

```
sudo apt-get install zerofree
sudo apt-get clean
sudo reboot
# interrupt grub boot and boot into recovery mode
mount -n -o remount,ro -t ext4 /dev/sda1 /
zerofree /dev/sda1
shutdown -h now
```

And now on the Windows Host:
```
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyvdi "VirtualBox VMs\server\server.vdi" compact
```

This should make the VirtualBox image more in line with the calculated size it should be.