


You can’t actually use zerofree on your / partition while you’re booted into the standard Linux environment. For example, you can install it on Ubuntu by running the following command at the terminal inside your virtual machine: sudo apt install zerofree It should be available in your Linux distribution’s software repositories. To do this, you’ll first need to install the zerofree utility inside the virtual machine. We’ll use Ubuntu as the example here, but the process will be similar on other Linux distributions. If you have Linux installed in the virtual machine-a Linux guest operating system instead of a Windows guest operating system, in other words-you can skip the defragmentation process and use built-in commands to zero the free space on the drive. When it’s done, shut down your virtual machine using the “Shut Down” option in its Start menu. For example, if you have a fixed disk of 50 GB in size with only 20 GB of data on it and you convert it to a dynamic disk, you should be able to shrink it to take up only 20 GB of space. If you have a fixed size disk you want to shrink, you can first convert it to a dynamic disk and then follow the below instructions. RELATED: How to Convert Between Fixed and Dynamic Disks in VirtualBox Fixed size disks will always be their maximum size. Dynamic disks may be up to a certain maximum size-50 GB, for example-but they only actually grow to that maximum size when they contain that much data. This process only works for dynamic disks, which can grow and shrink in size. Step One: Ensure You’re Using a Dynamic Disk But, if you’ve created a dynamic disk, downloaded 10 GB of data into it, and then deleted that 10 GB of data afterwards, you should be able to shrink the disk by about 10 GB. So, if you just created a dynamic disk, this won’t shrink it. Remember that this will only shrink the disk if it’s grown in size and you’ve since removed data. RELATED: Beginner Geek: How to Create and Use Virtual Machines

But you can manually shrink a dynamic disk using a hidden command. However, if you delete data from the virtual machine later, you’ll notice that the disk doesn’t automatically shrink. By default, VirtualBox creates dynamic disks that grow over time as you add data.
