Mount device as RW for root and RO for everyone else

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
3
down vote

favorite












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/foo

  • sudo mkdir /mnt/fooReadOnly


  • sudo chmod 700 /mnt/foo (rw for root only)


  • sudo chmod 444 /mnt/fooReadOnly (ro for everyone)

  • ensure device /dev/sdaX is mounted as /mnt/foo

Then I did what the man page suggested:



  • sudo mount --bind /mnt/foo /mnt/fooReadOnly

  • sudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly

Now to test:




  • ls /mnt/foo --> Permission denied ...CORRECT


  • sudo ls /mnt/foo works ..CORRECT


  • ls /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?







share|improve this question






















  • You will need 555 permissions on the directory to be able to traverse it. Why don't you look at ACLs instead ?
    – solsTiCe
    May 10 at 10:30










  • @solsTiCe I can't change anything for that bind mount, it says: chmod: changing permissions of '/mnt/fooReadOnly/': Read-only file system. Thing is according to the man pages, this functionality is actually supposed to work, so I'm obviously doing something wrong.
    – lonix
    May 10 at 11:26











  • "I have a device", what sort of device? In particular, which filesystem?
    – fkraiem
    May 10 at 11:44










  • @fkraiem ext4 hard drive
    – lonix
    May 10 at 12:27






  • 1




    Normally, permissions on ext4 drives are managed by using chown/chmodon the actual files...
    – fkraiem
    May 10 at 12:35















up vote
3
down vote

favorite












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/foo

  • sudo mkdir /mnt/fooReadOnly


  • sudo chmod 700 /mnt/foo (rw for root only)


  • sudo chmod 444 /mnt/fooReadOnly (ro for everyone)

  • ensure device /dev/sdaX is mounted as /mnt/foo

Then I did what the man page suggested:



  • sudo mount --bind /mnt/foo /mnt/fooReadOnly

  • sudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly

Now to test:




  • ls /mnt/foo --> Permission denied ...CORRECT


  • sudo ls /mnt/foo works ..CORRECT


  • ls /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?







share|improve this question






















  • You will need 555 permissions on the directory to be able to traverse it. Why don't you look at ACLs instead ?
    – solsTiCe
    May 10 at 10:30










  • @solsTiCe I can't change anything for that bind mount, it says: chmod: changing permissions of '/mnt/fooReadOnly/': Read-only file system. Thing is according to the man pages, this functionality is actually supposed to work, so I'm obviously doing something wrong.
    – lonix
    May 10 at 11:26











  • "I have a device", what sort of device? In particular, which filesystem?
    – fkraiem
    May 10 at 11:44










  • @fkraiem ext4 hard drive
    – lonix
    May 10 at 12:27






  • 1




    Normally, permissions on ext4 drives are managed by using chown/chmodon the actual files...
    – fkraiem
    May 10 at 12:35













up vote
3
down vote

favorite









up vote
3
down vote

favorite











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/foo

  • sudo mkdir /mnt/fooReadOnly


  • sudo chmod 700 /mnt/foo (rw for root only)


  • sudo chmod 444 /mnt/fooReadOnly (ro for everyone)

  • ensure device /dev/sdaX is mounted as /mnt/foo

Then I did what the man page suggested:



  • sudo mount --bind /mnt/foo /mnt/fooReadOnly

  • sudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly

Now to test:




  • ls /mnt/foo --> Permission denied ...CORRECT


  • sudo ls /mnt/foo works ..CORRECT


  • ls /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?







share|improve this question














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/foo

  • sudo mkdir /mnt/fooReadOnly


  • sudo chmod 700 /mnt/foo (rw for root only)


  • sudo chmod 444 /mnt/fooReadOnly (ro for everyone)

  • ensure device /dev/sdaX is mounted as /mnt/foo

Then I did what the man page suggested:



  • sudo mount --bind /mnt/foo /mnt/fooReadOnly

  • sudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly

Now to test:




  • ls /mnt/foo --> Permission denied ...CORRECT


  • sudo ls /mnt/foo works ..CORRECT


  • ls /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?









share|improve this question













share|improve this question




share|improve this question








edited May 10 at 11:27

























asked May 10 at 8:41









lonix

956




956











  • You will need 555 permissions on the directory to be able to traverse it. Why don't you look at ACLs instead ?
    – solsTiCe
    May 10 at 10:30










  • @solsTiCe I can't change anything for that bind mount, it says: chmod: changing permissions of '/mnt/fooReadOnly/': Read-only file system. Thing is according to the man pages, this functionality is actually supposed to work, so I'm obviously doing something wrong.
    – lonix
    May 10 at 11:26











  • "I have a device", what sort of device? In particular, which filesystem?
    – fkraiem
    May 10 at 11:44










  • @fkraiem ext4 hard drive
    – lonix
    May 10 at 12:27






  • 1




    Normally, permissions on ext4 drives are managed by using chown/chmodon the actual files...
    – fkraiem
    May 10 at 12:35

















  • You will need 555 permissions on the directory to be able to traverse it. Why don't you look at ACLs instead ?
    – solsTiCe
    May 10 at 10:30










  • @solsTiCe I can't change anything for that bind mount, it says: chmod: changing permissions of '/mnt/fooReadOnly/': Read-only file system. Thing is according to the man pages, this functionality is actually supposed to work, so I'm obviously doing something wrong.
    – lonix
    May 10 at 11:26











  • "I have a device", what sort of device? In particular, which filesystem?
    – fkraiem
    May 10 at 11:44










  • @fkraiem ext4 hard drive
    – lonix
    May 10 at 12:27






  • 1




    Normally, permissions on ext4 drives are managed by using chown/chmodon the actual files...
    – fkraiem
    May 10 at 12:35
















