System Administration Guide
Chapter 2, Administering filesystems

Removing empty directory slots

Removing empty directory slots

When files are deleted or moved to subdirectories in EAFS, AFS and S51K filesystems, ``empty directory slots'' (or ``shadow files'') are left. These empty slots can affect system performance by slowing down directory searches.


NOTE: In HTFS and DTFS filesystems, empty directory slots are merged automatically, so it is not necessary to remove them. Attempts to use the hd(C) command as described in this section will fail on HTFS and DTFS filesystems.

To determine if a directory contains empty slots, enter: 

hd . | wc -l
l | wc -l

These commands display the number of inodes and number of files in the directory listing. If the number of inodes is significantly more than the number of files in the directory, your system performance might be affected.

To view empty directory slots, enter: 

hd .

You see a listing like this:

0000	8c 17 2e 00 00 00 00 00  00 00 00 00 00 00 00 00   ................
0010	4e 1d 2e 2e 00 00 00 00  00 00 00 00 00 00 00 00   N...............
0020	00 00 54 4d 2e 32 33 35  37 35 2e 30 30 31 00 00   ..TM.23575.001..
0030	00 00 44 2e 63 68 6f 72  2d 61 63 35 38 39 66 31   ..D.chor-ac589f1
0040	00 00 58 2e 63 68 6f 72  2d 75 73 41 61 63 35 38   ..X.chor-usAac58
0050	00 00 44 2e 63 68 6f 72  2d 61 63 35 36 34 39 35   ..D.chor-ac56495
0060	00 00 58 2e 63 68 6f 72  2d 75 73 41 61 63 35 36   ..X.chor-usAac56
0070	00 00 43 2e 63 68 6f 72  2d 75 73 4e 33 32 32 61   ..C.chor-usN322a
0080	00 00 41 2e 63 68 6f 72  2d 75 73 4e 33 32 32 39   ..A.chor-usN3229
0090
The shadow files appear at the end of the list, and have null inode numbers; 00 and 00 appear in the first two columns of hex digits. In the example, all but the first two files are shadow files.

To remove these empty file slots from the directory:

  1. Change to the directory above the oversized one and create a backup directory. For example, to remove the empty slots from a spool directory (in this case, /usr/spool/uucp/pdxbox), enter these commands:

    cd /usr/spool/uucp
    mkdir pdxbox.old

  2. Move to the oversized directory and back it up with cpio(C):

    cd pdxbox
    find . -print | cpio -pdlm ../pdxbox.old

    This command copies the directory and all subdirectories to the backup directory, linking files instead of copying them where possible.

  3. Confirm that the files were copied and that the ownership, group, and permissions of the new directory and files match the original:

    cd ..
    l pdxbox pdxbox.old

  4. Use hd to check the backup directory to verify that all the empty slots are gone:

    hd pdxbox.old

    The output of this command should not list any files with null inode numbers (00 in the first two columns).

  5. Delete the original, oversized directory:

    rm -rf pdxbox

  6. Rename the backup directory to replace the oversized one:

    mv pdxbox.old pdxbox

The directory appears the same, but you can search it more quickly.

You can improve system performance by using this procedure on other working and spool directories.

See also: