Help - Search - Members - Calendar
Full Version: Question about fstab
MandrivaUsers.org > Advanced Topics > Command Line, Kernel and Programming
javaguy
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.

Phil Edwards
QUOTE (javaguy @ Aug 16 2008, 01:17 PM) *
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... biggrin.gif

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.
javaguy
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.

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.