0

I am running proxmox 2.3

Since I installed proxmox on a new server I definitely can't use mount and unmount script on a container and I don't know why. Proxmox just doesn't read those scripts.

Here are the 2 scripts with +x rights :

[root@prox /etc/vz/conf]$ l total 16K
-rwxr-xr-x 1 root root 180 May  6 03:03 100.mount
-rwxr-xr-x 1 root root 145 May  6 02:44 100.umount
-rwxr-xr-x 1 root root  97 May 11 19:00 103.mount
-rwxr-xr-x 1 root root  89 May 11 18:52 103.umount

I simplified the scripts to the most.

103.mount :

#!/bin/bash
. /etc/vz/vz.conf
. ${VE_CONFFILE}

mount --bind /mnt/share /var/lib/vz/root/103/mnt

103.umount :

#!/bin/bash
. /etc/vz/vz.conf
. ${VE_CONFFILE}

umount /var/lib/vz/root/103/mnt/

exit 0

If I restart the contener 103 :

[root@prox /etc/vz/conf]$ vzctl --verbose restart 103
Restarting container
Stopping container ...
Container was stopped
Container is unmounted
Starting container ...
Container is mounted
Running container script: /etc/vz/dists/scripts/debian-add_ip.sh
Setting CPU units: 1000
Setting CPUs: 1
Running container script: /etc/vz/dists/scripts/debian-set_hostname.sh
Running container script: /etc/vz/dists/scripts/set_dns.sh
Running container script: /etc/vz/dists/scripts/set_ugid_quota.sh
Configure veth devices: veth103.0
Adding interface veth103.0 to bridge vmbr2 on CT0 for CT103
Container start in progress...
[root@prox /etc/vz/conf]$

Here we see that proxmox didn't read the 103.mount.. If I enter in the conterner, the directory "share" is not mounted.

So I tried the command line directly in my shell :

mount --bind /mnt/share /var/lib/vz/root/103/mnt

... and it works. I also tried "mount -n --bind" and so other things... I'm run out of ideas.

So, if you have any suggestions as to how I can fix this. Thanks!

Florent
  • 31
  • 1
  • 5

2 Answers2

1

Since the same question was also asked on the Proxmox forums, I chimed in there, but in order to help others here, I wanted to mention my response here as well.

The gist of the post is that your system may not be set up properly for the scripts to be found, much less called. Specifically, the /etc/vz/conf directory should be a symlink to /etc/pve/openvz - which, since that's where Proxmox also stores your VM configuration files, doesn't seem to be the case (based on the output of ls given above...). Moving the scripts to /etc/pve/openvz should do the trick, and removing /etc/vz/conf and replacing it with a symlink to /etc/pve/openvz can help you keep things straight in your own head.

Dan Hunsaker
  • 131
  • 3
0

This is what I use and it seems to work:

In 146.mount:

#! /bin/bash
VEID=146
SRC=/mnt/nfs
VE_ROOT=/var/lib/vz/root/${VEID}

MPS="/u/tools /u/homes /u/releases /f"
for mp in $MPS; do
    if [ ! -e ${VE_ROOT}${mp} ]; then mkdir -p ${VE_ROOT}${mp}; fi
    mount -n --bind ${SRC}${mp} ${VE_ROOT}${mp} -o ${SRC}
done

MPS lists the mount points that are mounted under /mnt/nfs (SRC), they will get bind mounted to the root of the container. I added these directly to /etc/fstab so they would always be mounted on the VM host.

I had planned to genericize this by calculating VEID from the basename of the file, but moved away from using OpenVZ in favor of KVM before finishing that work. Something like this would probably work:

VEID=`basename $0 .mount`

and would allow using the exact same mount file for all VZs, but has not been tested by me.

Could probably also put SRC and MPS in /etc/vz/vz.conf or some other config file unlikely to be overwritten by updates and source that like you are doing for additional simplification.

jlp
  • 411
  • 2
  • 5
  • Thank you but I don't think the script is the problem. :( I even tried your script in doubt, but it gives the same result... – Florent May 14 '13 at 20:30