This tutorial is using Xubuntu 14.04 as virtual box guest OS.
These are the step to compact a Linux Guest OS in VirtualBox
1.) First, you need to login into your Linux OS.
2.) Then, you will need to open a terminal by pressing ctrl-alt-T.
3.) Next, type this command : "sudo dd if=/dev/zero of=emptyfile bs=1M" into your terminal to zero out the un-used space.
4.) After that, you need to check and making sure of the "emptyfile" location and cd into the "emptyfile" location. Since the location is located at my Home directory and my terminal is showing at my Home directory. I will just directly enter this command into the terminal: "sudo rm emptyfile" to remove/delete the "emptyfile"
5.) After completing the previous step, you will need to log out of your Linux OS.
6.) Then, if your host OS is Windows. you will need to open up your command prompt and navigate to the virtual box installation folder by entering this command : cd "C:\locationOfYourVirtualboxInstallationFolder".
7.) Next step is to type in : VBoxManage.exe modifyhd --compact "C:\LocationOfYourGuestOSHardDiscVDIFile" and wait for it to complete.
8.) Finally, you can check on your compacted virtual box hard disc size.