LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to mount partitions on user login (https://www.linuxquestions.org/questions/linux-general-1/how-to-mount-partitions-on-user-login-612027/)

prabhatsoni 01-08-2008 11:38 AM

How to mount partitions on user login
 
Hello folks,
I have recently purchased a new hard disk. I have earmarked one partition (NTFS) each for my kids. These are NTFS since my objective is that these partitions should be accesible from windows too. I have put appropriate entries in the fstab so that when the linux starts the two partitions are mounted with correct ownerships and permissions.
No problem - it is working fine.

But I was thinking that I should delay the mounting till the kids log in. In addition , the correct partition only should mount (and not both the partitions) depending upon who is logging in.

Is there any way by which it could somehow be done.


Thanks in advance.


Prabhat Soni

theNbomr 01-08-2008 01:19 PM

You could put the commands to mount the partition(s) in user shell startup script(s), such as .bashrc. You will then need to put in code to test whether the partition is already mounted, but then how will you handle automatic unmounting? Messy. Let us know if you come up with something that works well.
--- rod.

lazlow 01-08-2008 02:23 PM

Why not go ahead and mount it but use groups to set the permissions to rw to the drives? Kid A (a member of group One) can see partition One but not partition Two. Kid B (a member of group Two) can see partition Two but not partition One.

Emerson 01-08-2008 02:27 PM

Quote:

Originally Posted by theNbomr (Post 3015795)
You could put the commands to mount the partition(s) in user shell startup script(s), such as .bashrc. You will then need to put in code to test whether the partition is already mounted, but then how will you handle automatic unmounting? Messy. Let us know if you come up with something that works well.
--- rod.

.bash_logout is sourced when user logs off.

theNbomr 01-08-2008 02:53 PM

Quote:

Originally Posted by Emerson (Post 3015876)
.bash_logout is sourced when user logs off.

True, but you would only want umount to occur on the last logout, which requires some book-keeping to keep track of. Moreover, a user may be logged in without any shell running. I'm not sure what happens when users simply close a terminal window without actually typing 'logout/exit'; does something trap this event and execute a shell logout?
--- rod.

theNbomr 01-08-2008 02:58 PM

Quote:

Originally Posted by lazlow (Post 3015873)
Why not go ahead and mount it but use groups to set the permissions to rw to the drives? Kid A (a member of group One) can see partition One but not partition Two. Kid B (a member of group Two) can see partition Two but not partition One.

This makes the most sense to me. At least one benefit of this would be that the locate database would be kept up-to-date for both partitions if updatedb is run on an automatic schedule.
--- rod.

jtshaw 01-08-2008 03:27 PM

Quote:

Originally Posted by lazlow (Post 3015873)
Why not go ahead and mount it but use groups to set the permissions to rw to the drives? Kid A (a member of group One) can see partition One but not partition Two. Kid B (a member of group Two) can see partition Two but not partition One.


Does NTFS support UNIX style permissions? I'd also test to see how setting the owning group/user and modifying the permissions of a file ultimately effects Windows.

lazlow 01-08-2008 03:42 PM

It does not effect NTFS but it does effect the mount point. Access to the mount point can be treated just like any other FS.

prabhatsoni 01-08-2008 09:23 PM

Hello folks,
For the present I am using the fstab entry as below:
Code:

/dev/sda9  /mnt/sda9  ntfs  uid=500,gid=500,umask=077  0 0
The same effect could be obtained by following command:
mount -t ntfs -o uid=500,gid=500,umask=077 /dev/sda9 /mnt/sda9

But this can be done only by the root.

Thus executing this command from the bash start up script of a user is not possible.
But that gives me an idea. Can I make the user the owner of the device /dev/sda9 (which is presently owned by root). And by incorporating this change would this ordinary user be able to mount the partition. Will have to check out.

Will changing the ownership of a disk device from root to an ordinary user have any serious side-effects ?

Any more ideas ?


Thanks


Prabhat Soni


All times are GMT -5. The time now is 06:07 PM.