Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have multiple chroots with different sets of software version as a light-weight alternative to VMs.

How can I share a directory across the VMs? Naturally, symlinks do not allow to escape a chroot. Sure, I could mount a network share (via nfs or so) in each chroot, but that would impose a significant overhead and security considerations, wouldn't it?

share|improve this question
up vote 5 down vote accepted

On Linux – bind mounts.

mount --bind /orig /vm/one
mount --bind /orig /vm/two
mount --rbind /media /vm/one/media

Sharing /proc and /dev is the most common use for this (but make sure you use --rbind for /dev). You can even add -o ro for read-only.

To make the mounts persistent, update /etc/fstab:

/orig   /vm/one     none    bind
/orig   /vm/two     none    bind,ro

Once you start with using bind mounts for VMs, you will soon find yourself deep in namespaces and containers. (For example, you can have a chroot with isolated network, with just a single command...) Take a look at lxc, which uses native Linux features to create virtual systems.

share|improve this answer
Exactly what I was looking for. Thanks! – phihag Nov 1 '11 at 21:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.