OpenVZ Forum


Home » General » Support » Change VEID without recalculating quota :: vzmlocal openvz option
Change VEID without recalculating quota :: vzmlocal openvz option [message #20688] Tue, 25 September 2007 07:55 Go to next message
rickb is currently offline  rickb
Messages: 368
Registered: October 2006
Senior Member
Hello friends, I posted about this a few months ago but I can't find it; devs confirmed there was no solution right now but I think I am onto one.

problem:

I want to change the VEID without recalculating the quota. Naturally I change /vz/private/OLD to /vz/private/NEW, OLD.conf to NEW.conf, then start NEW. Vzctl then wants to calc the fresh quota as it should. I have tried to move /var/vzquota/OLD.quota to NEW.quota but the value OLD is stored in the binary quota file and thus is a corrupt NEW quota file.

solution:

I then remembered that the virtuozzo tool vzmlocal can rename a VE and does not require quota [re]calculation upon start. vzmlocal is a binary tool, does anyone know if it performs some replacement on the OLD.quota binary? If so, I am interested in doing this myself.

Any pointers or ideas on how to rename a VE without quota calc on openvz are appreciated.

Thanks!
Rick


-------------
Common Terms I post with: http://wiki.openvz.org/Category:Definitions

UBC. Learn it, love it, live it: http://wiki.openvz.org/Proc/user_beancounters

[Updated on: Tue, 25 September 2007 08:03]

Report message to a moderator

Re: Change VEID without recalculating quota :: vzmlocal openvz option [message #20762 is a reply to message #20688] Wed, 26 September 2007 05:05 Go to previous messageGo to next message
vaverin is currently offline  vaverin
Messages: 708
Registered: September 2005
Senior Member
Hello Rick,

When quota is enabled it watches the changes in VE private area. When quota is disabled any modification inside this subtree invalidates quota.

However you can move whole subtree of VE private area to any another place on the same filesystem (i.e. by using sys_rename for private area directory). In this case quota information will be still consistent.

In your scenario you have started VE too early. On VE start quota file has not been found (I mean NEW.quota file) and quota has been recalculated. Also I would note that each VE start modifies several files inside VE private area -- and it invalidates information in OLD quota file.

Could you please try to make the following steps:
1) move private area to any new place on the same filesystem
2) rename VE configuration file and correct VE_PRIVATE path
3) Don't forget to move quota file too.

Now your quota file is present and have correct information about new VE private subdirectory.

Then you can try to mount VE -- and I believe quota will be started without recalculation.

thank you,
Vasily Averin
Re: Change VEID without recalculating quota :: vzmlocal openvz option [message #20795 is a reply to message #20762] Wed, 26 September 2007 10:23 Go to previous messageGo to next message
rickb is currently offline  rickb
Messages: 368
Registered: October 2006
Senior Member
Thanks Vasily, I tried this (your procedure was what I naturally tried in the past as well). Below are the results.


[root@beast ~]# vzctl stop 1001
Stopping VE ...
VE was stopped
VE is unmounted
[root@beast ~]# mv /vz2/private/1001 /vz2/private/1002
[root@beast ~]# mv /etc/sysconfig/vz-scripts/1001.conf /etc/sysconfig/vz-scripts/1002.conf
[root@beast ~]# grep VE_PRIV /etc/sysconfig/vz-scripts/1002.conf
VE_PRIVATE="/vz2/private/$VEID"
[root@beast ~]# mv /var/vzquota/quota.1001 /var/vzquota/quota.1002
[root@beast ~]# vzctl start 1002
Starting VE ...
vzquota : (error) quota check : stat /vz2/private/1001: No such file or directory
vzquota on failed [1]
[root@beast ~]# grep 1001 /etc/sysconfig/vz-scripts/1002.conf
[root@beast ~]#


I believe this is the problem!:

[root@beast ~]# strings /var/vzquota/quota.1002 | grep 1001
/vz2/private/1001

I am wondering if vzmlocal modifies this quota file, I will test on virtuozzo.


-Rick


-------------
Common Terms I post with: http://wiki.openvz.org/Category:Definitions

UBC. Learn it, love it, live it: http://wiki.openvz.org/Proc/user_beancounters
Re: Change VEID without recalculating quota :: vzmlocal openvz option [message #20796 is a reply to message #20795] Wed, 26 September 2007 10:29 Go to previous message
rickb is currently offline  rickb
Messages: 368
Registered: October 2006
Senior Member
Yes this is definitely the key, see below:

[root@germanium ~]# md5sum /var/vzquota/quota.9889792
78f3b64633a22139dcd3834beb2bb2ef /var/vzquota/quota.9889792
[root@germanium ~]# vzmlocal 9889792:12345
Moving/copying VE#9889792 -> VE#12345, [], [] ...
Moving private area '/vz/private/9889792'->'/vz/private/12345'
done
Copying/modifying config scripts of VE#9889792 ...
done
Successfully completed
[root@germanium ~]# md5sum /var/vzquota/quota.12345
16288b19128a28c734370d3c50b36a4d /var/vzquota/quota.12345
[root@germanium ~]# strings /var/vzquota/quota.12345 | grep 12345
/vz/private/12345
[root@germanium ~]#


strace output:

write(1, "Copying/modifying config scripts"..., 49) = 49
stat64("/var/vzquota/quota.9889792", {st_mode=S_IFREG|0644, st_size=1365, ...}) = 0
open("/var/vzquota/quota.9889792", O_RDONLY) = 4
open("/var/vzquota/quota.12345", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 5
fstat64(4, {st_mode=S_IFREG|0644, st_size=1365, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4010c000
read(4, "\'\274\334\376\4\0\0\0\0\0\0\300\1\0\0\0\0\0\0\200\1\0"..., 8192) = 1365
read(4, "", 4096) = 0
read(4, "", 8192) = 0
fstat64(5, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4010d000
write(5, "\'\274\334\376\4\0\0\0\0\0\0\300\1\0\0\0\0\0\0\200\1\0"..., 1365) = 1365
close(5) = 0
munmap(0x4010d000, 4096) = 0
close(4) = 0


vzmlocal is a magical tool! Do you know how we can safely modify this binary file without vzmlocal?

Rick


-------------
Common Terms I post with: http://wiki.openvz.org/Category:Definitions

UBC. Learn it, love it, live it: http://wiki.openvz.org/Proc/user_beancounters

[Updated on: Wed, 26 September 2007 10:57]

Report message to a moderator

Previous Topic: Some VPS don't restart after HN reboot
Next Topic: Limiting multiple IP's with TC from Wiki
Goto Forum:
  


Current Time: Sat Apr 13 19:13:34 GMT 2024

Total time taken to generate the page: 0.01467 seconds