User`s guide

Managing Resources 100
Moving Container Files to the Cache Area
We will illustrate the effect produced by vzcache by copying one and the same huge dummy
file into two Containers. First, let us learn the disk space occupied by the whole /vz partition
and by the two Containers - Container 101 and Container 102:
# df /vz
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda3 13756796 1348292 11622123 11% /vz
# pctl exec 101 df
Filesystem 1K-blocks Used Available Use% Mounted on
vzfs 1048576 22311 1026265 3% /
# pctl exec 102 df
Filesystem 1K-blocks Used Available Use% Mounted on
vzfs 1048576 22311 1026265 3% /
After that, we copy the dummy file, which is around 600 MB in size, to the root of these
Containers:
# cp foo /vz/root/101
# cp foo /vz/root/102
Now check the disk space once again:
# df /vz
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda3 13756796 2569060 10401355 20% /vz
# pctl exec 101 df
Filesystem 1K-blocks Used Available Use% Mounted on
vzfs 1048576 632430 416146 61% /
# pctl exec 102 df
Filesystem 1K-blocks Used Available Use% Mounted on
vzfs 1048576 632430 416146 61% /
We see that around 600 MB has been added to the space occupied by each Container and,
consequently, around 1.2 GB has been added to the space used on the /vz partition. Now it's
time to resort to vzcache to get rid of identical files inside the Containers:
# vzcache -v 101 102
Processing VZFSv2 Container 101
VZFSv2 Container 101 78 regular files
Processing VZFSv2 Container 102
VZFSv2 Container 102 78 regular files
During the command execution, vzcache does the following:
Looks for identical files inside Container 101 and Container 102.
Creates the CT_UUID subdirectory (where CT_UUID denotes the Container unique
identifier and can be determined by viewing the UUID parameters in the Container
configuration file) within the server template area (/vz/template/vc by default) for
each Container.
Moves the identical files to the created subdirectories in the server template area.
Let us now take the final look at the disk space usage:
# df /vz
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda3 13756796 1953053 11017362 16% /vz
# pctl exec 101 df
Filesystem 1K-blocks Used Available Use% Mounted on
vzfs 1048576 15105 1033471 2% /
# pctl exec 102 df
Filesystem 1K-blocks Used Available Use% Mounted on
vzfs 1048576 15138 1033438 2% /