*SOLVED* Umount action script problem [message #10715] |
Mon, 26 February 2007 23:29 |
mcarreira
Messages: 30 Registered: February 2007
|
Member |
|
|
I am trying to automate the access from VE to another disk using the "mount --bind" process.
I created two action scripts like these:
#/vz/sysconfig/vz-scripts/120.mount
#!/bin/bash
/bin/mount --bind /nova /vz/root/120/teste
exit $?
#/vz/sysconfig/vz-scripts/120.umount
#!/bin/bash
/bin/umount /vz/root/120/teste
exit $?
and they worked like I was expecing except for a little annoying behaviour:
If I start and stop VE several times, the mountpoint /nova is also unmounted.
Better explaining:
If I do for the first time:
# vzctl start 120
# vzctl stop 120
and then:
# ls -l /nova
I can see that the content list of "/nova" is still there.
But if I repeat the operation the "ls -l" don't show anything. Is empty, although /proc/mounts shows me that /nova is still mounted.
Is this a vzctl bug, or am I doing something wrong?
Thanks,
M.C.
[Updated on: Wed, 07 March 2007 07:30] by Moderator Report message to a moderator
|
|
|
|
|
Re: Umount action script problem [message #10813 is a reply to message #10802] |
Sun, 04 March 2007 08:08 |
|
Hi! I'm a user. I meet this problem too. I use GENTOO.
My solution for this problem:
1) do not use symlinks to /proc/mounts in VE0 and VE
Contents of /etc/mtab in VE
simfs / auto rw,noatime 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec 0 0
tmpfs /dev tmpfs rw,nosuid 0 0
devpts /dev/pts devpts rw,nosuid,noexec 0 0
none /dev/shm tmpfs rw 0 0
2) all binds are unmounted automatically when VE stops
Problem is in contents of VE0 /etc/mtab -- openvz do not edit this one when unmounts. Then there is global umount script which do not perform any real unmount. It only removes lines from /etc/mtab
/etc/vz/vps.umount
#!/bin/bash
# after stoping VE but before unmounting root area
#!!! all mounted on /vz/root/${VEID} FS are unmounted automaticaly
#echo vps.umount begin VEID=${VEID}
# umount /vz/root/${VEID}/usr/portage
# umount /vz/root/${VEID}/usr/portage-distfiles
# umount /vz/root/${VEID}/usr/portage-overlays
sed -i -e "\|^.* /vz/root/${VEID}/.* .*|d" /etc/mtab
#echo vps.umount end
true
exit ${?}
|
|
|
|
|
Re: Umount action script problem [message #10903 is a reply to message #10842] |
Tue, 06 March 2007 23:23 |
mcarreira
Messages: 30 Registered: February 2007
|
Member |
|
|
Thanks to Vasily precious help, the problem is corrected!
There are two critical points:
The script /vz/sysconfig/vz-scripts/120.mount must have the "-n" option, like:
#!/bin/bash
/bin/mount -n --bind /nova /vz/root/120/teste
exit $?
But the unmount script (/vz/sysconfig/vz-scripts/120.umount) MUST_NOT_EXIST!
I forgot that everything is unmounted during a shutdown.
Even with the "mount -n" option if the unmount script is used, we have problems after some more "start/stop".
M.Carreira
|
|
|