javaguy Posted August 16, 2008 Report Share Posted August 16, 2008 (edited) 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 August 17, 2008 by javaguy Quote Link to comment Share on other sites More sharing options...
Phil Edwards Posted September 12, 2008 Report Share Posted September 12, 2008 (edited) 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 September 12, 2008 by Phil Edwards Quote Link to comment Share on other sites More sharing options...
javaguy Posted September 13, 2008 Author Report Share Posted September 13, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.