mount USB drive as user
Hi,
I have some external USB drives (WD) which are not considered by system as removable. I have one with NTFS and two with FAT32. When I try to mount I get error: rafal@linux-39sr:~> mount /dev/sdb1 /mnt/usb1 mount: only root can do that I know this was discussed several times, but no solution worked for me. Here what didn't work: 1) chmod +s /bin/mount chmod +s /bin/umount 2) giving sudo: In YaST (I am using suse) I added my user option to execute /bin/mount, but it still does not work. maybe its about the access to /dev/sdb1 ? I don't want to add any entry to /etc/fstab because I have several USB slots and disks. Some are NTFS, some FAT32. If I add entry in fstab then I never sure whether next time my sdb1 will be FAT32 or NTFS. It depends which drive I will connect as first (and maybe only one). What I have to do in order to give access for my user to mount everything I want. regards Rafal |
There are various options I would try. First off, create an entry in fstab with the user option, but without the type specified.
Now since you specified user you should be able to mount it as a user, however you have not define the type yet. Try: -t autofs -t vfat,ntfs (mount will try these in this order) -t vfat (if you are sure it is vfat) -t ntfs (likewise) Reading thru man fstab I get the idea that other options are retrieved from fstab but that you are free to specify the type in the command. jlinkels |
To resolve the problem where the same drive may have a different device node the next time you boot or plug it in, use the uuid or label instead of the device.
Suppose that the partition to mount is /dev/sdb. Then run "udevinfo -q env -n /dev/sdb". There will be a line like: FS_UUID=ABC123-123432 Copy the UUID= and the number after it and paste it in the fstab entry in place of /dev/sdb. For fat32 partitions, to be able to mount them as root, you need the "user" or "users" option and UID= and GID= options as well. Then a regular user can mount and unmount the partition. You can use either your username or your uid number. The mount command is normally an suid program. It checks the mount options in /etc/fstab to determine whether a regular user will be allowed to use the command or not. |
Quote:
Thanks for advise. I executed the command and added the line to /etc/fstab: Code:
UUID=B06A38A66A386AEC /mnt/usb1 ntfs-3g users,gid=users,locale=pl_PL.UTF-8 0 0 here the error I get: Code:
rafal@linux-39sr:/mnt> mount /mnt/usb1 Only user 'root' have access to /dev/sdb1 Once I read I should add my user to group "disk' but it is not solution So what can I do to get access to /dev/sda1. chmod ? I tested with "chmod 777" and afterwards get another error: Code:
rafal@linux-39sr:/mnt> mount /mnt/usb1 what will be clean solution here? The reason why I need to mount device manually is that sometimes I'm using "Blackbox" as x-manager. regards Rafal |
modding /etc/fstab should be all you need to do.
Well, that and adding said user to the disk group. And maybe chgrp the mount point. /dev/uba1 /mnt/usb vfat user,noauto 0 0 /dev/sda1 /mnt/usb vfat user,noauto 0 0 /dev/sdf1 /mnt/usb vfat user,noauto 0 0 $ chgrp disk /mnt/usb $ cat /etc/group | grep -i "disk" disk:x:6:user $ mount /mnt/usb or $ mount /dev/uba1 depending on which device or which usb port I use. Or if it's plugged in at boot time, versus inserted later. Check /proc/partitions to see what it registered as. (if it registered) $ cat /proc/partitions HTH |
Adding a user to the disk group is a bad idea. That is the group owner of the raw devices as well. You want to grant access to one partiton, not all of them and not the raw devices (such as /dev/sdb) as well. Making a typo as a member of the disk group, you can wipe out any partition.
Read the web page that the error message points to. It gives solutions. You can also use the ntfs filesystem. It might not work if the ntfs partition was formatted in vista and there are volume flags that aren't supported. Using these options, and the ntfs filesystem, I can mount it as a normal user:"rw,user,fmask=117,dmask=007,uid=jschiwal,gid=jschiwal" However, due to unsupported features, it is mounted read-only. |
This may be over simplistic and not what you need but could you install and use pmount?
|
Quote:
man mount says: Quote:
|
The "users" option is similar to the "user" option. Using "users" any user can umount it. Maybe "user" would be a better option. There is also the "owner" option. Even if a different user mounts a fat32 partition, the uid=, gid=, fmask= and dmask= options will determine whether that user can read or write.
Use fmask and dmask instead of simply umask. You don't want the files to have the "x" bit set. You need the directories to have the "x" bit set. The "x" bit has different uses for files & directories so you need to use fmask & dmask instead. |
All times are GMT -5. The time now is 10:29 PM. |