OpenVZ Forum


Home » Mailing lists » Users » post-start and stop scripts
post-start and stop scripts [message #25814] Wed, 09 January 2008 10:55 Go to next message
Jakob Goldbach is currently offline  Jakob Goldbach
Messages: 14
Registered: January 2008
Junior Member
From: openvz.org
Hi,

I've seached the docs in vain on executing scripts on start or stop of
the VE.

I'm doing a bind mount on the HN to the mounted VE
($VZROOT/root/101/mnt/..)  as descriped in 
http://wiki.openvz.org/Mounting_filesystems. 

I want to automate this during start and stop of the VE. 

Ideally the start script should run after the VPS is mounted but before
it is started. Likewise during stop - an umount after the VPS has
stopped but before it is umounted.

Is this possible ?

/Jakob

# vzctl start 222
Starting VPS ...
VPS is mounted
--> start hook here <---
Adding IP address(es): 172.16.4.9
Setting CPU units: 1000
Set hostname: test1
VPS start in progress...


# vzctl stop 222
Stopping VPS ...
VPS was stopped
--> stop hook here <-- 
VPS is unmounted
Re: post-start and stop scripts [message #25815 is a reply to message #25814] Wed, 09 January 2008 12:04 Go to previous messageGo to next message
Thorsten Schifferdeck is currently offline  Thorsten Schifferdeck
Messages: 38
Registered: February 2006
Member
From: openvz.org
Hello Jakob,

please read the OpenVZ User Guide, at page 88 "OpenVZ Action Scripts".

Bye,
 Thorsten

Am Mi, 9.01.2008, 11:55, schrieb Jakob Goldbach:
> Hi,
>
> I've seached the docs in vain on executing scripts on start or stop of
> the VE.
>
> I'm doing a bind mount on the HN to the mounted VE
> ($VZROOT/root/101/mnt/..)  as descriped in
> http://wiki.openvz.org/Mounting_filesystems.
>
> I want to automate this during start and stop of the VE.
>
> Ideally the start script should run after the VPS is mounted but before
> it is started. Likewise during stop - an umount after the VPS has
> stopped but before it is umounted.
>
> Is this possible ?
>
> /Jakob
>
> # vzctl start 222
> Starting VPS ...
> VPS is mounted
> --> start hook here <---
> Adding IP address(es): 172.16.4.9
> Setting CPU units: 1000
> Set hostname: test1
> VPS start in progress...
>
>
> # vzctl stop 222
> Stopping VPS ...
> VPS was stopped
> --> stop hook here <--
> VPS is unmounted
>
>
-- 
Thorsten Schifferdecker
email ts@systs.org
phone +49 (0) 911 50 63 69 82
Re: post-start and stop scripts [message #25862 is a reply to message #25815] Wed, 09 January 2008 20:09 Go to previous messageGo to next message
Jakob Goldbach is currently offline  Jakob Goldbach
Messages: 14
Registered: January 2008
Junior Member
From: openvz.org
On Wed, 2008-01-09 at 13:07 +0100, Thorsten Schifferdecker wrote:
> 
> please read the OpenVZ User Guide, at page 88 "OpenVZ Action Scripts".
> 

Yes! - sorry for not seeing this on first read..

Bind mounting works fine during start, but umounting on stop fails.
umount just boils down to a 'umount -v <mountpt>'.

See transcript and full mount/umount script below. 

What am I missing here ? 

I'm using 2.6.18-ovz-028stab051.1 (x86_64) with vzctl version
3.0.22-1dso1

/Jakob





HN:~# vzctl start 222
Starting VE ...
/bin/mount -v --bind /mnt/test /var/lib/vz/root/222/mnt/bindmpt
/mnt/test on /var/lib/vz/root/222/mnt/bindmpt type none (rw,bind)
VE is mounted
Adding IP address(es): 172.16.4.9
Setting CPU units: 1000
Configure meminfo: 35000
Set hostname: test1
VE start in progress...

HN:~# mount
[snip]
/mnt/test on /var/lib/vz/root/222/mnt/bindmpt type none (rw,bind)

HN:~# vzctl stop 222
Stopping VE ...
VE was stopped
/bin/umount -v /var/lib/vz/root/222/mnt/bindmpt
could not umount /var/lib/vz/root/222/mnt/bindmpt - trying /mnt/test
instead
umount: /mnt/test: not mounted
could not umount /var/lib/vz/root/222/mnt/bindmpt - trying /mnt/test
instead
umount: /mnt/test: not mounted
Error executing umount script /etc/vz/conf/222.umount

HN:~# vzlist -a
  VEID      NPROC STATUS  IP_ADDR    HOSTNAME                        
  222          - mounted 172.16.4.9  test1
Re: post-start and stop scripts [message #25864 is a reply to message #25862] Wed, 09 January 2008 22:25 Go to previous messageGo to next message
Jakob Goldbach is currently offline  Jakob Goldbach
Messages: 14
Registered: January 2008
Junior Member
From: openvz.org
> Bind mounting works fine during start, but umounting on stop fails.

I found the problem. The mountpoint in the VE got umounted by Debians
umountfs script during shutdown of the VE. 

I didn't realize that a VE had permission to umount.

/Jakob
Re: post-start and stop scripts [message #25879 is a reply to message #25864] Thu, 10 January 2008 08:07 Go to previous messageGo to next message
vaverin is currently offline  vaverin
Messages: 692
Registered: September 2005
Senior Member
From: *sw.ru
IMHO nothing strange: if the filesystems is visible inside VE it can be unmounted from inside VE too.
Re: post-start and stop scripts [message #25880 is a reply to message #25879] Thu, 10 January 2008 08:13 Go to previous message
vaverin is currently offline  vaverin
Messages: 692
Registered: September 2005
Senior Member
From: *sw.ru
Probably following thread will be useful for You:
http://forum.openvz.org/index.php?t=msg&goto=15183&& amp;srch=could+not+umount#msg_15183

it explains why we recommend to use "-n" option for mount commands inside ve.mount scripts and do not use ve.umount script at all.

thank you,
Vasily Averin
Previous Topic: Security risks in ve_allow_kthreads
Next Topic: Debuginfo-package for kernel-ovz
Goto Forum:
  


Current Time: Sat Sep 21 23:31:48 GMT 2019