3

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.

EDIT:

To clarify: I tried (as root)

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

and

bindfs -u myuser -g users -p +rw /path/to/project /path/to/chroot/mountpoint
2
  • Do you use kvm for virtualization?
    – ikrabbe
    Commented Jul 8, 2015 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). Commented Jul 9, 2015 at 4:08

1 Answer 1

3

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

6
  • 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. Commented Jul 9, 2015 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
    Commented Jul 9, 2015 at 6:53
  • Then I might be doing something wrong. I'll post the exact mount command later (currently enroute to work). Commented Jul 9, 2015 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. Commented Jul 9, 2015 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. Commented Jul 9, 2015 at 11:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .