Remove BTRFS compression

Hi All,

Can anyone recommend a certain way to convert all BTRFS compressed files in a filesystem to no compression?

I have switched the fstab to no compress and run a defrag but it does not remove compression from all files. This is also the case if i run a defrag while the drive is mounted from the install media so it is not just about files being open or locked for use.

Any suggestions?

The reason i want to try this is i had some really odd kernel hanging behaviour and when i removed compression on my brave .local files this resolved the issue. Id prefer to remove compression from the loop for now.

Does anyone know a handy tool or fancy command string i can make use of ? :smiley:

I don’t know of a way to remove compression. The defrag command can be used to add compression but it won’t remove compression.

If you have the free disk space you could rsync the data to a new uncompressed subvolume and then swap the subvols.

@dalto do you think something like the following could work?

compress --help
usage: compress [-h] [-r] [-v] [-d] [-V] target [target ...]

Tool which recursively compress files in a folder using btrfs transparent compression

positional arguments:
  target            File or folder that you want to compress

  -h, --help        show this help message and exit
  -r, --recursive   Recursively change all items in given path
  -v, --verbose     Change the program verbosity, by default program prints nothing unless there is some error
  -d, --decompress  Will remove compression flag and uncompress all files
  -V, --version     show program's version number and exit

Would this only work for user owned files/folders?

It looks like it just recursively calls chattr -c file on everything in a given path.

Then it copies every file to remove the compression.

I don’t see any reason it wouldn’t work although I think it would be faster to rsync to an uncompressed target if you have the free space to do it.

1 Like

Interesting both those seem decent ideas i’ll have a read into it.

Thanks both for the suggestions.


I did this about a month ago. After making the necessary changes in /etc/fstab and rebooting, I ran this (as root) on every subvolume:

btrfs filesystem defragment -rvf /path/to/subvol

I noticed a big change in space used almost right away. What was your command for defragging?

Simiar to that maybe without the -f

Try running:

sudo compsize -x /

on the path you removed from compression from. I still get:

Processed 613059 files, 232969 regular extents (343030 refs), 343176 inline.
Type Perc Disk Usage Uncompressed Referenced
TOTAL 78% 15G 20G 30G
none 100% 10G 10G 15G
zlib 48% 4.2M 8.8M 8.8M
lzo 52% 4.9G 9.3G 15G
zstd 48% 12M 25M 25M

I ended up booting into recovery, mounting the parent subvol, renaming the old subvol’s with


creating new subvol’s with the old names`

sudo btrfs subvolume create

and then running

rysnc -acxP

made sure it was all happy before i got rid of the old volumes.

ran a


on each subvol to tidy up.

that “compress” tool wasnt playing nicely so i got the rsync man page out.