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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-26-2005, 07:46 PM
|
#1
|
Member
Registered: Jan 2005
Distribution: Fedora Core 4 Test 3/3.92, Fedora Core 3
Posts: 45
Rep:
|
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.
|
|
|
01-26-2005, 07:52 PM
|
#2
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
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.
|
|
|
01-26-2005, 08:48 PM
|
#3
|
Senior Member
Registered: Aug 2003
Location: Upstate
Distribution: Debian, Mint, Mythbuntu
Posts: 1,249
Rep:
|
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.
|
|
|
01-26-2005, 09:19 PM
|
#4
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
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.
|
|
|
01-27-2005, 02:34 AM
|
#5
|
Senior Member
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107
Rep:
|
You should be able to do mount /dev/sda1 as user, but probably can't give mountoptions like: mount -t vfat /dev/sda1
|
|
|
01-27-2005, 03:00 AM
|
#6
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
01-27-2005, 03:13 AM
|
#7
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
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.
|
|
|
01-27-2005, 05:37 PM
|
#8
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
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.
|
|
|
All times are GMT -5. The time now is 11:50 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|