I use mount -o bind to mount directories inside chroots, which works really well. The problem is that I'd like some of these bind-mounted directories to be read only in chroot.
Is it possible? If not - any other way to achieve it?
I was thinking about using NFS for localhost mounts, but it looks like overkill.
Direct answer from the LWN article:
Supported since Linux 2.6.26.
According to this article is it is possible. You do need a recent kernel.
In Squeeze it used to work with only:
then
Now in Debian Wheezy you have to do:
to get rid of the: resource busy message.
Edit: Now in Debian Jessie, mount tries to be smart and mounts sub dirs, which if already mounted with bind, gets recursive and bad things happens :)
There is a special option that forces util-linux to be 'stupid' again. Solutions is this:
Afterwards you can mount --bind $prefix/sbin to another dir.
From the man page:
in the second mount you have to use "remount,ro,bind" otherwise all other instances of /vital_data will got read-only right too.