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

How to dispense with indirect cluster bitmap blocks

Since defragmenters aren't friendly to indirect cluster bitmap blocks, you may wish to know what to do with existing large files so that they don't need an indirect cluster bitmap block.

Note: All example commands in this node assume the presence of `/tmp/bigpaths' as created by the example in the previous section.

If you have enough space, then the easiest method is just:

xargs -0 chattr -c < /tmp/bigpaths;
xargs -0 lsattr < /tmp/bigpaths

(We run lsattr just to check whether or not there was enough space to decompress them; see section How do I see if a file has not been decompressed?, for details.)

The next easiest method is to put them into a compressed tar file that you put onto another device:

xargs tar cSf - < /tmp/bigpaths | gzip -9 > wherever

If you can't do that, then try gzipping each file one by one: gzip deletes the original as soon as the compressed version has been written.

xargs -0 -i, find , \( \
 -links 1 \( \
   -path '*.gz' -exec chattr -c '{}' \; \
   -o \! -path '*.gz' -print0 \) \
 -o -links +1 -fprintf /dev/stderr \
  'warning: not handled file "%p" (inode %i) with %n links\n' \
\) < /tmp/bigpaths > /tmp/bigpaths_gz && 
xargs -0 gzip -9 < /tmp/bigpaths_gz &&
tr \\0\\n \\n\\0 < /tmp/bigpaths_gz | sed 's/$/.gz/' | tr \\0\\n \\n\\0 |
xargs -0 chattr -c

(Note: the above hasn't yet been tested, so have a look at it before running it. Just post a note to the e2compr mailing list (see section URLs usw. relevant to e2compr.) to give the rest of us confidence and so that the maintainer of this documentation can make an appropriate note here.)

The above doesn't attempt to gzip files whose names already end in `.gz', by the way.

The names of files with multiple links (see section Links) are just echoed to stderr (i.e. displayed on the screen). gzip doesn't handle files with multiple links, but tar does, so just create a gzipped tar file of the links to each inode, delete the originals, and `chattr -c' the gzipped tar files. (Writing this as a script that deletes the originals of one file before starting to compress the next, while handling file names with embedded newlines, was too much brain strain for me, sorry. I think it could be done by getting find to print the inode number, getting the filesystem from running df on the file, sorting and uniqing the results as inum--mountpoint pairs, using sed to construct a `find' command to pipe to xargs to tar then rm... it's not worth it.)

If you know of a tar option that unlinks the original files as soon as they have been written to the archive, then it would make all this a lot easier.

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