You will need 555 permissions on the directory to be able to traverse it. Why don't you look at ACLs instead ?
– solsTiCe
May 10 at 10:30




You will need 555 permissions on the directory to be able to traverse it. Why don't you look at ACLs instead ?
– solsTiCe
May 10 at 10:30












@solsTiCe I can't change anything for that bind mount, it says: chmod: changing permissions of '/mnt/fooReadOnly/': Read-only file system. Thing is according to the man pages, this functionality is actually supposed to work, so I'm obviously doing something wrong.
– lonix
May 10 at 11:26





@solsTiCe I can't change anything for that bind mount, it says: chmod: changing permissions of '/mnt/fooReadOnly/': Read-only file system. Thing is according to the man pages, this functionality is actually supposed to work, so I'm obviously doing something wrong.
– lonix
May 10 at 11:26













"I have a device", what sort of device? In particular, which filesystem?
– fkraiem
May 10 at 11:44




"I have a device", what sort of device? In particular, which filesystem?
– fkraiem
May 10 at 11:44












@fkraiem ext4 hard drive
– lonix
May 10 at 12:27




@fkraiem ext4 hard drive
– lonix
May 10 at 12:27




1




1




Normally, permissions on ext4 drives are managed by using chown/chmodon the actual files...
– fkraiem
May 10 at 12:35





Normally, permissions on ext4 drives are managed by using chown/chmodon the actual files...
– fkraiem
May 10 at 12:35











1 Answer
1






active

oldest

votes

















up vote
0
down vote













First, unmount fooReadOnly with
sudo umount /mnt/fooReadOnly



Then, change the permission of fooReadOnly to 555
sudo chmod 555 /mnt/fooReadOnly

This is needed because entering a directory requires execute privilege.



Finally, remount fooReadOnly
sudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly






share|improve this answer




















  • Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set to drwx------.
    – lonix
    May 10 at 14:02











  • Did you try chmod after mounting?
    – Harikrishnan R
    May 12 at 21:56










  • yes, it's a readonly volume, so nothing can be changed
    – lonix
    May 13 at 8:16










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1034397%2fmount-device-as-rw-for-root-and-ro-for-everyone-else%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













First, unmount fooReadOnly with
sudo umount /mnt/fooReadOnly



Then, change the permission of fooReadOnly to 555
sudo chmod 555 /mnt/fooReadOnly

This is needed because entering a directory requires execute privilege.



Finally, remount fooReadOnly
sudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly






share|improve this answer




















  • Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set to drwx------.
    – lonix
    May 10 at 14:02











  • Did you try chmod after mounting?
    – Harikrishnan R
    May 12 at 21:56










  • yes, it's a readonly volume, so nothing can be changed
    – lonix
    May 13 at 8:16














up vote
0
down vote













First, unmount fooReadOnly with
sudo umount /mnt/fooReadOnly



Then, change the permission of fooReadOnly to 555
sudo chmod 555 /mnt/fooReadOnly

This is needed because entering a directory requires execute privilege.



Finally, remount fooReadOnly
sudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly






share|improve this answer




















  • Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set to drwx------.
    – lonix
    May 10 at 14:02











  • Did you try chmod after mounting?
    – Harikrishnan R
    May 12 at 21:56










  • yes, it's a readonly volume, so nothing can be changed
    – lonix
    May 13 at 8:16












up vote
0
down vote










up vote
0
down vote









First, unmount fooReadOnly with
sudo umount /mnt/fooReadOnly



Then, change the permission of fooReadOnly to 555
sudo chmod 555 /mnt/fooReadOnly

This is needed because entering a directory requires execute privilege.



Finally, remount fooReadOnly
sudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly






share|improve this answer












First, unmount fooReadOnly with
sudo umount /mnt/fooReadOnly



Then, change the permission of fooReadOnly to 555
sudo chmod 555 /mnt/fooReadOnly

This is needed because entering a directory requires execute privilege.



Finally, remount fooReadOnly
sudo mount -o remount,bind,ro /mnt/foo /mnt/fooReadOnly







share|improve this answer












share|improve this answer



share|improve this answer










answered May 10 at 13:35









Harikrishnan R

463




463











  • Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set to drwx------.
    – lonix
    May 10 at 14:02











  • Did you try chmod after mounting?
    – Harikrishnan R
    May 12 at 21:56










  • yes, it's a readonly volume, so nothing can be changed
    – lonix
    May 13 at 8:16
















  • Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set to drwx------.
    – lonix
    May 10 at 14:02











  • Did you try chmod after mounting?
    – Harikrishnan R
    May 12 at 21:56










  • yes, it's a readonly volume, so nothing can be changed
    – lonix
    May 13 at 8:16















Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set to drwx------.
– lonix
May 10 at 14:02





Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set to drwx------.
– lonix
May 10 at 14:02













Did you try chmod after mounting?
– Harikrishnan R
May 12 at 21:56




Did you try chmod after mounting?
– Harikrishnan R
May 12 at 21:56












yes, it's a readonly volume, so nothing can be changed
– lonix
May 13 at 8:16




yes, it's a readonly volume, so nothing can be changed
– lonix
May 13 at 8:16












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1034397%2fmount-device-as-rw-for-root-and-ro-for-everyone-else%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491