Proxmox 4.0 - sharing folders via lxc.mount.entry

Here is my config for 101:

lxc.include = /usr/share/lxc/config/debian.common.conf
lxc.arch = i386
lxc.cgroup.cpu.cfs_period_us = 100000
lxc.cgroup.cpu.cfs_quota_us = 200000
lxc.cgroup.cpu.shares = 1024
lxc.cgroup.memory.limit_in_bytes = 1073741824
lxc.cgroup.memory.memsw.limit_in_bytes = 1610612736
lxc.mount.entry = /data/nas /data none bind,create=dir 0 0
lxc.rootfs = loop:/var/lib/vz/images/101/vm-101-rootfs.raw
lxc.utsname = NAS
pve.disksize = 8
pve.volid = local:101/vm-101-rootfs.raw
lxc.network.type = veth
pve.network.bridge = vmbr0
pve.network.gw = 192.168.2.1
lxc.network.hwaddr = 26:AC:97:70:05:D5
pve.network.ip = 192.168.2.80/24
lxc.network.name = eth0
lxc.network.veth.pair = veth101.0
 
Problem solved - I removed the forward slash from the container mount point, e.g.

lxc.mount.entry = /data/nas data none bind,create=dir 0 0

Thanks to everyone who looked.
 
Problem solved - I removed the forward slash from the container mount point, e.g.

lxc.mount.entry = /data/nas data none bind,create=dir 0 0

Thanks to everyone who looked.

Thanks, I was dealing with this for 2 hours until I saw your post to remove slash.
 
Hi.
Can anybody help to mount more than one host directory into lxc container?
I've installed last Proxmox VE 4.0 beta2.
When i trying to add more than one entry (one of):
mp0: /fldr1,mp=/hostfldr1
mp1: /fldr2,mp=/hostfldr2
or
lxc.mount.entry /hostfldr1 fldr1 none bind,create=dir
lxc.mount.entry /hostfldr2 fldr2 none bind,create=dir
I just got first of configured mounts accessible in LXC container.

I've also checked with lxc.mount.hook that two directories mounted to $LXC_ROOTFS_MOUNT before root_pivot:
/dev/mapper/sata-root on /usr/lib/x86_64-linux-gnu/lxc/rootfs/fldr1 type ext4 (rw,relatime,stripe=256,data=ordered)
/dev/mapper/sata-root on /usr/lib/x86_64-linux-gnu/lxc/rootfs/fldr2 type ext4 (rw,relatime,stripe=256,data=ordered)

Is it possible to mount two host folders to container?
 
All I can say is that it works for me:

Inside the container:

Code:
sigxcpu@Library:~$ mount | grep data
storage/library on /data/library type zfs (rw,noatime,xattr,noacl)
raid0/torrents on /data/torrents type zfs (rw,noatime,xattr,noacl)

In the config file:

Code:
root@gen8:~# grep data /etc/pve/lxc/100.conf
mp0: /storage/library,mp=/data/library
mp1: /raid0/torrents,mp=/data/torrents

I think you've reversed host folder and mountpoint in container .conf file.
 
Also note that if you use lxc.mount.entry instead of mp* you need to prefix the destination folder with /var/lib/lxc/$VMID/rootfs (obviously replace $VMID with the container's ID)
 
multiple shared directories from host to lxc work here..
conf:
Code:
lxc.mount.entry: /bkup  bkup  none bind 0 0
lxc.mount.entry: /tmp   tmp2  none bind 0 0

df -h in ct:
Code:
/dev/dm-0     ext4     95G   11G   79G  13% /bkup
/dev/dm-0     ext4     95G   11G   79G  13% /tmp2

it is strange that device is same for both: /dev/dm-0

however the target directories are correct. the files in each are same as /tmp and /bkup on host



using:
proxmox-ve: 4.0-10 (running kernel: 4.2.0-1-pve)
lxc-pve: 1.1.3-1

debian etch is run in the lxc .
 
Last edited:
Oh, really, I'm looking stupid :)


I've checked with df -h, and it shows only one shared mount.
But when I tried "mount | grep dm-0", I seen all my mounts.
Thanks!
 
Hoping someone can help me out. I had mount points successfully configured but it seems a recent update has broken something. My previous lxc.mount.entry line looked like:

Code:
lxc.mount.entry = /host/mount /etc/pve/lxc/209/rootfs/container/mount none bind 0

(/host/mount and /container/mount are the directory locations, such as /mnt/storage) but this fails to mount now. Upon doing some research i've updated it so that it now looks like

Code:
lxc.mount.entry = /host/mount container/mount none bind 0 0
but i'm still not getting it to mount. Even though the directory already exists, i tried it with the create=dir flag but still nothing.

On boot there are a number of error messages that seem to relate to LXC mounting

Code:
proxmox kernel: audit: type=1400 audit(1443359239.649:32): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-container-default" name="/" pid=10423 comm="mount" flags="rw, remount"
proxmox kernel: audit: type=1400 audit(1443359239.649:33): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-container-default" name="/" pid=10424 comm="mount" flags="rw, remount, relatime"
proxmox kernel: audit: type=1400 audit(1443359239.769:34): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-container-default" name="/run/" pid=10645 comm="mount" flags="rw, nosuid, noexec, remount, relatime"
proxmox kernel: audit: type=1400 audit(1443359239.777:35): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-container-default" name="/run/lock/" pid=10662 comm="mount" flags="rw, nosuid, nodev, noexec, remount, relatime"
proxmox kernel: audit: type=1400 audit(1443359239.785:36): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-container-default" name="/proc/" pid=10672 comm="mount" flags="rw, nosuid, nodev, noexec, remount, relatime"
proxmox kernel: audit: type=1400 audit(1443359239.789:37): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-container-default" name="/sys/" pid=10683 comm="mount" flags="ro, nosuid, nodev, noexec, remount, relatime"
proxmox kernel: audit: type=1400 audit(1443359239.861:38): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-container-default" name="/run/shm/" pid=10847 comm="mount" flags="rw, nosuid, nodev, noexec, remount, relatime"
proxmox kernel: audit: type=1400 audit(1443359239.869:39): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-container-default" name="/dev/pts/" pid=10858 comm="mount" flags="rw, nosuid, noexec, remount, relatime"

One suggestion i found while googling (cannot post link) involved adding

Code:
mount options=(rw, bind),

to /etc/apparmor.d/lxc/lxc-default. It didn't seem to fix anything.

Does anyone have any suggestions?
 
Yes we moved to a more standard way of mounting the rootfs, replace /etc/pve/lxc/209/rootfs/ with /var/lib/lxc/209/rootfs/.
Alternatively there's now also a mountpoint option: mp0: /host/mount,mp=/container/mount
 
Worked it out. Saw this in the 4.0 beta2 release thread:

The config file /etc/pve/lxc/XXX/config is converted to /etc/pve/lxc/XXX.conf but the "lxc.mount.entry" lines don't reach the new config.
I was editing hte config file, not the .conf. All sorted now.
 
Yes we moved to a more standard way of mounting the rootfs, replace /etc/pve/lxc/209/rootfs/ with /var/lib/lxc/209/rootfs/.
Alternatively there's now also a mountpoint option: mp0: /host/mount,mp=/container/mount

Is there any preference to which should be used?

I'm seeing my mount points drop for no reason I can discern.