how to mount host directories inside a proxmox lxc container

Proxmox supports the creation of custom mountpoints inside a lxc container straight from the proxmox container .conf file:

locate your container conf file under /etc/pve/lxc/<ID>.conf and add the following:

mp0:/mount/point/on/host,mp=/mount/point/on/lxc
mp1:/another/mount/point/on/host,mp=/another/mount/point/on/lxc

thats it!

edit: another way, in the same file, as pointed out in the comments is:

lxc.mount.entry: /bkup bkup none bind,create=dir,optional 0 0

This method works with migrations!

Note: Do not put a ‘/’ before the target

People who use pve-zsync or have problems regarding the backup of the container might want to check out this alternative.

4 Comments

  • morfair Reply

    Migration don’t work with this method.

    • Felix Brucker Reply

      That’s right, the container is bound to that host with that specific mount path.

  • Jared Reply

    They have a new method of doing this now, fyi:

    This works as of 2015-09-13 using lxc-pve: 1.1.3-1 .
    add this to the .conf file in /etc/pve/lxc
    lxc.mount.entry: /bkup bkup none bind,create=dir,optional 0 0
    Note: Do not put a ‘/’ before the target

    • Felix Brucker Reply

      thanks 🙂

      I prefer the original one above because of the easier syntax, though.

Leave a Reply

Your email address will not be published. Required fields are marked *