Go to the first, previous, next, last section, table of contents.


e2compress overview

e2compress compresses files directly into the format readable by the kernel on a second extended file system. Unlike `chattr +c', `e2compress' does the compression jobs in the user space. This may have some advantages. e2compress opens the file it is working on, and create a new temporary file (whose name is derived from the original file by adding suffix (`~z~' by default)) for which the automatic compression will be turned off. It then reads from the input file, compresses each cluster in memory, verifies the compression by decompressing to a work area and comparing with the original, and then writes the compressed data to the temporary file, using the lseek() system call to create the necessary holes as it goes. When it is done, automatic compression is turned on again for the temporary file, and the temporary file is renamed to replace the original file.

e2decompress is to e2compress as gunzip is to gzip: it is the same program invoked under a different name, whose default behaviour is to decompress rather than to compress.

When e2decompress or e2compress -d is called to decompress a file, we create a temporary file, remove the compression attribute, attempt to disable automatic decompression on the input file.

Using `e2compress' instead of `chattr +c' has some advantages. The main one is that the resulting file will not be fragmented as it would be with chattr: this comes from the fact that e2compress does not free some blocks as the kernel would do, but instead writes to a new file. Also, the compression is done in the user space. Some people may consider this better. e2compress is also more safe, since the compressed data is immediately checked for decompression.

One disadvantage of using e2compress is that the original file and the temporarily must coexist. This may be not possible if the file system is completely full. `chattr +c' will work even on a completely full file system.


Go to the first, previous, next, last section, table of contents.