Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've finally found how to enable compression in btrfs, and would like to do so. However, as my main drive, I'm not really wanting to risk a change that could corrupt the hard drive.

Everything I've read indicates that these options are safe to change, as they only apply on new writes, but I'd like some more assurance...

Can I have a rough explanation on how the compression algorithm works? Is it per file (as I think it has to be?)

After this is on, what options/commands are there to recompress the hard drive?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I can only answer with the available information in the different related btrfs sites. As you say, using compression is relatively safe as compression is only applied to the new written content. As per the stability of the FS, it is still in testing stage, although it seems to be pretty stable right now. About recompressing the whole disk, I'm not sure you can do it (I haven't seen it). It shouldn't be difficult to write such tool. Right now the obvious way is to copy/move the data from the partition to other disk/partition, and then re-copying, but it implies having enough space in another disk or partition to do the copy (and a fair amount of time)...

share|improve this answer
add comment

You can initiate a compression of a btrfs file system that has files written when it was mounted without compression by triggering a defragment:

sudo btrfs fi defragment /path

Note that path can be a directory or file within a btrfs volume, you don't need to do the whole thing at once. So you could target folders that contain highly compressible files, such as documents, ahead of folders that contain files that do not compress well, such as images, audio, video, and compressed archives (zip etc).

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.