LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 09-23-2007, 11:34 AM   #1
ddlawrence
LQ Newbie
 
Registered: Aug 2007
Location: Vancouver Island, Canada
Distribution: Fedora Core
Posts: 24

Rep: Reputation: 16
Question USB memory stick


Hi. My USB memory stick works OK for the root user but
not for non-root users. It gives the 'permission denied'
message when trying to write to it.
I know I can probably fix this in /etc/fstab. Here she is:

LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda3 swap swap defaults 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/sda1 /mnt/flash auto noauto,owner,kudzu 0 0
[root@d64-180-208-166 root]#

I think I need to change the 'owner' field for the /mnt/flash record.
How do I do this?

thanks...............don
 
Old 09-23-2007, 11:50 AM   #2
Okie
Senior Member
 
Registered: Mar 2002
Location: Oklahoma
Posts: 1,154

Rep: Reputation: 187Reputation: 187
/dev/sda1 /mnt/flash auto noauto,owner,kudzu 0 0 <--change this to:



/dev/sda1 /mnt/flash auto noauto,users,kudzu 0 0 <-- to this:

this should work, changing owner to users should allow non-root users to mount and have read & write permissions to your USB flash memory stick...
 
Old 09-23-2007, 11:59 AM   #3
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Look at the "uid" and "gid" options.
Code:
$ cat /etc/fstab | grep uid
/dev/WinXP/C            /hd/c                   ntfs-3g rw,uid=root,gid=disk 0 0
/dev/WinXP/D            /hd/d                   vfat    rw,uid=root,gid=disk 0 0
Since it's a USB stick, consider setting up automount for it, or configuring udev to symlink the mount point to a fixed /dev location so your fstab entry will continue to work even when you add other USB devices to your system.
 
Old 09-23-2007, 12:31 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
There is also the fmask and dmask options to set the permissions for the mounted drive. I would recommend using either the label or UUID number to mount a thumb drive. The next time you insert it it might be assigned to a different device. Here is an example from an external usb drive formatted with the ext3 filesystem:
Code:
LABEL=news      /home/jschiwal/news     ext3    acl,user_xattr 1 2
 
Old 09-23-2007, 01:19 PM   #5
ddlawrence
LQ Newbie
 
Registered: Aug 2007
Location: Vancouver Island, Canada
Distribution: Fedora Core
Posts: 24

Original Poster
Rep: Reputation: 16
USB memory stick mounting saga

Thanks for the pointers gents.
I used emacs to change the /etc/fstab entry for the
memory stick device to 'users' instead of 'owner'
It worked and non-root users could write to it.
But when I rebooted the change was undone.
I changed it again and checked it and rebooted.
The change was undone again.
I must be changing it wrong.


Also, how do I specify automount?

I think I will give the users the root password so they
can continue to use the memory stick. This is a small
company so I can trust them as long as I can get it
to automount.

thanks............don
 
Old 09-24-2007, 07:19 AM   #6
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Even in a "small" company, giving users "root" privilege is not a good idea. In fact, it's not a good idea for you to run a "root" unless you need to do system maintenance. The problem with "root" privilege is that "accidents" can catastrophic if done by "root."

Your real problem seems to be that the USB stick settings are not "sticking" across a reboot. So the question I'd ask is, do you have the USB stick plugged in when you reboot, or do you plug it in later? (Or move it around?) Most modern Linux systems will automatically attach a USB stick when it's plugged in, but the mount is done by a script invoked by udev which doesn't use the fstab settings.

Much better would be to create a group (say, e.g., usb_users) and then use chown to reset the group owner flag on the files and directories on the USB stick, and chmod to give group members rw to the files on the stick. Since you've already created an ext3 file system on the stick, the permissions set on the file system entries in the stick should override any mount options.

Setting up automount can be tricky. There are tutorials available in the LinuxQuestions "Tutorials" link at the top of this page which might help, but that might be overkill for your needs. Try jschiwal's suggestion about labeling the file system on the stick. It's a good one I should have suggested myself. (The tune2fs can be used to change the label. Hum. Looking at the man tune2fs I notice that it can also be used to set the mount options for the file system. You might try that approach, and let us know if it works.

Last edited by PTrenholme; 09-24-2007 at 11:34 AM. Reason: Incorrect reference
 
Old 09-24-2007, 11:31 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Quote:
Originally Posted by ddlawrence View Post
Thanks for the pointers gents.
I used emacs to change the /etc/fstab entry for the
memory stick device to 'users' instead of 'owner'
It worked and non-root users could write to it.
But when I rebooted the change was undone.
I changed it again and checked it and rebooted.
The change was undone again.
I must be changing it wrong.


Also, how do I specify automount?

I think I will give the users the root password so they
can continue to use the memory stick. This is a small
company so I can trust them as long as I can get it
to automount.

thanks............don
How were the changes undone? Is the /etc/fstab file back the way it was before?

The "user" option allows a regular user to mount that partition without having to mount it as root.
You might want to try "users" instead if more than one user wants to mount the same pendrive.

If each user has their own pen drive, then you can have an fstab entry for each user. Using "UUID=" or "LABEL=" instead of a device and the "user", "dmask" & "fmask" options will allow controlling access to each respective pendrive (on the same machine) without the respective users needing to know the root password.
note: dmask & fmask assumes that the thumbdrive use a FAT filesystem. For a linux filesystem, use chown & chmod instead.
---
Note: by default, you can allow members of a group to execute the mount command by using the sudoers file. It is edited using the visudo program. The mount & umount commands are in a commented line. So you remove the comment character (#). Also, by default, the users own password is used for authentication rather than the root password.

Last edited by jschiwal; 09-24-2007 at 11:33 AM.
 
  


Reply



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
*** USB external hard drive and USB memory stick linux_2007_ Linux - General 1 07-17-2007 04:20 PM
USB memory, Compact Flash, Memory Stick energiza Linux - Hardware 2 08-22-2006 09:29 PM
Missing memory in USB stick, flash memory, removable hd etc bamboo_spider Linux - Newbie 3 06-14-2006 05:39 PM
USB Memory Stick coal-fire-ice Mandriva 11 12-09-2004 11:59 PM
usb memory stick linen0ise Slackware 9 10-03-2003 04:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 09:53 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
Open Source Consulting | Domain Registration