*Edit: I have figured out how to use BTRFS and enable what it calls “transparent file compression”, and I’m going to use that on most of my old storage devices. The only problem I’m having is that I want to use F2FS on my oldest storage device, as BTRFS takes up too much space on the device and I was told by multiple users that F2FS also supports transparent file compression, but I can’t get files to compress and I’m not getting any error messages to try and fix it. Based on what the documentation says, I’m supposed to do something like this:
sudo mkfs.f2fs -f -O extra_attr,inode_checksum,sb_checksum,compression /dev/mmcblk0p1
sudo mount -o compress_algorithm=zstd,compress_extension=* /dev/mmcblk0p1 '/home/j/mountpoint/128mb'
chattr -R +c '/home/j/mountpoint/128mb'
The device will mount like this but files aren’t compressing when added, nor are they compressed if using the last command after they’ve been moved.*
I’m rewriting the old portion for clarification:
In Windows, there’s a file/folder option called “Compress contents to save disk space”. What it does is it compresses the files, as the name suggests, but leaves them accessible as though they aren’t. This doesn’t really have much of a benefit on newer storage devices but on older storage devices, in addition to saving space, it allows files to potentially read faster.
As I have some old storage devices that I want to run games from, I think this will be a great option to have if I could find something similar for Linux. I tried looking online myself but search engines are terrible and I couldn’t find anything though them. So, I decided to post about this here, to see if anyone knows of anything I could try.


Huh. My computer allows me to format a 128MB image file with brtfs. It won’t do it at 64MB though.
deleted by creator
Good call. Seems minimum for ZFS is three quarters of a Gigabyte, anyway. And definitely not made for what OP does 😆
How are you trying to format the device? I got that error message when using gparted.
truncate -s 128M fs.img parted fs.img mklabel gpt mkpart primary btrfs 1MiB 100% quit sudo losetup --find --partscan --show fs.img sudo mkfs.btrfs /dev/loop0p1You should be able to skip the loop device stuff and work on an actual device instead. Seems to me the limit is somewhere between 64M and 128M.
Edit: But as edinbruh said, maybe try f2fs if it’s a flash device, that’s probably a bit more lightweight?! And since I don’t know what you’re doing… If it’s embedded stuff and you’re alright with read-only, you might want to use squashfs.
I got brtfs working on a different storage device but I can’t tell if I set it up properly or not. I’m using the documentation that another user posted but it’s a bit confusing to me and I need to test it more.
For my 128 MB sd card, I am trying f2fs because that’s working. It does seem to write much faster than it did with ext4 but it seems to take up more space and it now has about 25% less free space, and it doesn’t seem to compress files. I’ll have to do more testing before I determine whether this what I go with or not.
As for squashfs, I probably don’t want that.
Remember to enable compression. Usually the Arch Wiki is a great resource to learn stuff: https://wiki.archlinux.org/title/F2FS
And don’t forget to back up your data if you’re messing around with your computer. One typo with the device names is enough to accidentally delete your harddrive.
I figured out what I did wrong but now I’m getting a different error. It’s saying “Error: Wrong features compress_algorithm=zstd” even though the page you linked to specifies that that should be possible.
I tried to enable compression using the command they provide but it fails with an error saying “Error: Failed to get the device stat!”. Also, to make sure that I’m using the correct command line, how would I change the command they give to enable zstd as the compression method for all files.
I haven’t tried it. But looks to me you need to add “compression” when formatting it. And then later when mounting, you’d add options like
compress_algorithm=zstd,compress_extension=*I actually figure out the problem, I was actually supposed to just enable compression and then use the command when mounting. Only problem is, it’s not compressing the files even though I mounted it with zstd enabled. I know this because I’m using a file that’s slightly larger than the free space but it’s still giving errors about not having enough space.
Did you read the Wiki? You need to either pass the compress_extension option when mounting it. The Arch Wiki lists how to enable compression on all text files. And I gave you the version with a ‘*’, which enables compression for all files. Or you do a
chattr -R +c ...on specific files or directories to compress them. Maybe you missed that and that’s why it doesn’t compress?!There’s probably also a way to debug it and somehow figure out what it does and how many files/sectors got compressed on the filesystem. Linux usually buries that kind of information somewhere in /sys or /proc, or there’s special commands to figure it out. But I’m not really an expert on it.
And there’s also files which just can not be compressed any further because they’re already compressed. Most images, for example. Or music or ZIP archives. If you try to compress those, they’ll usually stay the same size.