LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-26-2005, 08:46 PM   #1
a thing
Member
 
Registered: Jan 2005
Distribution: Fedora Core 4 Test 3/3.92, Fedora Core 3
Posts: 45

Rep: Reputation: 15
Changing ownership of partition and USB key


Is there any way to change the owner of a partition or USB flash drive to a non-root user? I'd be nice if I didn't have to log into root to use those.
 
Old 01-26-2005, 08:52 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Nothing so drastic is necessary

Open your /etc/fstab file in an editor, and add the "user" option to all the devices that you would like to allow regular users to mount. For instance, here is a line from my /etc/fstab for my USB pendrive:
Code:
/dev/sda1      /media/pendrive  vfat     noauto,rw,user          0     0
Your USB drive will likely be the same device unless you have SCSI disks in your system; in which case, you's probably be familiar enough to know what to change. Save the file, and then regular users should be able to mount and unmount those devices at will.
 
Old 01-26-2005, 09:48 PM   #3
m_yates
Senior Member
 
Registered: Aug 2003
Location: Upstate
Distribution: Debian, Mint, Mythbuntu
Posts: 1,207

Rep: Reputation: 63
I did the same thing as Dark_Helmet. One other thing, you won't be able to mount the drive as a regular user (the command mount /dev/sda1 will only work as root). Instead, you need to do:
Code:
mount /media/pendrive
as regular user to mount it.
 
Old 01-26-2005, 10:19 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
m_yates:
Really? It won't let you execute mount /dev/sda1 as a regular user? That's a bit odd if I may say so. My system will allow a regular user to mount using either the device itself or the mountpoint. I just double-checked and that the user I tested with isn't in any special groups or anything like that. I can't say anything comes to mind about why you're seeing that behavior.
 
Old 01-27-2005, 03:34 AM   #5
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
You should be able to do mount /dev/sda1 as user, but probably can't give mountoptions like: mount -t vfat /dev/sda1
 
Old 01-27-2005, 04:00 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
For vfat partitions, you can use the 'uid=' and 'gid=' options. For pendrives however, they are usually mounted dynamically by the hotplug system, rather than having an entry for the device in /etc/fstab.
 
Old 01-27-2005, 04:13 AM   #7
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Quote:
Originally posted by jschiwal
For pendrives however, they are usually mounted dynamically by the hotplug system, rather than having an entry for the device in /etc/fstab.
True, but if the pendrive is the only USB device that's being used (or used frequently), then adding an entry in /etc/fstab isn't going to hurt anything.

Also, if the system is using udev (2.6 series kernel), udev can be configured to assign a specific device to a specific designation. For instance, assigning the pendrive to /dev/sda1. I haven't done this myself (I fall into the pendrive-is-the-only-device category), but it makes adding an entry in /etc/fstab very useful in this case as well.

An sda1 entry may not work for 100% of the people, but it's probably useful for a large group.
 
Old 01-27-2005, 06:37 PM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
I agree with dark_helmets advice. The direct answer is to use the 'uid' and 'gid' in the fstab entry to change the ownership and group ownership of the pendrive. If you don't remove the drive, then an fstab entry is great, but if a device isn't present, and if the /etc/fstab entry results in the partition being mounted during boot, then the computer won't finish booting because the device isn't present.

So adding the 'user' option would be a good idea. It may be an idea to include a test for the device in the users ~/.profile script and mount it at that time. This would allow the mounting to be done transparently, and only mount it for that user. I think that is what 'a thing' has in mind.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble reading usb key partition table BNI Linux From Scratch 1 11-02-2005 11:13 AM
Issues reading usb key partition table BNI Linux - Hardware 2 11-02-2005 09:23 AM
usb key partition table guldo Linux - General 7 07-26-2005 03:28 AM
changing the ownership djh Slackware 3 11-08-2004 05:16 AM
mounting second partition of USB RAM key Armgas Linux - Hardware 0 05-17-2003 02:10 PM


All times are GMT -5. The time now is 03:21 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