Mount device as RW for root and RO for everyone else
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
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
...CORRECTsudo ls /mnt/foo
works ..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?
permissions mount fstab read-only
 |Â
show 1 more comment
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
...CORRECTsudo ls /mnt/foo
works ..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?
permissions mount fstab read-only
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 usingchown
/chmod
on the actual files...
â fkraiem
May 10 at 12:35
 |Â
show 1 more comment
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
...CORRECTsudo ls /mnt/foo
works ..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?
permissions mount fstab read-only
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
...CORRECTsudo ls /mnt/foo
works ..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?
permissions mount fstab read-only
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 usingchown
/chmod
on the actual files...
â fkraiem
May 10 at 12:35
 |Â
show 1 more comment
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 usingchown
/chmod
on 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
/chmod
on the actual files...â fkraiem
May 10 at 12:35
Normally, permissions on ext4 drives are managed by using
chown
/chmod
on the actual files...â fkraiem
May 10 at 12:35
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
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
Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set todrwx------
.
â 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
add a comment |Â
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 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
Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set todrwx------
.
â 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
add a comment |Â
up vote
0
down vote
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
Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set todrwx------
.
â 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
add a comment |Â
up vote
0
down vote
up vote
0
down vote
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
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
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 todrwx------
.
â 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
add a comment |Â
Doesn't work. Before mounting, the permissions work as expected, but after the bind mounting they are are automatically set todrwx------
.
â 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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
/chmod
on the actual files...â fkraiem
May 10 at 12:35