Ok, thank you to hologen2 as the post they gave provided inspiration to me in the right direction. I've resolved the issue.
1. Ensure you have a root password:
$ sudo passwd -u root
$ sudo passwd root
Type in a password you can remember
$ sudo shutdown -r now
When you see the VirtualBox logo screen, hold down the [RIGHT SHIFT] key until you see the grub screen.
Select the advanced options and then recovery mode.
At the next screen select to drop to root console.
At the # prompt enter the root password you set earlier.
# mount | grep "sda"
Takenote of the sda # (ie. sda1, sda2, etc.) that is for the / or rootdirectory. We'll assume /dev/sda2 for this example.
# echo "u" > /proc/sysrq-trigger
# mount /dev/mapper / -o remount,ro
# zerofree -v /dev/sda2
# shutdown -r now
NOTE: You don't need to remount as rw after using zerofree because once you reboot fstab will mount the drive rw anyway.
Now let it boot normally.
If you want to disable your root password (I am one of those that does this for security reasons):
$ sudo passwd -l root
Now I usually just go and shut down the system and compress the drive:
$ sudo shutdown -hP now
From there I use VBoxManage clonehd [machine].vmdk [machine]-disk1.vmdk to clone it and that compresses it further.
I hope this post helps those who have also had issues with getting zerofree working in Ubuntu 18.04LTS in Virtualbox.
Bookmarks