Permission denied - USB drive
Solved
Hello,
I currently have a Raspberry Pi 3 B.
I have plugged in a USB stick, and I am unable to copy a file or folder onto it.
(It works in root, BUT):
I have an open proftpd server, and I want to put files on this USB stick, but I don't have the permissions.
-I would like to know how to grant all rights on this stick to all users of the machine.
Thank you in advance :)
I currently have a Raspberry Pi 3 B.
I have plugged in a USB stick, and I am unable to copy a file or folder onto it.
(It works in root, BUT):
I have an open proftpd server, and I want to put files on this USB stick, but I don't have the permissions.
-I would like to know how to grant all rights on this stick to all users of the machine.
Thank you in advance :)
1 answer
-
Hello,
Generally speaking, it is not a good idea to grant access rights to everyone on a key. Typically, only the user who mounted the key has write permissions on it, and that is the correct approach. When access needs to be granted to multiple users, it is better to define a group that includes the people who have access to the key in question.
In any case, all of these questions are resolved at the time of mounting the key (see commandmount
), which allows you to specify the owner user of the key, the owner group, and the associated rights to the files on the key.
In your case, the key will be identified by a device (for example/dev/sdb1
, assuming that/dev/sda
corresponds to your hard drive). You can find this information using the commandsudo fdisk -l
.
Next, you need to create an empty directory (mount point) where the key will appear. Let's say/media/usb
.
sudo mkdir -p /media/usb
Then you mount the key, with the right options (once again, I insist: this is NOT a command I recommend, but it does what you're asking):
sudo mount -o default,rw,user,dmask=000,fmask=111 /dev/sdb1 /media/usb
For more details, seeman mount
and this link to understand mask issues. Basically,dmask
andfmask
correspond to the rights associated with directories and regular files.
To understand what follows, readman chmod
beforehand to understand how the octal syntax used by this command is defined.
The mask values correspond to the complement (in the mathematical sense) of the mask passed to thechmod
command (so for example, applyingchmod 755
on directories means setting admask
equal to022
). To put it simply,mask_chmod + dmask = 777
. The principle is the same forfmask
.
Good luck!-
-
Thank you mamiemando, I managed to do it thanks to a Ubuntu forum. I just copied 2-3 lines into the /etc/fstab file.
For the commandsudo mount -o default,rw,user,dmask=000,fmask=111 /dev/sdb1 /media/usb
. I looked at (and tried to understand at the same time) the permissions, and I saw that default could be an issue, so I removed it, and it worked :D
I restarted the Raspberry, and :) it didn't work anymore :-| I went back to the /etc/fstab file to remove the default that I hadn't seen.
Now it's perfect.
Thank you <3 -
-