On the Fly Compression for a Directory

compressionfilesystemsfusetar

I have a directory that is always going to be storing text files that are rarely (think weekly) used. Naturally this is a great place to use compression. However, rather than having to use tar ever time I want to access a file, I would love it if I could "mount a compressed folder".

Lets assume the folder is called mydir

Ideally the following should be true:

  • Items copied/moved/deleted/read in mydir without programs needing to know that the directory is compressed
  • When a file from mydir is read by a program, only that file is decompressed, not the entire directory.
  • The directory should be always available. (maybe mounted on boot or login)

Best Answer

If read-only access is acceptable, then SquashFS is a good choice.

However, it sounds like you want to be able to do in place updating as well. Btrfs may be an option for you. It is still considered somewhat experimental, but it does support transparent file compression, and is available to try in most distros.

The other approach is to do this in userspace, via FUSE. The most plausible of the options here is probably fusecompress.