I chose btrfs as the format of my /
filesystem in the Ubuntu 12.04 LTS installer. After the installation completed, I added compress=lzo
to the mount options in /etc/fstab
and rebooted.
Will the existing files be automatically compressed now, or must I explicitly do something to cause that to happen?
You will have to run
btrfs fi defragment
to force recompression of existing data. Otherwise, only new data will be compressed.From the FAQ:
I've made what Norbert Fabritius said, but I didn't notice any compression in the existing files - df -h / before btrfs fi defragment = 658MB | df -h / after btrfs fi defragment = 658MB. New files are ok. Searching a little bring me this quote:
After this, my / it's occupping 656MB - nothing huge, but certainly there is compression.
Source: https://btrfs.wiki.kernel.org/index.php/Problem_FAQ#Defragmenting_a_directory_doesn.27t_work
According to Oracle's documentation, you can compress existing files on an existing, online filesystem by defragmenting each file in it with the -c, -clzo, or -czlib options. LZO is recommended for speed.
This uses the find command to run the btrfs defragmenter on every file in the root filesystem (given by the slash right after the "find" command at the beginning). If you have other subvolumes, you can use it again with the path of a subvolume (I have one at /home, for example) instead of the single slash.
You'll need root privileges for this, so add sudo to the front if you need to.
See:
According to https://btrfs.wiki.kernel.org/index.php/Mount_options#List_of_options following compression algorithms are available:
Note: This post is answer for the additional question what type of compression algorithms are available which was asked below...so please don't blame me.
According to ArchWiki:
Very nice! God bless BTRFS!
Also, from the BTRFS wiki: