LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 02-09-2009, 12:39 AM   #1
Tomás Ó hÉilidhe
LQ Newbie
 
Registered: Feb 2008
Location: Southeast Asia (sunny!)
Distribution: Xubuntu
Posts: 28

Rep: Reputation: 15
Permissions for mounting file systems


I know there's more than one way of doing this, but I'm asking for advice on how you think it should be done.

OK so I have my own laptop, and I have my own user account in Linux. My username is "toe" and my group is "grp_toe". I log into my Xfce desktop with my "toe" username. I have "automatic mounting" turned off in Xfce, meaning I have to manually mount my own devices.

My "/mnt" folder belongs to "root:root". Here are its permissions:

Code:
drwxr-xr-x  10 root  4096 2009-02-07 13:26 mnt
Within my "/mnt" folder, I have a folder called "sdb1", which is where I mount my USB stick drive. Most of the time, the USB sticks I mount will have the FAT32 filesystem (which doesn't have Linux permissions). Here's the permissions:

Code:
drwxrwxrwx 2 root root      4096 2008-12-01 23:02 sdb1
My fstab file only contains two entries: one for "proc", and the other for my Linux partition. As follows:

Code:
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>        <options>                     <dump>  <pass>
proc            /proc           proc          defaults                          0       0
/dev/sda3       /               ext3          relatime,errors=remount-ro        0       1
Presently, I mount my FAT32 USB stick drive with:

Code:
sudo mount /dev/sdb1 /mnt/sdb1
(If I try it without "sudo", then I get "mount: only root can do that").

After I do this, I can read from my USB stick but I can't write to it. (I don't know why, because the "sdb1" folder has full write permissions for all users). Anyway when I navigate into the sdb1 folder, I see that all the contents belong to "root:root".

Of course, if I do:

Code:
su
(Then enter my password)
, then I'm logged in as root and I can write to the USB stick.

I'd like people's advice on how I should go about doing this properly.

Here's my questions:
1) What should the permissions of the "/mnt" folder be?
2) What should the permissions of the "/mnt/sdb1" folder be?
3) What should I put in my fstab file (note that I don't want to specify a filesystem in my fstab file because sometimes the USB stick will be FAT32, and other times it might be ext3).
4) How should I mount my USB stick (should I use "sudo"?)

Thanks for listening.
 
Old 02-09-2009, 06:23 PM   #2
athor
LQ Newbie
 
Registered: Feb 2009
Location: Sweden
Distribution: Slackware
Posts: 19

Rep: Reputation: 1
Hi

On number 1 and 2, I would choose, drwxr-xr-x root root..

On number 3, I would try something like:
Code:
/dev/sdb1 /mnt/sdb1 auto noauto,users,rw 0 0
Guess it would meet your requirements.

And for number 4; If you use the above fstab you probably wont need to use sudo for mounting sdb1, but I guess it's good when you need your cd or something, so most probably you need to add the following line to visudo (run in terminal as root)
Code:
%wheel  ALL=/sbin/mount
where you can replace %wheel with %users if you like. It's also possible without password
Code:
%wheel ALL=(ALL) NOPASSWD:/sbin/mount
. If there are any problems with permissions when you mount, with or without sudo, you can simply specify an UID. Ie
Code:
mount /dev/sdb1 /mnt/sdb1 -o uid=your_uid_here
(if you dont know ur uid, just type id followed by your username)
 
Old 02-09-2009, 06:23 PM   #3
irishbitte
Senior Member
 
Registered: Oct 2007
Location: Brighton, UK
Distribution: Ubuntu Hardy, Ubuntu Jaunty, Eeebuntu, Debian, SME-Server
Posts: 1,213
Blog Entries: 1

Rep: Reputation: 88
Have a couple of mount scripts, something like this (for FAT32):

Code:
sudo mount -t vfat /dev/sdb1 /mnt/usb
sudo chown -R toe:grp_toe /mnt/usb
You can change this script and have a couple of scripts for mounting different USB keys. Give it a go, and let us know how you get on.
 
Old 02-11-2009, 07:34 PM   #4
openSauce
Member
 
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Rep: Reputation: 39
Quote:
Originally Posted by irishbitte View Post
Have a couple of mount scripts, something like this (for FAT32):

Code:
sudo mount -t vfat /dev/sdb1 /mnt/usb
sudo chown -R toe:grp_toe /mnt/usb
You can change this script and have a couple of scripts for mounting different USB keys. Give it a go, and let us know how you get on.
I don't think this will work, as FAT32 doesn't support linux ownership/permissions.

The mount options uid,gid,fmask and dmask (or just umask) determine ownership and permissions for FAT or NTFS filesystems - check out the mount manpage (the permissions and ownership of the mountpoint are ignored once the filesystem is mounted).

If you include the users option in your fstab as per athor's reply, you should be able to mount without sudo, but I think you may need write permissions to /mnt/sdb1 to be able to do this.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mounting 2 file systems to one directory leupi Linux - Networking 7 01-21-2006 10:29 PM
Mounting to file systems n e r d Linux - Hardware 3 07-22-2004 07:53 AM
Mounting NTFS File Systems quorn Linux - General 7 10-09-2003 02:56 PM
mounting two file systems to one point sophie Linux - Hardware 4 07-01-2003 12:47 PM
mounting file systems philfighter Linux - General 5 08-20-2001 08:20 PM

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

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