Free some space on ext2|3|4 filesystems

  • In addition to my topic Suggestion for useful options when creating filesystems I wrote a little shellscript which first lists the filesystems and their reserved block count as well as the resulting reserved space in megabyte. If called with an argument, it sets the reserved block count on those filesystems to 0 (zero) and therefore freeing the space.


    First some background details: on a linux machine there is at least one filesystem which holds "/", the so called root file system. This is the mother of all other paths, be they on the same filesystem as root or on another mounted filesystem. As the running system always needs some space for temporary files, logs, backups and so on it would be fatal if some user (or any process) would eat up all space on the filesystem and leave no space for other important tasks. That's why the standard filesystems for linux -- ext2, ext3 and ext4 -- come with an option for saving some space for the superuser and his privileged processes. This space is calculated to be 5% of the total space of the partition, regardless wether this is gonna be the root filesystem or some simple data storage for users. So all generated filesystems come with this reserved space, that only superuser may use. Quite senseless on a disk that only offers space for normal users. Discs are getting cheaper from day to day, but nevertheless you pay for every gigabyte and should be able to use it afterwards. On a 2TB disc this hidden space sums up to nearly 100GB!


    This script scans all filesystems on a linux machine and shows the current settings for the reserved block count. This count is also calculated to show the hidden space in megabyte. If the script is called with option "--FREE" it changes the settings for all filesystems and frees up the hidden space for all users. One exception is the filesystems which holds the root. This is not touched.


    For execution of the script, bash needs to be installed and the following tools need to be available:
    blkid from package util-linux and
    tune2fs from package e2fsprogs.


    To run the script, copy and paste the following code to a file on your linux machine (e.g. your OMV-machine).


    Then call this file on commandline (use ssh ore something similar for that) by typing

    Code
    bash <filename>


    The script can only be called by superuser (root) so the call might be prepended with "sudo". You can also make this file executable by typing

    Code
    chmod u+x <filename>


    Calling this script without any argument doesn't change anything on the system. It just reads some settings and prints them on the screen. Even calling the script with "--FREE" will only change that single setting, which can be undone at any time using the following command (this is also noticed in the script itself):

    Code
    tune2fs -m <number> <filesystem>


    This command sets the reserved block count for <filesystem> to <number> percent of total block count (e.g. of total space).

    System: OMV 1 on HP Microserver G7 N54L w/ 16GB RAM and 60GB SSD (backports enabled)
    Storage: 3TB + 2x 1.5TB + 3x1TB HDD

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!