du /vservers/ref du /vservers/new
The du command produced the same result. Not saving much disk space ?
The du" command is not the right tool to test this. One easy way to test is to run df before and after the new vserver creation. This will show the exact amount of disk space allocated to the new vserver. Here is the explanation:
Unification is made using hard links. A hard link is another name pointing to the same data. The entity controlling the mapping of a file on a Unix/Linux file system is called an inode. It contains information about the file location (the blocks making the file), the access right and ownership, and a few other flags. The name is not stored in the inode itself. A directory contains a list of names. Each name points to an inode. The inode also hold a reference counter so it knows how many directory entries point to itself. From this explanation, you see that a file name points to inode, and does not relate to any other name pointing to the same inode. All we can tell is how many names are pointing to the same inode. Finding which names point to a single inode involves a complete file system traversal, opening every directory to find a name pointing to the given inode.
Here is a little demonstration:
cd /tmp # We create a dummy file and see which inode number it has touch dummy ls -i dummy # The number printed is the inode number # Now we create a link to this file ln dummy dummy2 # Now we check that the reference count is 2 since # both dummy and dommy2 points to the same inode ls -l dummy2 # What is the inode of dummy2 ls -i dummy2 # The same as dummy.
What is the point ? We have two files, dummy and dummy2, each pointing to the same inode. Which one is the real file ? Anyone is the real. I can delete dummy and dummy2 will continue to exist unchanged. I can delete dummy2 and dummy will continue to exist. If I delete both, then the space allocated will be freed.
Back to our du utility
du dummy du dummy2
We are getting the same result. The command do not care about the reference count. dummy2 is as real as dummy. Applied to a unified vserver, we get the same result on the original and new. For the du command, neither is more the owner of the files. This also shows how independent are two unified vservers. They are sharing the same data space, yet they are truly independent. Package may be updated in one and it won't affect the other. The vserver ref may be delete and this won't affect the new vserver.
Sometime, it is useful to find how much disk space is used by one vserver alone. The /usr/lib/vserver/vdu utility was written for this purpose. It works like du (a minimal one) except it ignores files with more than one link. Hard links are seldom used in a vserver, so the is rather precise. vdu will indeed show that your new vserver is not so big after all. But if you apply it to the ref vserver, you will get the same (small) result.