Mount and access external media

From eLinux.org
Revision as of 22:24, 22 June 2020 by GoTouch (talk | contribs) (Created page with "<p>Once Raspberry Pi OS is installed and running, a default 'pi' user is created. I have a SSD drive in USB 3.0 enclosure plugged in. Every time after booting up, it is mounte...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Once Raspberry Pi OS is installed and running, a default 'pi' user is created. I have a SSD drive in USB 3.0 enclosure plugged in. Every time after booting up, it is mounted under /media/pi/label.

I have another user foo, as there are several users for this box and I don't wait to use the default 'pi'. And I added user foo in root group for root group privilege.

Problem: I can't go to /media/pi to access the SSD drive

To find the problem, first thing:

~$ ls -l /media
drwxr-x---+ 2 root root 4096 Jun 21 14:19 pi

So it looks all good, root group has r-x access. However there is a '+' at end of the permission. What is it? Maybe something hidden there. I found the answer by searching online. We need the ACL tool getfacl/setfacl to find out:

~$ <code>sudo apt-get install acl</code>
~$ getfacl /media/pi
# file: media/pi 
# owner: root
# group: root
user::rwx
user:pi:r-x
group::---
mask::r-x
other::---

Now it is clear. Group members don't have any access right. The r-x is just the mask. So to grant access to group members:

~$ sudo setfacl -m g:root:rx /media/pi
~$ getfacl /media/pi
# file: pi
# owner: root
# group: root
user::rwx
user:pi:r-x
group::---
group:root:r-x
mask::r-x
other::---

Now user foo in group root is able to access /media/pi and the mounted external SSD drive under it.