Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

up vote 4 down vote accepted

Accourding to this is it is possible. You do need a recent kernel.

share|improve this answer
    
Thanks. Mount + remount fixed it. –  user13185 Apr 28 '10 at 7:51

Direct answer from the LWN article:

mount --bind /vital_data /untrusted_container/vital_data
mount -o remount,ro /untrusted_container/vital_data

Supported since Linux 2.6.26.

share|improve this answer

mount --bind /vital_data /untrusted_container/vital_data

mount -o remount,ro,bind /untrusted_container/vital_data

in the second mount you have to use "remount,ro,bind" otherwise all other instances of /vital_data will got read-only right too.

share|improve this answer

In Squeeze it used to work with only:

mount --bind /src /dst

then

mount -o remount,ro /dst

Now in Debian Wheezy you have to do:

mount -o remount,ro,bind /dst

to get rid of the: resource busy message.

share|improve this answer
    
Thanks :) the wheezy thing saved me. –  Wyatt8740 Aug 5 at 21:49

Your Answer

 
discard

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