Jump to content

Question about fstab


Recommended Posts

Is it possible to set up a partition so that when the superuse mounts it it is read-write, but when an ordinary user mounts it it is read-only?

 

edit:

 

Okay, found good-enough solution. Make two fstab entries for it:

 

/dev/sdb1 /media/location1 ext3 ro,user,relatime 0 0

/dev/sdb1 /media/location2 ext3 relatime 0 0

 

Only root can mount /media/location2. Any user can mount /media/location1. Both are the same device, but one is read-only.

Edited by javaguy
Link to comment
Share on other sites

  • 4 weeks later...
Is it possible to set up a partition so that when the superuse mounts it it is read-write, but when an ordinary user mounts it it is read-only?

 

Barking slightly up the wrong tree, methinks... :D

 

Instead of restricting access to the files using the mount command, you should look at setting the permissions on the files so that they match up with what you want, i.e. for all files to be read/write for root but read only for everyone else. Starting off with 'cd /path/to/the/files/in/question', you should then:

 

find . -type f | xargs chown root:root

find . -type f | xargs chmod 644

 

The first command finds all normal files, i.e. it ignores directory entries, symbolic links, etc and changes the file owner and group to root.

 

The second command finds all normal files and makes them read/write for the owner (root) and read-only for everyone else.

Edited by Phil Edwards
Link to comment
Share on other sites

That doesn't really work for my purposes. This is the drive that I use for backups. I want the file ownerships and permissions to stay what they are. My backup script runs with root permission and mounts it read-write to make backups, then unmounts it. When I'm logged in as me, I want to be able to mount it and look at it if necessary but not be able to muck with it, i.e. accidentally screw something up royally. So far the solution of having two fstab entries for it is working for me.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...