Reclaim free space on your server ‘with this weird trick’ (KVM/Xen/dedi only)

This quick tutorial will help you reclaim free space on your servers or Xen/KVM VPSes. This post can be considered as a re-post the method from LowEndTalk discussion topic. The source can be found HERE.

By default the Ext2/3/4 filesystems are created with a setting to set aside 5% of free space for the root user, not shown in the free space count and not usable by other users and their programs. This is done “just in case”, with practically just one scenario in mind: if something goes wrong and your server consumes all its free disk space, the root user could still log in and check logs/crash dumps/etc and generally fix the situation.

Let say if you have a 10G HDD, 5% is just 512MB, on 500G it is around 25GB. However, in my backup system which has 2TB disk, 5% mean 100G which I cannot use and it is really the waste. Let’s check this:

[bash]# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 20G 1018M 18G 6% /
/dev/root 20G 1018M 18G 6% /
devtmpfs 2.0G 216K 2.0G 1% /dev
/dev/sda3 1.8T 1.7T 74G 96% /home
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named
/dev/root 20G 1018M 18G 6% /var/named/chroot/var/named
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named.conf
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named.rfc1912.zones
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/rndc.key
/dev/root 20G 1018M 18G 6% /var/named/chroot/usr/lib64/bind
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named.iscdlv.key
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named.root.key[/bash]

Then, I want to reduce the “reserving space” for root user to 1%, meaning 20G (more than enough):

[bash]# tune2fs -m 1 /dev/sda3
tune2fs 1.41.12 (17-May-2010)
Setting reserved blocks percentage to 1% (4831265 blocks)[/bash]

Then check the final result:

[bash]# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 20G 1018M 18G 6% /
/dev/root 20G 1018M 18G 6% /
devtmpfs 2.0G 216K 2.0G 1% /dev
/dev/sda3 1.8T 1.7T 148G 92% /home
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named
/dev/root 20G 1018M 18G 6% /var/named/chroot/var/named
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named.conf
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named.rfc1912.zones
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/rndc.key
/dev/root 20G 1018M 18G 6% /var/named/chroot/usr/lib64/bind
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named.iscdlv.key
/dev/root 20G 1018M 18G 6% /var/named/chroot/etc/named.root.key[/bash]

 

As you can see, in some backup system with very large disk and space is one of the critical one in your concern, it should be better to save as much as unused space as we can 🙂

Similar Posts

  • Install PHP 5.5 with OpCache and Google PageSpeed

    This tutorial guides step-by-step on how to install most recent/most updated versions of a regular PHP stack. This comprises PHP 5.5 with OpCache, Percona 5.6 server and Google PageSpeed for Apache HTTPD Import needed repo for PHP 5.5:[bash]rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm [/bash] Install PHP 5.5 and related softwares:[bash]yum –enablerepo=remi,remi-php55 install httpd php php-common…

  • Install Apache Solr on CentOS 6

    Solr is the popular, blazing fast open source enterprise search platform from the Apache LuceneTM project. Its major features include powerful full-text search, hit highlighting, faceted search, near real-time indexing, dynamic clustering, database integration, rich document (e.g., Word, PDF) handling, and geospatial search. Solr is highly reliable, scalable and fault tolerant, providing distributed indexing, replication…

  • OwnCloud with NginX and PostgreSQL

    This quick tutorial will help you run the OwnCloud with NginX and PostgreSQL on Ubuntu 14.04. Add the necessary repo to /etc/apt/sources.list: [bash]# nginx stable deb http://nginx.org/packages/ubuntu/ trusty nginx deb-src http://nginx.org/packages/ubuntu/ trusty nginx # nginx mainline deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx[/bash] Update system: [bash]apt-get update apt-get dist-upgrade[/bash] Install nginx: [bash]apt-get install nginx[/bash] Install dependencies for…

Leave a Reply

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