Compact a VM Disk Image

My Windows 7 desktop complained the disk space usage is near to 90%. After checked my Ubuntu VM, its virtual disk expands to around 200G although it only contains around 100G data.

So I googled some posts which have instructions:

After compacted the VDI file, my desktop has more 100G free space now.

Reboot the Ubuntu VM, and it shows a message:
mountall: disconnected from Plymouth

Google again. The swap partition is not mounted correctly. Use following command to check it:

free -m

The total of swap is 0.

Try some commands from “Mountall fails on startup“, then the swap is back and the message is gone.

Final step, there is a very large hiberfil.sys file and I let my desktop keep awake for a long time. I think I don’t need hibernation, so I disable it by following article, “How to disable and re-enable hibernation on a computer that is running Windows“.