LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Mount bind read-only (http://www.linuxquestions.org/questions/linux-general-1/mount-bind-read-only-478154/)

kramer2718 08-28-2006 02:18 PM

Mount bind read-only
 
I have the following lines in my fstab:

/dev/sdb1 /mnt/3 reiserfs auto,user,noatime 0 0
/mnt/3 /home/ftp none bind,ro

I was hoping to be able to be able to mount /dev/sdb1 for reading writing through /mnt/3 and for reading only through /home/ftp. Unfortunately, it doesn't work. After mount, I have rw access to both. After, googling, I came across some discussion that this functionality is being added to the kernel, but the discussion was a bit technical for me.

Does anyone know anything about this?

ramram29 08-28-2006 02:55 PM

Take out the '/mnt/3 /home/ftp none bind,ro' from /etc/fstab; that will not work. Instead use:

mount --bind -r /mnt/3 /home/ftp

This will allow you to mount /home/ftp as read-only.

kramer2718 08-28-2006 04:07 PM

Quote:

Originally Posted by ramram29
mount --bind -r /mnt/3 /home/ftp


Nope. I still have write access to /home/ftp.

ramram29 08-28-2006 04:28 PM

Look in your FTP configuration and make sure that you are not allowing write/upload/modify access - vsftp is very good with this. Look in /usr/share/doc/vsftpd/EXAMPLES for more examples.

You may also want to change permissions for the /home/ftp folder with something like:

chown -R root:root /home/ftp
chmod -R 0755 /home/ftp

kramer2718 08-28-2006 05:43 PM

Quote:

Originally Posted by ramram29
Look in your FTP configuration and make sure that you are not allowing write/upload/modify access - vsftp is very good with this. Look in /usr/share/doc/vsftpd/EXAMPLES for more examples.

You may also want to change permissions for the /home/ftp folder with something like:

chown -R root:root /home/ftp
chmod -R 0755 /home/ftp

Those are good points but this isn't really an ftp issue. I don't even have an ftp daemon running right now. I was hoping to get the directory to mount as read only while still being read-write when mounted as another directory. This is because I'm going to chroot into /home.

In general it would be nice to be able to mount partitions with different read-write permissions depending on where they are mounted.

I.e. mount --bind -r dir1 dir2

should not allow write access to dir2 no matter the mount permissions of dir1.

Matir 08-28-2006 05:49 PM

As far as I can tell, the functionality you seek should be coming shortly, but is not yet in the stable kernel.

ramram29 08-29-2006 08:43 AM

I thought '--bind -r' would work but you are right - it does not make it read only. I never tried it before but now that I tested this it does not mount it read only but rather it ignores the read-only parameter.

MONK 08-30-2008 11:44 AM

Does anyone know if this has been fixed yet as I really need this functionality?

jarfil 08-30-2008 05:03 PM

More info: http://lwn.net/Articles/281157/

Seems like this should be in kernel 2.6.26, with some enhancements afterwards. Meanwhile, a workaround might be to export a local nfs share as read-only.

MONK 08-31-2008 11:14 AM

Good idea, guess I can just mount them as read only instead.

It appears I'm not the only person who has had this problem, I have also stuck a post on the ubuntu forums about it.

http://ubuntuforums.org/showthread.p...32#post5699832


All times are GMT -5. The time now is 04:54 AM.