Bruab Schrader published in his blog a curious low-tech trick that I found particularly interesting for how counter-intuitive it is. He has simply titled it Why All My Servers Have an 8GB Empty File and it serves to avoid one of the most typical problems of many servers, the dreaded “disk full”.

The fact is that one might wonder why anyone would want to store a gigantic file on their server to avoid “disk full” problems if doing so would fill up the disk a little more. As Schrader explains, the fact is that on many Linux and other machines when they fill up, it is usually both difficult to detect and difficult to recover quickly. Can you expand the disk in a matter of minutes? Normally, no. What do you delete when the disk is full? Whatever is useless. Are you sure that what you intend to delete is useless?

The trick is that if when you have the disk with a suitable occupation, let’s say 30 of 100 GB, you add a “false file” or “ghost” of 8 GB [the size can vary] if the dreaded moment of the failure by “full disk” arrives you simply delete that file and magically you will have at your disposal a lot of free GB. And that’s when you gain time to find another more suitable solution and implement it, be it deleting other things, expanding disk space, and so on.

A simple way to create the file in question is to run:

head -c 8000000000 /dev/urandom > random_file.txt

(where the number indicates how many bytes the phantom file in question will have; it takes a while to generate). The content is random – and therefore cannot be compressed – and depending on how the backup is configured it will also take up space there, so it may be best to exempt it from copying.

Depending on how you look at it, the trick can be compared to carrying stones in a backpack when you are being chased by a lion: if you throw them on the ground, you run faster and escape more easily… but you could not carry them in the first place and maybe then the lion would not chase you (!) Anyway, maybe that’s why some runners train with a backpack full of stones, to anticipate a “worst case scenario”.

LEAVE A REPLY

Please enter your comment!
Please enter your name here