Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been trying out the Btrfs with an SSD drive and like the compress option which is set in the fstab.

However this only applies to the files created after I have installed the operating system and modified the fstab file.

What I would like is to apply the compression to all the files on the system, to see if it improves boot time and application start up times.

Does anybody know of a way that I could apply the change to all files either pre or post installation?

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

I believe you have to run

btrfs fi defragment

after mounting the FS with compression.

Check this out: http://askubuntu.com/questions/129063/will-btrfs-automatically-compress-existing-files-when-compression-is-enabled

share|improve this answer
add comment

When installing you can issue a:

mount -o remount,compress=lzo

Often you will have to do it just as the installer starts installing stuff (maybe you will miss a file or 2. but no biggie). You could check to see if the installer has already mounted the filesystem just before the install stage.

Also make sure you update the /etc/fstab on the installed system. I use the following options that give some other improvements:

compress=lzo,ssd,relatime,space_cache,inode_cache,autodefrag

You can also try using compress-force=lzo for the install rather than compress=lzo, it makes sure that even files that don't compress that well are still compressed. That would make writes slower but since it's a one time install that might be worth it. But I'm not sure if it improves reads or not.

I have seen another way that involves renaming the mount.btrfs binary and replacing it with a script but when I did it under Ubuntu it messed up as it normally installs to subvolumes @ and @home but everything just got dumped to the root of the filesystem.

Alternatively you can install and then use the defragment, but you must defragment every file individually as the command isn't recursive. This could come in handy to upgrade to the new compression methods that are likely to appear in the newer versions of btrfs, snappy and lz4. Run the following from the / directory.

find -xdev -type f -exec btrfs fi defrag '{}' \;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.