On Sat, 8 Mar 2025, Thomas Schmitt wrote:
But if, instead, what you want is the backing store to grow then use a sparse file as the backing store.This idea reduces the search to filesystems which don't hop around and write without need to new random places on their storage medium.# truncate -s 1T file # mke2fs -t ext4 file That's a 1T ext4 filesystem that is, when empty, using around 20M ofdisk space. Question is how its "du" size grows when you put a few files into it, overwrite their content, rename and copy them.
# fallocate -l 100M file # du -h file 101M file # mke2fs -t ext4 -E nodiscard file mke2fs 1.47.0 (5-Feb-2023) Creating filesystem with 102400 1k blocks and 25584 inodes Filesystem UUID: 7e49b294-4c51-407a-9b84-557755c7baed Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done # du -h file 101M file # mount -o loop file mnt # fstrim -v mnt mnt: 88.2 MiB (92486656 bytes) trimmed # umount mnt # du -h file 5.7M file It can be cleaned up periodically. Ideally you'd want a fuse fs that supported fstrim I guess. I don't know whether this is even possible. ext4 fuse doesn't support SEEK_HOLE/SEEK_DATA (at least not last time I looked) so I doubt it will support discard.