I want to use bindfs (or any viable alternative) to solve the following problem:

I have a local folder that contains a maven project I am working on. However I can only build in a chroot environment (virtualization is too slow). But since this is a development environment it would be a big issue to not being able to edit files in the mount bind folder (thats how I currently make it available to the chroot env) using an IDE (with user privileges).

I think bindfs might help here, but I do not see how.


To clarify: I tried (as root)

mount -o bind /path/to/my/project /path/to/chroot/mountpoint


bindfs -u myuser -g users -p +rw /path/to/project /path/to/chroot/mountpoint
  • Do you use kvm for virtualization? – ikrabbe Jul 8 '15 at 18:22
  • I tried virtualbox (way too slow) and had partial help to setup a lxc container solution (did not work since something with the container was messed up and I can't complete the steps to get all dependencies in the container). – Benjamin Westrich Jul 9 '15 at 4:08

Making extra directory trees available in a chroot is a typical use case for bind mounts. In your case, it probably makes sense to have the same home directories in the main system and in the development environment. If you have root access and you're on Linux, you can use a Linux bind mount:

mount --bind /home /path/to/development/environment/home
chroot /path/to/development/environment

A bind mount is faster than bindfs, since bindfs is an extra layer whereas a bind mount is equivalent to the original — it does to mounts what a hard link does to files.

You may wish to use schroot. This is a bit of automation to create a working system in a chroot; one of the things it automates is bind mounts. It was originally developed for pretty much what you're doing now: to set up a clean development environment on a Debian system.

See What is a bind mount? for more information about bind mounts, especially the sections “Mounting in a jail” and “Running a different distribution”.

  • Thx for the reply. The problem that I have is that once I mount bind the project folder (it is not necessary to share the whole /home/myhome) then (I think that) the underlying resource, namely /path/to/my/project, is occupied by a process of root. Hence it is read-only for my normal user account (the one on the Host). If this is correct then I would either need to mount as a user or find a mount option (maybe bindfs) that does not mark the project path as read-only somehow. – Benjamin Westrich Jul 9 '15 at 4:15
  • Yes that's the nature of mount: When you mount something it is occupied by the system. But that should not have any effect on the underlying permissions. The permissions of the file tree and the flags on the file system should be the same as in the original file system. Check the mount(1) manual page about /The bind mounts and following sections about options. – ikrabbe Jul 9 '15 at 6:53
  • Then I might be doing something wrong. I'll post the exact mount command later (currently enroute to work). – Benjamin Westrich Jul 9 '15 at 7:22
  • @BenjaminWestrich I don't understand that “hence it is read-only” bit. Nothing is read-only unless you make it so. With mount --bind, all permissions are exactly the same no matter which mount point you access the directory tree through. – Gilles Jul 9 '15 at 9:16
  • @Gilles It is not read-only from the filesystem point of view. I think since a root process is using it it is marked (by the Kernel) as being read-only for other users. – Benjamin Westrich Jul 9 '15 at 11:54

I don't know what bindfs means, I just know the mount -o bind (option)

sudo mount -o bind /some/path/in/the/rootfs local/path
  • 1
    What bindfs is and what it does can be learned here: bindfs.org – Benjamin Westrich Jul 9 '15 at 4:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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