lxc.mount.entry fails into mnt/subdir
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxc (Ubuntu) |
Fix Released
|
Low
|
Unassigned | ||
Precise |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
=========== SRU Justification ===============
Impact: containers configured to have host directories bind mounted under
subdirectories of /mnt will not see those mounts
Development fix: change the directory which lxc uses (in ubuntu templates)
for pivot_root from mnt to mnt.putold.
Stable fix: same as development fix.
Test case:
Create a container:
sudo apt-get -y install lxc
sudo lxc-create -t ubuntu -n p1
Create a bind mount under an /mnt subdir of the container:
sudo mkdir -b /var/lib/
cat << EOF | sudo tee -a /var/lib/
lxc.mount.entry = /etc mnt/etc none bind 0 0
EOF
Start the container, and look under /mnt
sudo lxc-start -n p1
#(log in as user ubuntu, password ubuntu, and do)
ls /mnt/etc
Regression potential: this simply uses an existing, working lxc configuration
variable to use a more sensible location for the pivot_root put_old directory.
There should be no regression.
=======
A lxc.mount.entry line like
lxc.mount.entry = /var/lib mnt/series none bind 0 0
fails to mount the host's /var/lib under the container's /mnt/series, while
lxc.mount.entry = /var/lib mnt none bind 0 0
works.
Changed in lxc (Ubuntu): | |
status: | New → Confirmed |
importance: | Undecided → Medium |
description: | updated |
The reason this happens is that by default 'mnt' is the directory used as pivotdir, where the old_root is placed during pivot_root(). After that, everything under pivotdir is unmounted.
A workaround is to specify an alternate 'lxc.pivotdir' in the container configuration file.
The code should be changed to use a tempdir as pivotroot. However, that can wait for Q and an SRU, since there is a workaround