How to Reclaim Free Space for Linux Root Partition using Zerofree

This article discussed about how we can reclaim the free space for linux root partition that was implemented using thin provisioned disks in Linux VMware virtual machine (VM). Common advantages by implementing thin provisioned disks in VMware is the administrator are able to over-allocate storage because the provisioned thin disks consume only the space used. The concept of thin provisioning disk disregard either the operating system running on Linux or Windows. However, by using thin provisioned disks, you will find that vmdk file size still expands over the time whenever you install, uninstall or delete applications in VM. You will noticed that the vmdk file size does not shrink or return to its previous size. When this happens to the linux VM, we need to use zerofree utility to reclaim and shrink the free space. The following steps is mainly to reclaim free space for linux root partition, tested in CentOS 7 and RHEL 7.

READ  How to Change Date and Time Linux on RHEL 6/7 and CentOS 6/7

1. Install “zerofree” on your virtualbox guest machine.

2. Run this command to boot into rescue mode :

# systemctl rescue

3. In the rescue mode, enter root password :

4. Mount the root partition as read-only. Then run zerofree command. Once zerofree command complete, kindly reboot the VM.

reclaim-freespace-zerofree-1

# mount -o remount, ro /dev/mapper/centos-root
# zerofree -v /dev/mapper/centos-root

5. Do a virtual clone V2V using vCenter or vmkfstool command. You will notice the vmdk size reduce to only the space used.

Leave a Reply

Your email address will not be published. Required fields are marked *

SiteGround.com

A world leading hosting company that provides fully-managed innovative and secure solutions, suitable for hosting small to medium-sized websites

Built on the best available technologies combined with Google Cloud for strong redundancy and application availability. Backed by skilled experts to address web security threats, a devops team to create advanced custom security solutions, and 24/7 sysadmins to watch over the platform. This powerful, hands-on approach makes your sites faster, safer, and easier to manage. Starting from only $3.95/mo.

TRY FREE

* up to 30 days money back guarantee