Saturday 29 December 2018

linux - How do I auto mount a USB drive that all users can write to?


I'm trying to set up a Raspberry Pi to run BitTorrent Sync to back up my files to an external hard drive, but I'm running into some frustrating issues.


First, I need to set up the USB hard drive to auto-mount on boot, because the power frequently goes out where I live. So, I added a line to /etc/fstab


/dev/sda1   /media/josiah    vfat    defaults   0   0

I rebooted, and it mounted the drive, but then btsync couldn't write to it. So, I did a little reading and found that you have to specify the user option, so I tried this;


/dev/sda1   /media/josiah    vfat    defaults,user   0   0

That didn't seem to work either, so I tried specifying all of the defaults manually


/dev/sda1   /media/josiah    vfat    rw,auto,user,async,suid,dev,exec    0   0

I thought it was working, but then btsync started complaining again that it couldn't write to the drive, and when I tried to unmount it as a normal user it said that only a super user can unmount the drive.


That's confusing to me, since I thought that's what the user option was for. What am I missing, or doing wrong?



Answer



You can do a chmod after you mounted the partition, but that wouldn't be persistent accross reboots.


You should try this fstab line:


/dev/sda1   /media/josiah    vfat    user,umask=0000   0   0

Or this mount options:


mount -t vfat -ouser,umask=0000 /dev/sda1 /media/josiah

That will make the mounted partition world readable and writable.


If you need a less permissive setup, you should create a new group and mount as follows:


mount -t vfat -ouser,gid=1010,umask=0007 /dev/sda1 /media/josiah

It assumes your new group's gid is 1010. All users that need access to the mountpoint will need to be added to the new group.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...