Skip to content

Instantly share code, notes, and snippets.

@lmiphay
Created June 22, 2016 15:17
Show Gist options
  • Save lmiphay/ce47eede69e097cb067afc8aaf15220b to your computer and use it in GitHub Desktop.
Save lmiphay/ce47eede69e097cb067afc8aaf15220b to your computer and use it in GitHub Desktop.
# top mount point
/shared /shared none bind,unbindable,shared 0 0
# virtual machines
/lxc/c1 /shared/c1 none bind 0 0
/lxc/c2 /shared/c2 none bind 0 0
/lxc/c3 /shared/c3 none bind 0 0
/home /shared/home none bind 0 0
#!/bin/bash
mnts="c1 c2 c3 home"
for i in $mnts; do
umount /shared/$i
done
for i in $mnts; do
mount /shared/$i
done
ls /shared/*
exit 0
This is based on: https://s3hh.wordpress.com/2011/09/22/sharing-mounts-with-a-container/
This is for a trusted environment only.
The lxc rootfs for each container is located under: /shared/c?
Setup:
1. mkdir /shared /shared/c{1,2,3}
2. add entries to /etc/fstab (see file excerpt)
3. start the lxc's
4. run remount-shared.sh on the host if the mount points are missing inside the lxc's
Step 4 appears to be required because the lxc umounts the directories during startup (possibly related to pivot root)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment