OpenVZ Forum


Home » General » Support » Why umount script runs on VE start?
Why umount script runs on VE start? [message #37795] Thu, 22 October 2009 15:15 Go to next message
cray is currently offline  cray
Messages: 11
Registered: October 2009
Junior Member
I have followed the instruction from wiki (http://wiki.openvz.org/Bind_mounts) and set up the mount and umount scripts. When I start the system I see the following error message:

vzctl start 101
Starting VE ...
umount: /home/vz/root/101/mnt: not mounted
Error executing umount script /etc/vz/conf/101.umount


Here are my scripts:
cat 101.mount
#!/bin/bash
mount --bind /test /home/vz/root/$VEID/mnt

cat 101.umount
#!/bin/bash
umount /home/vz/root/$VEID/mnt


Thanks for helping.
Re: Why umount script runs on VE start? [message #37796 is a reply to message #37795] Thu, 22 October 2009 15:23 Go to previous messageGo to next message
cray is currently offline  cray
Messages: 11
Registered: October 2009
Junior Member
I have also tried without the umount script, but it seems that it doesn't umount automatically. Here is the log:

host:/etc/vz/conf# vzctl start 101
Starting VE ...
VE is mounted
Adding IP address(es): 192.168.0.101
Setting CPU units: 1000
Configure meminfo: 65536
File resolv.conf was modified
VE start in progress...
---------------------------------------
host:/etc/vz/conf# mount -l | grep test
/test on /home/vz/root/101/mnt type none (rw,bind)
---------------------------------------
host:/etc/vz/conf# vzctl stop 101
Stopping VE ...
VE was stopped
VE is unmounted
---------------------------------------
host:/etc/vz/conf# mount -l | grep test
/test on /home/vz/root/101/mnt type none (rw,bind)
---------------------------------------
host:/etc/vz/conf# umount /home/vz/root/101/mnt
umount: /test: not mounted
umount: /home/vz/root/101/mnt: not found
umount: /test: not mounted
umount: /home/vz/root/101/mnt: not found
Re: Why umount script runs on VE start? [message #37797 is a reply to message #37795] Thu, 22 October 2009 15:28 Go to previous messageGo to next message
kir is currently offline  kir
Messages: 1645
Registered: August 2005
Location: Moscow, Russia
Senior Member

Perhaps your container was mounted (vzctl mount CTID to mount, vzctl status CTID to check if it's mounted or not). In that case vzctl umounts it first (vzctl umount) and then mounts again (vzctl mount) and then starts.

Kir Kolyshkin
http://static.openvz.org/userbars/openvz-developer.png
Re: Why umount script runs on VE start? [message #37798 is a reply to message #37797] Thu, 22 October 2009 15:38 Go to previous messageGo to next message
cray is currently offline  cray
Messages: 11
Registered: October 2009
Junior Member
I'm quite confused with your explanation. Can you advice a solution?
Re: Why umount script runs on VE start? [message #37799 is a reply to message #37796] Thu, 22 October 2009 15:38 Go to previous messageGo to next message
kir is currently offline  kir
Messages: 1645
Registered: August 2005
Location: Moscow, Russia
Senior Member

cray wrote on Thu, 22 October 2009 19:23

host:/etc/vz/conf# mount -l | grep test
/test on /home/vz/root/101/mnt type none (rw,bind)
---------------------------------------
host:/etc/vz/conf# umount /home/vz/root/101/mnt
umount: /test: not mounted
umount: /home/vz/root/101/mnt: not found
umount: /test: not mounted
umount: /home/vz/root/101/mnt: not found[/code]


As you can see, there is a discrepancy here -- "mount -l" output shows that test is mounted, while "umount" is not able to unmount it.

This discrepancy is caused by the fact that mount/umount has a build-in functionality to add/remove mount records to the /etc/mtab file, and "mount -l" just lists those records. This add/remove behavior can be disabled using -n option, check mount/umount man pages for details. So if you mount without using -n and then umount with -n you will get this.

To see if something is mounted for real, one need to look into /proc/mounts file.


Kir Kolyshkin
http://static.openvz.org/userbars/openvz-developer.png
Re: Why umount script runs on VE start? [message #37800 is a reply to message #37798] Thu, 22 October 2009 15:42 Go to previous messageGo to next message
kir is currently offline  kir
Messages: 1645
Registered: August 2005
Location: Moscow, Russia
Senior Member

cray wrote on Thu, 22 October 2009 19:38
Can you advice a solution?


Sure, make the umount script always return 0, i.e. add something like
true

or
exit 0

to the end of the umount script.

And be consistent with using -n -- either use it in both script or not use it at all.


Kir Kolyshkin
http://static.openvz.org/userbars/openvz-developer.png
Re: Why umount script runs on VE start? [message #37801 is a reply to message #37799] Thu, 22 October 2009 16:42 Go to previous messageGo to next message
cray is currently offline  cray
Messages: 11
Registered: October 2009
Junior Member
What about the -n option, I doesn't use it in both scripts.

exit 0 didn't help me.

I assume that mount/umount scripts should work this way:

start VE
mount /path/from /path/to
-------------------------
umount /path/to
stop VE
Re: Why umount script runs on VE start? [message #37802 is a reply to message #37801] Thu, 22 October 2009 16:47 Go to previous messageGo to next message
kir is currently offline  kir
Messages: 1645
Registered: August 2005
Location: Moscow, Russia
Senior Member

cray wrote on Thu, 22 October 2009 20:42
What about the -n option, I doesn't use it in both scripts.


From another topic by you I see that you have used it, see this message.

Quote:
exit 0 didn't help me.


What do you mean «didn't help»? Can you describe one more time what problem are you having?

Quote:
I assume that mount/umount scripts should work this way:

start VE
mount /path/from /path/to
-------------------------
umount /path/to
stop VE


They do not work this way -- mount is happening *before* CT start, while umount is happening *after* CT stop. Plus, as I described above, umount is run on start if CT is mounted.


Kir Kolyshkin
http://static.openvz.org/userbars/openvz-developer.png
Re: Why umount script runs on VE start? [message #37803 is a reply to message #37802] Thu, 22 October 2009 16:56 Go to previous message
cray is currently offline  cray
Messages: 11
Registered: October 2009
Junior Member
kir wrote on Thu, 22 October 2009 12:47
cray wrote on Thu, 22 October 2009 20:42
What about the -n option, I doesn't use it in both scripts.


From another topic by you I see that you have used it, see this message.


I have removed -n key, as I didn't see the mounts.

kir wrote on Thu, 22 October 2009 12:47

Quote:
exit 0 didn't help me.


host:~# vzctl start 101
Starting VE ...
VE is mounted
Adding IP address(es): 192.168.0.101
Setting CPU units: 1000
Configure meminfo: 65536
File resolv.conf was modified
VE start in progress...
host:~# vzctl stop 101
Stopping VE ...
VE was stopped
umount: /test: not mounted
umount: /test: not mounted
VE is unmounted
host:~#




here is the cat of mount/umount scripts:

cat 101.mount
#!/bin/bash
mount --bind /test /home/vz/root/$VEID/mnt

cat 101.umount
#!/bin/bash
umount /home/vz/root/$VEID/mnt
exit 0



kir wrote on Thu, 22 October 2009 12:47
What do you mean «didn't help»? Can you describe one more time what problem are you having?

Quote:
I assume that mount/umount scripts should work this way:

start VE
mount /path/from /path/to
-------------------------
umount /path/to
stop VE


They do not work this way -- mount is happening *before* CT start, while umount is happening *after* CT stop. Plus, as I described above, umount is run on start if CT is mounted.


Well, if umount script starts when the VE is stoped, so it can not unmount the path, as root directory of the VE is unmounted. Am I right?

P.S. What is CT? Is it VE (virtual environment)?

[Updated on: Thu, 22 October 2009 16:59]

Report message to a moderator

Previous Topic: *SOLVED* OpenVZ mount script works incorrectly
Next Topic: routing tables with openvz container
Goto Forum:
  


Current Time: Sun Apr 28 14:31:57 GMT 2024

Total time taken to generate the page: 0.02364 seconds