Permission denied - USB drive

Solved
Anonymous user -  
mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   -
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 :)

1 answer

  1. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 943
     
    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 command
    mount
    ), 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 command
    sudo 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, see
    man mount
    and this link to understand mask issues. Basically,
    dmask
    and
    fmask
    correspond to the rights associated with directories and regular files.

    To understand what follows, read
    man 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 the
    chmod
    command (so for example, applying
    chmod 755
    on directories means setting a
    dmask
    equal to
    022
    ). To put it simply,
    mask_chmod + dmask = 777
    . The principle is the same for
    fmask
    .

    Good luck!
    0
    1. Anonymous user
       
      Well.. I'm going to spend another 5 hours learning new things. Thank you ❤️
      0
    2. Anonymous user
       
      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 command
      sudo 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
      0
    3. mamiemando Posted messages 33228 Registration date   Status Moderator Last intervention   7 943
       
      Congratulations and best wishes for the future :-)
      0