automagic bind mounts

c0mputerking

Active Member
Oct 5, 2011
174
5
38
I would like to mount a host mount point on a guest os eery tiime it is restarted have found some scripts by googling around, and on these forums here http://wiki.openvz.org/Bind_mounts and http://newpush.com/2010/02/openvz-shared-directory-mounting-from-host-to-guest-systems/ here.

I have manual mounting working like this but of course i need this to stick each time the virtual machine is restarted.

mount --bind /usr/local/backups/backuppc /var/lib/vz/root/202/var/lib/backuppc

Here is a preposed 202.mount script edited to my needs think??? (im confused about the variables or if i need them) for one machine will it work and where do i put it?

#!/bin/bash
source /etc/vz/vz.conf
source ${VE_CONFFILE}
echo "Starting ${VEID}.mount..."
mount --bind /usr/local/backups/backuppc ${VE_ROOT}/var/lib/backuppc
echo "...${VEID}.mount complete"

Also this author suggests a 202.umount script
#!/bin/bash
source /etc/vz/vz.conf
source ${VE_CONFFILE}
echo "Starting ${VEID}.umount..."
umount ${VE_ROOT}/var/lib/backuppc
echo "...${VEID}.umount done"

PS i have started a post here http://computerking.ca/node/611 about making this work with a ct and backuppc here if anyone is interested hoever it is not finished yet. I will probably make it a seperate blog in the end too
 
To answer my own post i believe that the scripts go in /var/pve/conf havent had at chance to try this out yet but hopefully in the next couple of days
 
you need to save the CTID.mount scripts in /etc/pve/nodes/<yournodename>/openvz/

in this folder you have for example a 101.conf and then you can add a 101.mount script.
 
Thanks Tom i just got it working tested a reboot of host and the guest thing get mounted and unmounted correctly. I also just finished creating a clever post in this thread with my ugly scripts (not sure how to get variables working or if proxmox/openvz even uses them) however i must have pressed a wrong button somewhere as i do not see my clever post here now.

Anyways to summarize my post that got lost i managed to get things working i put these scripts in /var/vz/conf/202.mount
#!/bin/bash
source /etc/vz/vz.conf
#source ${VE_CONFFILE}
#echo "Starting ${VEID}.mount..."
echo "Starting 202.mount..."
#mount --bind /usr/local/backups/backuppc ${VE_ROOT}/var/lib/backuppc
mount --bind /usr/local/backups/backuppc /var/lib/vz/root/202/var/lib/backuppc
echo "...202.mount complete"

and /var/vz/conf/202.umount
#!/bin/bash
source /etc/vz/vz.conf
source ${VE_CONFFILE}
echo "Starting ${VEID}.umount..."
umount ${VE_ROOT}/var/lib/backuppc
echo "...${VEID}.umount done"

However i have taken your advice and moved the scripts to the more correct location of /etc/pve/nodes/<yournodename>/openvz/ to my suprise they were already there? must be an link or something?

mv 202.mount 202.umount /etc/pve/nodes/sun/openvz/
mv: `202.mount' and `/etc/pve/nodes/sun/openvz/202.mount' are the same file
mv: `202.umount' and `/etc/pve/nodes/sun/openvz/202.umount' are the same file

For testing what log to i watch to see these get mounted? /var/log/vzctr.log

As always thank you very much for your help
 
Last edited:
opps i have my umount script wrong it is now this
#!/bin/bash
source /etc/vz/vz.conf
#source ${VE_CONFFILE}
echo "Starting 202.umount..."
#umount ${VE_ROOT}/var/lib/backuppc
umount /var/lib/vz/root/202/var/lib/backuppc
#echo "...${VEID}.umount done"
echo "...202.umount done"
~
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!