LXC Bind Mounts: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
(remove deprecated info: bind mounts can be backed up, pve-zsync with mount points is fixed)
Line 1: Line 1:
== Introduction ==
== Introduction ==
This is an experimental feature.


Bind mounts allow you to access a directory, or a storage volume from your Proxmox VE host inside a container. There can be many purposes:
Bind mounts allow you to access a directory, or a storage volume from your Proxmox VE host inside a container. There can be many purposes:
Line 8: Line 7:


Note that the device you want to use has to be already accessible in the pve host. For security reasons, it is not possible to mount a device of NFS share directly in the guest.
Note that the device you want to use has to be already accessible in the pve host. For security reasons, it is not possible to mount a device of NFS share directly in the guest.
== Step by step examples ==
*Note that the "mp0:" mount variant may result in an error "ERROR: Backup of VM 103 failed - unable to handle mountpoint 'mp0' - feature not implemented" on backup of the container. To make backups work, use the "lxc.mount.entry" method described below.
*Note2 using mp0 mount variant prevents pve-zsync from working. instead zsync fails with ''ERROR Message: disk is not on ZFS Storage'' . for now use the "lxc.mount.entry" method described below.  See bug 813.


Suppose you want to access the following directories in your LXC container with ID100:
Suppose you want to access the following directories in your LXC container with ID100:
Line 30: Line 25:
</pre>
</pre>


== Another method ==
== Manual method ==
* This works as of 2015-09-13 using lxc-pve: 1.1.3-1 .   
* This works as of 2015-09-13 using lxc-pve: 1.1.3-1 .   
:add this to the .conf file in /etc/pve/lxc
:add this to the .conf file in /etc/pve/lxc
Line 37: Line 32:


'''Note:''' This adds an entry to "/var/lib/lxc/<containerID>/config" in the correct format.  Do not edit "/var/lib/lxc/<containerID>/config" manually as that is overwritten on container boot.
'''Note:''' This adds an entry to "/var/lib/lxc/<containerID>/config" in the correct format.  Do not edit "/var/lib/lxc/<containerID>/config" manually as that is overwritten on container boot.
== Caveats ==
 
== Bind mounts and backup ==
Note that bind mounts are not going to be included when you backup the container by default. You need to
Note that bind mounts are not going to be included when you backup the container by default. You need to
set the backup flag to include them.
set the backup flag to include them.

Revision as of 12:58, 14 December 2015

Introduction

Bind mounts allow you to access a directory, or a storage volume from your Proxmox VE host inside a container. There can be many purposes:

  • Accessing your home directory in the guest
  • Accessing a USB device directory in the guest
  • Accessing a NFS mount from in the host in the guest

Note that the device you want to use has to be already accessible in the pve host. For security reasons, it is not possible to mount a device of NFS share directly in the guest.

Suppose you want to access the following directories in your LXC container with ID100:

  • /target which is a local directory
  • /mnt/pve/freenas which is a NFS mounted directory

Then you need to add the following parameters to /etc/pve/lxc/100.conf

 mp0: /target/test,mp=/target
 mp1: /mnt/pve/freenas,mp=/mnt/pve/freenas

reboot your container and log in:

 pct enter
 mount | egrep '(target|freenas)'
 /dev/dm-0 on /target type ext4 (rw,relatime,errors=remount-ro,data=ordered)
 freenas.local:/mnt/TranstecThrough/exported

Manual method

  • 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: /host/folder container/folder  none bind,create=dir,optional 0 0

Note: Do not put a '/' before the container target

Note: This adds an entry to "/var/lib/lxc/<containerID>/config" in the correct format. Do not edit "/var/lib/lxc/<containerID>/config" manually as that is overwritten on container boot.

Bind mounts and backup

Note that bind mounts are not going to be included when you backup the container by default. You need to set the backup flag to include them.

mp0: /target/test,mp=/target,backup=yes