I have a device I want to mount for root with full permissions and for everyone else as readonly. The man page tells me this is possible.
So:
sudo mkdir /mnt/foosudo mkdir /mnt/fooReadOnlysudo chmod 700 /mnt/foo(rw for root only)sudo chmod 444 /mnt/fooReadOnly(ro for everyone)- ensure device
/dev/sdaXis mounted as/mnt/foo
Then I did what the man page suggested:
sudo mount --bind /mnt/foo /mnt/fooReadOnlysudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly
Now to test:
ls /mnt/foo-->Permission denied...CORRECTsudo ls /mnt/fooworks ..CORRECTls /mnt/fooReadOnly-->Permission denied...INCORRECT?
How do I fix this?
Also, how do I add this to /etc/fstab so that it will automatically remount on boot?
1 Answer
First, unmount fooReadOnly withsudo umount /mnt/fooReadOnly
Then, change the permission of fooReadOnly to 555sudo chmod 555 /mnt/fooReadOnly
This is needed because entering a directory requires execute privilege.
Finally, remount fooReadOnlysudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly