On Wed, 3 Oct 2001, Ben Kennish wrote:

> Hi all,
> 
> It is my understanding that, in order to save disk space, certain files
> are hard linked between a skel and the VSs that are based upon it.  If
> that's true...

yup.. it's true

I think that the linking is also done to simplify the structure of both
the virtual servers and the freevsd concept itself.

> 
> i. Is it possible for a user of the VS to overwrite a file that is hard
> linked to the skel with their own version (assuming they have write
> access) - presumably this wouldnt overwrite the file in every VS that is
> based on this skel? Or would it?
> 

it would... 

any change made will be reflected immediately in all the files linked...

--to see something like this in action.... do this:

mkdir junk
touch one
ln one junk/two
echo 'I am file one' > one
cat one
cat two
echo 'but I am not one' > junk/two
cat one
cat two
mv junk/two junk/two-is-one
echo 'I just changed my name' > junk/two-is-one
echo 'I am really two now' > junk/two
cat one
cat junk/two
cat junk/two-is-one

Hope that gives you a general idea of how hard linking works!

BTW, this is one of the reasons why all those linked files are owned by
root and not by the admin, and part of the problem in regard of the
managing Perl modules on the virtuals (sometimes I think that would be
easier to have Perl not linked)
 

> ii. Is there any way to tell from the host server which files in a VS
> are linked to the skel and which are not?  I tried doing "ls -la" in
> "/home/vsd/vs/krusty" and beneath but couldn't find any indication that
> files were linked.
> 

the command you're looking for is

ls -li

using the example in i. :
 
$ ls -li one
 531528 -rw-r--r--    2 root     root           23 Oct  3 18:27 one
$ ls -li junk/two-is-one
 531528 -rw-r--r--    2 root     root           23 Oct  3 18:27 junk/two-is-one
$ ls -li junk/two
 547955 -rw-r--r--    1 root     root           20 Oct  3 18:27 junk/two

the first number is the inode number for the file (as you can see, one and
junk/two-is-one have the same number, while junk/two has another), and the
number before ownership reflects how many files share the same inode (in
other words.. anything over 1 shows that you have hard links of that
file).

(BTW.. I don't think there is any command that will show you where those
links are... short of building a database I can't think in any way to do
it... I hope somebody corrects me on this!)

a "dirty" way to see what's linked to what... in the vs's... could be
something like:

cd /home/vsd/vs/

ls -liR > all-the-files

sort all-the-files

then with

less all-the-files

you will be able to see your files sorted by inode...

if you want to know which are all of the other files that share an inode
with a given file (that are linked), you could do a simple sh or perl
script to get all the files with the same inode number when you input the
name of the file.

You did not explicitly ask... but, I see an implied question about
"unlinking" files... remember the command mv keeps the reference to the
same inode.... then *do not use mv* if your intention is to unlink.

the "safe" way to go is to cp the file (I would use cp -p) and then rm the
linked file, and then mv again the new cp file to the original name. 

BTW... I think that's safe to unlink most files in the vs's as long as you
don't touch the ones under /dev and /proc  (I would be very careful
anyway with all the files that are needed for glibc and file utils in
general... you could make your host server very insecure!).

in second thought.. think 10 times before you touch anything ;) (unless
you are working with a test server)

cheers!

Marcos


> 
> Thanks in advance,
> 
> 
> 
> Ben Kennish
> [EMAIL PROTECTED]
> www.fubra.com
> 
> ------------------------- The freeVSD Support List --------------------------
> Subscribe:   mailto:[EMAIL PROTECTED]?body=subscribe%20freevsd-support
> Unsubscribe: mailto:[EMAIL PROTECTED]?body=unsubscribe%20freevsd-support
> Archives:    http://freevsd.org/support/mail-archives/freevsd-support
> -----------------------------------------------------------------------------
> 


------------------------- The freeVSD Support List --------------------------
Subscribe:   mailto:[EMAIL PROTECTED]?body=subscribe%20freevsd-support
Unsubscribe: mailto:[EMAIL PROTECTED]?body=unsubscribe%20freevsd-support
Archives:    http://freevsd.org/support/mail-archives/freevsd-support
-----------------------------------------------------------------------------

Reply via email to