Isn’t using LVM and holding some space back a better solution for this? Also I keep databases on their own partition so that nothing else can accidentally fill up the space and lead to data loss.
Maybe, but author says: > On Linux servers it can be incredibly difficult for any process to succeed if the disk is full. You won't feel too clever if you come to grow your LVM volume into the free space and it won't work because there's no free space on the filesystem! :) (I don't actually know if this would fail or not - but the point is "rm spacer.img" is pretty much guaranteed not to fail).
All my servers have an 8 GB empty file on disk
61–70 of 715 posts
Re: All my servers have an 8 GB empty file on disk
#62> Copy commands and even deletions can fail or take forever as memory tries to swap to a full disk That's only a problem if your memory is full as well, and even then, I've never encountered a server that uses a swapfile instead of a swap partition.
Re: All my servers have an 8 GB empty file on disk
#63Once the project invariably goes over budget, he drops the plans for the gold and frees up extra funds.
Edit: I think it was a large marble slab. Same thing.
Re: All my servers have an 8 GB empty file on disk
#64I have an empty leader on my hard drive so that I can recover if I accidentally nuke the front of it with dd while making a live usb. So it's not a bad idea, and it's super effective so far it hasn't been tested, and hopefully I never will need to.
Re: All my servers have an 8 GB empty file on disk
#65This reasoning doesn't make sense. On Linux, swap is preallocated. This is true regardless of whether you're using a swap partition or a swap file. See man swapon(8):
> The swap file implementation in the kernel expects to be able to write to the file directly, without the assistance of the filesystem. This is a problem on files with holes or on copy-on-write files on filesystems like Btrfs.
> Commands like cp(1) or truncate(1) create files with holes. These files will be rejected by swapon.
I just verified on Linux 5.8.0-48-generic (Ubuntu 20.10) / ext4 that trying to swapon a sparse file fails with "skipping - it appears to have holes".
Now, swap is horribly slow, particularly on spinning rust rather than SSD. I run my systems without any swap for that reason. But swapping shouldn't fail on a full filesystem, unless you're trying to create & swapon a new swapfile after the filesystem is filled.
Re: All my servers have an 8 GB empty file on disk
#66Re: All my servers have an 8 GB empty file on disk
#67This is clever. Our shaky version of this, historically, has been to run ncdu and hastily delete the first large log file we see. It’s not ideal.
Re: All my servers have an 8 GB empty file on disk
#68Why not keep an eye on the disk and expand the fs before it goes south?