LXC Bind Mounts: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
= Introduction =
== Introduction ==
This is an experimental feature.
This is an experimental feature.


Line 9: Line 9:
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 =
== Step by step examples ==
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:
* /target which is a local directory
* /target which is a local directory
Line 25: Line 25:
  /dev/dm-0 on /target type ext4 (rw,relatime,errors=remount-ro,data=ordered)
  /dev/dm-0 on /target type ext4 (rw,relatime,errors=remount-ro,data=ordered)
  freenas.local:/mnt/TranstecThrough/exported
  freenas.local:/mnt/TranstecThrough/exported
= another method =
 
== Another method ==
*this works 2015-09-13 using lxc-pve: 1.1.3-1 .   
*this works 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 31: Line 32:
note do not put a '/' before the target
note do not put a '/' before the target


= Caveats =
== Caveats ==
Note that bind mounts are not going to be included when you backup the container.
Note that bind mounts are not going to be included when you backup the container.
This is a design decision: since bind mounts might be shared between many containers, it makes sense to backup their content on the host, not from inside the container.
This is a design decision: since bind mounts might be shared between many containers, it makes sense to backup their content on the host, not from inside the container.
[[Category: HOWTO]][[Category: Technology]]
 
[[Category: HOWTO]] [[Category: Technology]]

Revision as of 10:57, 27 October 2015

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:

  • 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.

Step by step examples

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

Another method

  • this works 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 0 0

note do not put a '/' before the target

Caveats

Note that bind mounts are not going to be included when you backup the container. This is a design decision: since bind mounts might be shared between many containers, it makes sense to backup their content on the host, not from inside the container.