OpenVZ Forum


Home » General » Support » Prevent unmount inside VE
Prevent unmount inside VE [message #10137] Fri, 09 February 2007 10:50 Go to next message
Kakihara is currently offline  Kakihara
Messages: 6
Registered: January 2007
Junior Member
Hi

I run several VE`s and mount some Directorys outside the VE via mount --bind to access them.
Inside the VE the Root could unmount this.

Example:

root@hn:/# mount --bind /mnt/ /vz/root/100/mnt/
root@hn:/# vzctl enter 100
root@ve:/# cat /proc/mounts
simfs / simfs rw 0 0
ext3 /mnt ext3 rw,data=ordered 0 0
root@ve:/# umount /mnt/ <---- Works
root@ve:/# exit
root@hn:/# mount
/dev/sda1 on / type ext3 (rw,errors=remount-ro)
/mnt on /var/lib/vz/root/100/mnt type none (rw,bind) <-- This Information is not updated.

How could I prevent this ?
Re: Prevent unmount inside VE [message #10139 is a reply to message #10137] Fri, 09 February 2007 11:18 Go to previous message
Vasily Tarasov is currently offline  Vasily Tarasov
Messages: 1345
Registered: January 2006
Senior Member
Hello,

Yes, VE root can do almost everything in VE, including umounting bind-mounted directories.

I offer you the solution I use, but there can be more smart solutions.

The essence of the soulution is to make directory, to which bind-mount is produced _busy_ from VE0. In your case:


root@hn:/# mount --bind /mnt/ /vz/root/100/mnt/
root@hn:/# cd /vz/root/100/mnt/ <--- this makes bind-mount busy
root@hn:/# vzctl enter 100
root@ve:/# cat /proc/mounts
simfs / simfs rw 0 0
ext3 /mnt ext3 rw,data=ordered 0 0
root@ve:/# umount /mnt/ <---- doesn't work
umount: /mnt: device is busy
umount: /mnt: device is busy
root@ve:/# exit

By various ways it can be automatized.

As concerns redudant information that `mount` still shows in your example,
this is because it gets information from /etc/mtab on HN, which is of course not updated when umounting in VE occurs. This can be prevented by bind-mounting with -n option.

HTH,
Vasily
Previous Topic: VPS dies
Next Topic: 2.6.18-ovz028test015.1-enterprise
Goto Forum:
  


Current Time: Sat Aug 03 20:25:05 GMT 2024

Total time taken to generate the page: 0.02624 seconds