LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-08-2008, 11:38 AM   #1
prabhatsoni
Member
 
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Rep: Reputation: 30
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
 
Old 01-08-2008, 01:19 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
Old 01-08-2008, 02:23 PM   #3
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,363

Rep: Reputation: 172Reputation: 172
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.
 
Old 01-08-2008, 02:27 PM   #4
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 6,311

Rep: Reputation: Disabled
Quote:
Originally Posted by theNbomr View Post
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.
 
Old 01-08-2008, 02:53 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by Emerson View Post
.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.
 
Old 01-08-2008, 02:58 PM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by lazlow View Post
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.
 
Old 01-08-2008, 03:27 PM   #7
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Quote:
Originally Posted by lazlow View Post
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.
 
Old 01-08-2008, 03:42 PM   #8
lazlow
Senior Member
 
Registered: Jan 2006
Posts: 4,363

Rep: Reputation: 172Reputation: 172
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.
 
Old 01-08-2008, 09:23 PM   #9
prabhatsoni
Member
 
Registered: Oct 2004
Location: India
Distribution: FC 12
Posts: 233

Original Poster
Rep: Reputation: 30
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

Last edited by prabhatsoni; 01-08-2008 at 09:25 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to give not-root user ability to mount devices to any mount point??? jdupre Linux - General 8 02-04-2012 10:03 AM
Changing Partitions cannot login to KDE as normal user hal8000b Linux - Desktop 1 10-30-2007 03:40 PM
mount directories of partitions, not partitions possible? kpachopoulos Linux - General 9 09-02-2007 07:25 PM
Gnome: Cannot login as default user, sends back to login, works as root Danny-T Linux - Newbie 2 05-27-2006 03:44 AM
Crazy blank dialog boxes and windows at login. Can't login as user soren625 Linux - General 2 08-11-2004 06:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration