Re: [Vserver] clean-up hash directory

From: Corey Wright <undefined_at_pobox.com>
Date: Fri 08 Sep 2006 - 13:46:12 BST
Message-Id: <20060908074612.66d691e8.undefined@pobox.com>

On Fri, 08 Sep 2006 06:46:17 +0200
Daniel Hokka Zakrisson <daniel@hozac.com> wrote:

> Roderick A. Anderson wrote:
> > Corey Wright wrote:
> >
> >> i was curious if vhashify cleaned up after itself (delete orphaned
> >> instances of files in hash directory), and it appears it doesn't.
> >> these commands should do the job. well, technically this just lists
> >> files with a
> >> hardlink count of 1 and prints the total size in bytes of all listed
> >> files
> >> on the last line (so you know how much space you are saving).
> >>
> >> find /etc/vservers/.defaults/vdirbase/.hash/ -type f -printf "%n %s
> >> %p\n" |
> >> grep '^1[[:space:]]' | awk '{ sum += $2; print $3 } END { print sum }'
>
> You could easily eliminate the grep by using -links 1 in the find command.

thanks. guess i didn't see that in the man page (and i've never had reason
to mess with hardlinks before, especially using find).

> >> to delete those listed files, add to the end:
> >> | while read FILE; do rm -f ${FILE}; done
>
> Would be far more efficient to use -print0 | xargs -0 rm -f.

correct, but that would have required me to offer two commands:
- one for calculating total size of all orphaned hardlinks (people, me
included, like to see the effects of what they are doing quantified for
purposes of justification and "warm fuzzies")
- another for deleting orphaned hardlinks

not an issue for me or hopefully most people, but i wanted to keep my
instructions as simple as possible (and just adding another piped command
is easiest as it simply builds upon what was already instructed). i try to
keep it KISS (Keep It Simple, Stupid) when dealing with people (the entire
mailing list) of unknown experience levels.

of course, also make sure you don't have a file in the current directory
named the same as the total size (in bytes) of all the orphaned hardlinks
or that file will be deleted (as it is the last line printed by awk), but i
didn't worry about that as the statistical odds are pretty low. when i sent the
email i wondered if anybody was going to reply noting that, so i already
had this response ready. :-D

so yeah, my suggested commands are not "production quality". ;-)

> > Did you hear anything on this? I ran the query on a 12+ guest system (
> > all FC5 ) and it ran for well over a couple of minutes before I got
> > tired of watching the output. This leads me to think I've got lots of
> > orphans. I'd like to get rid of them ( Save the inodes! ) but want to
> > understand what I'm doing first. Rather not fubar a live system.
>
> This should be a perfectly safe command, I always run some cleanup after
> hashifying my guests.

i hashify my guests daily as part of a daily-maintenance cron job as i
often forget after installing/upgrading a package and my vserver is not too
heavily loaded. i might toss this in there too.

> > I'm not sure I fully understand how vhashify works. Where are the
> > actual files located. Are the entries in
> > /etc/vservers/.defaults/vdirbase/.hash/
> > links to the actual files and then each guest links to these -- links?
>
> Those would be the actual files (the file in the .hash directory is
> created by vhashify as a copy of the file it's hashifying), and vhashify
> then creates links to those in the guest(s).

roderick, if daniel's explanation is too succinct for you, i can reference
a few of my prior postings where i ramble on forever trying to stumble
through my own hypothesizing of how hashifying works. ;-)

thanks daniel. your expert knowledge on vserver is always welcomed and
appreciated (no matter how bad it makes me look).

corey

-- 
undefined@pobox.com
_______________________________________________
Vserver mailing list
Vserver@list.linux-vserver.org
http://list.linux-vserver.org/mailman/listinfo/vserver
Received on Fri Sep 8 13:47:52 2006
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Fri 08 Sep 2006 - 13:47:57 BST by hypermail 2.1.8