in Others

Freeing Up Space on Virtual Machines

A Virtual Machine (also referred to as VM) is actually an OS (Operating System). It can also be seen as an application environment which has been installed on software that emulates dedicated hardware. For end users, the experience of being on a virtual machine remains exactly as it would on dedicated hardware.

Hypervisor (specialized software) imitates the Server’s CPU or PC client, network, hardware, hard disk, memory and similar hardware resources entirely, which allows VMs to share resources. Multiple virtual hardware platforms can be imitated by hypervisor that are cut off from each other. This allows VMs to run Window Servers and Linux OS on the same underlying physical host.

Virtualization helps you deduce the need for physical hardware systems, which in essence help you reduce cost. Virtual machines lower the required quantity of hardware by efficiently using the existing hardware and all of this, reduces maintenance costs, cooling demands and power needs.

All in all they sound perfect. So what is the problem?

Most virtual machines dynamically allocate space so that not all of the disk space is occupied. This is actually good because the operating system and software take very little space. The problem however arises when you discover that the space once allocated, will always remain allocated. As you add and delete files, caches build up and after that even if internally your virtual machine occupies very little space, on your hard drive it might completely take over.

· How to Free Up Space Then?

If you are using VMware then you can use the compact tool that comes with it to recover space, but be warned that it only works ootb (out of the box) with Windows virtual machines. However, if you have a Linux virtual machine with a journaling file system similar to ext4 then you might need to make some extra preparations. In a nutshell, it means that the preparation would require for you create a massive empty file that only contains 0.

To start the process, you first need to stop running all the services. The newly created file will consume the virtual disk’s free space. When they will no longer be able to write to the disk, the running services will malfunction. You need to stop the running services before you create the file if you don’t want your database server to crash.

The command to create the file is: dd if=/dev/zero of=/dummy bs=4096. This command allows dd to create a file named dummy in /. The free space of the virtual disk will be the entire file size. For example if your configured virtual disk is 500GB and out of that 400GB is free, then the size of the file would be 400GB. You don’t need to have 400GB free on your physical disk where the virtual machine is stored on the real space needed will be 0 MB as you write zeros. After dd fills your system, it will exit out. You can delete the dummy file using rm /dummy.

You need to shut down your virtual machine and open the VM Player. On the panel, locate properties select the hard disk you want to compact and start the Compact tool from the Utilities drop down menu.

Doing that will start the compact tool and after a while you will see a success message informing you that the disk was compacted.

If you use cloud VMs then you should start using CloudBacko. The software helps you with smooth Hyper-V backup and VMware backup. This will more or less solve the spacing issue. To know more about CloudBacko’s features or to get it now, visit