2 ms·
hope you're not running -o compress=lz4 , because you are going to be in for a big surprise when you try to pull this emergency lever! you may be shocked to see
by rektide 6y ago
hope you're not running -o compress=lz4 , because you are going to be in for a big surprise when you try to pull this emergency lever! you may be shocked to see you don't actually get much space back!
i do wonder how many FS would actually allocate the 8GB if you, for example, opened a file, seeked to 8GB mark, and wrote a character. many file systems support "sparse files"[1]. for example on btrfs, i can run 'dd if=/dev/zero of=example.sparse count=1 seek=2000000' to make a "1GB" file that has just one byte in it. btrfs will only allocate a very small amount in this case, some meta-data to record an "extent", and a page of data.
i was expecting this article to be about a rude-and-crude overprovisioning method[2], but couldn't guess how it was going to work. SSDs notably perform much much better when they have some empty space to make shuffling data around easier. leaving a couple GB for the drive to do whatever can be a colossal performance improvement, versus a full drive, where every operation has to scrounge around to find some free space. i wasn't sure how the author was going to make an empty file that could have this effect. but that's not what was going on here.
[1] https://wiki.archlinux.org/index.php/sparse_file https://wiki.archlinux.org/index.php/sparse_file
[2] https://superuser.com/questions/944913/over-provisioning-an-ssd-does-it-still-hold/944915 https://superuser.com/questions/944913/over-provisioning-an-...
- sonicrocketman 6y agoGood point. I didn't think of that. I'm not sure how my CentOS servers handle this scenario, but it seemed to take up the full 8GB however I checked.
- secabeen 6y ago> hope you're not running -o compress=lz4 , because you are going to be in for a big surprise when you try to pull this emergency lever! you may be shocked to see you don't actually get much space back! This is true. If you are replicating this, copy from /dev/urandom rather than using an empty file.
- yjftsjthsd-h 6y agoIt feels more elegant to do something like `touch /bigfile && chattr -c /bigfile && truncate --size 8G` to outright disable compression on that file
- spijdar 6y agoBefore reading this, I had presumed that sparse files did not overcommit drive space, but apparently, they do. I don't use them regularly and certainly not to "reserve disk space" but I was surprised that you can make sparse files way larger than available free space on the drive. I had assumed they were simply not initialized, but the FS still required <x> amount of free space in case a block is accessed.