User avatar
RDK
Posts: 254
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Mounting USBStick for R/W for all users

Tue Sep 16, 2014 5:58 pm

Folks......I have a USB-stick always in my Raspberry Pi at bootup. This line is in the /etc/fstab file

Code: Select all

/dev/sda1 /mnt/usbdrive vfat defaults 0 0
I have read the "defaults" contains the option rw which I assumed meant that everyone could create and write to this device. However when I try to

Code: Select all

cp /etc/fstab /mnt/usbdrive 
I get this error
cp: cannot create regular file `/mnt/usbdrive/fstab': Permission denied
. If it is prefixed with sudo, of course it works.

Here is

Code: Select all

ls -all /mnt
output
drwxr-xr-x 3 root root 8192 Sep 16 18:12 usbdrive
Can anyone help me get this right?....RDK

User avatar
RDK
Posts: 254
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Mounting USBStick for R/W for all users

Thu Sep 18, 2014 4:55 am

Hmmm, could this be because the USBStick is FAT and you can't set permissions on FAT?....RDK


User avatar
RDK
Posts: 254
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Mounting USBStick for R/W for all users

Thu Sep 18, 2014 7:23 am

lmarmisa....Thanks for the reply. I read the references and I changed the fstab line for the USBStick as follows

Code: Select all

/dev/sda1 /mnt/usbdrive vfat defaults,dmask=027,fmask=137 0 0
Rebooted and I get the same results as before, only the root can copy files to the USBStick.

Thanks again....RDK

User avatar
rpdom
Posts: 15004
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Mounting USBStick for R/W for all users

Thu Sep 18, 2014 8:11 am

Try

Code: Select all

/dev/sda1 /mnt/usbdrive vfat defaults,dmask=000,fmask=111 0 0
The mask negates the standard permissions, so effectively you get ( 777 - dmask ) as the directory permissions.

User avatar
RDK
Posts: 254
Joined: Wed Aug 13, 2014 10:19 am
Location: Wyoming and France

Re: Mounting USBStick for R/W for all users

Thu Sep 18, 2014 8:52 am

rpdom....WOW and thanks. Your code works like a champ. Thanks again....RDK

Return to “Beginners”