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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...