in reply to unlink : reclaim inodes, etc.?

When you unlink a file the filesystem should recover the associated disk blocks and inode. I'm assuming that you only want to remove some of the files and, possibly, directories based on some criterion or other. If this is the case, once you have completed your tidy-up you should run

fsck -n /dev/rdsk/c......

which will check the partiton without making any changes and give you some stats at the end including percentage fragmentation. If the fragmentation value is above single figures then consider doing a ufsdump of the partition, remaking it with newfs and doing a ufsrestore -rvf. It is extremely rare in my experience to need to do this.

If on the other hand you actually want to unlink all of the directories and files on the partition, don't bother, just newfs it.

I hope this is useful.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^2: unlink : reclaim inodes, etc.?
by camelcom (Sexton) on Oct 04, 2007 at 09:26 UTC
    The Unix sa here is saying that there is no benefit in doing a mv and re-creating the directory.

    I think JohnGG is saying the same.

    bruce is saying that there is a potential performance issue if I just delete the files (keeping the last 30 days files only) - as the directory file will still reflect the previous size?

    Any other views?

    Thanks

      When a directory is created on a Solaris 8 platform it has a size of 8k. If you add a lot of files to that directory then that 8k will get expanded to cope. If you then delete most of those files the directory will not shrink back to 8k which is what bruceb3 points out. However, we are only talking a few kilobytes here and you are probably not going to have lots of directories all with enough files to cause the expansion. So I agree with your SA that it's not going to gain you much. If you contemplate a filesystem where there are going to be huge numbers of very small files (or symlinks, perhaps) you may run out of inodes before you run out of data space so consider reducing the bytes per inode when making the filesystem with newfs. Conversely, if you have a files system that has just a few large files, perhaps database files, increase the bytes per inode, thus creating fewer inodes and leaving more space for data.

      Cheers,

      JohnGG

        A few kilobytes for 500,000+ files?

        I don't think so.

        # cd /var/tmp # mkdir lots-of-files # cd lots-of-files # perl -e 'for (1..500000) { { open my $f, ">poop.$_" } }' # cd /var/tmp # ls -ld lots-of-files drwxr-xr-x 2 szbrhv staff 10240000 Oct 5 10:01 lots-of-files

        That is 10 meg just for the directory, which might not be a concern with the large disks available but it's still a lot more than a few kilobytes.