truncating root directory of a file system

Philip Peake philip at axis.UUCP
Sun Dec 7 21:24:37 AEST 1986


In article <511 at cdx39.UUCP> jc at cdx39.UUCP writes:
>Well, there's a case where this doesn't work too well. 
>This is the root directory of a file system. 
>
>This is a root directory of a file system.  There are 
>about 75 directories under this one, so it only needs 
>to be about 1200 bytes in size.  Is there a way to shrink
>it down somewhat?
>
>On systems with the ftrunc() system call, there is an
>obvious solution.  Our SYS5 doesn't have ftrunc(), so
>there seems to be no way to do the job.  Or is there?

You can do it. It is a little complicated.

Basically, you move all of the entries in the directory to the first few slots.
You can do this by carefull use of link and rm.

If you really want to, you can do it with a standalone fsdb - just be
certain that you get it right !

Having done this, unless you really want to recover the block or two
of disc holding null entries, just leave things alone.
The only time the extra space will be scanned is when anyone gives a
full pathname which contains a non-existent first component - this should
be rare enough to ignore.

if you want the blocks back, use a standalone fsdb to remove the references
to the unused blocks at the end of the root directory inode list (set them
to zero).

Run fsck on the root to recover the blocks into the free list, and there
you are.

The best advice I can give it not to get into this situation in the
first place !

Philip



More information about the Comp.unix.wizards mailing list