Ubuntu – SD card operations from multiple user accounts

card-readermountmulti-userpermissionssd card

I am running Ubuntu MATE 16.04 and copying images to and from my internal SD card reader basically works fine… on my main account.

If another family member logs in (my login still active in the background, not logged out) and then inserts an SD card, he can't access it:

enter image description here

So, is this some kind of rights issue…? Logging back in as the main user, I also see some rights issues:

enter image description here

So, whatever it is, how can I loosen up access rights on the SD card reader, so it becomes accessible to everyone (including non-admin users)?

Perhaps some ‘relaxed’ etc/fstab entry? (no related entry there yet)


Update I:

Switching back & forth between 2 SD cards (from a single user) and looking at /dev/disk/by-id:

?> ~ $ ll /dev/disk/by-id | grep mmc
...  mmc-SDU1_0x02400f04 -> ../../mmcblk0
...  mmc-SDU1_0x02400f04-part1 -> ../../mmcblk0p1
?> ~ $ ll /dev/disk/by-id | grep mmc
...  mmc-SE32G_0x0072e5ab -> ../../mmcblk0
...  mmc-SE32G_0x0072e5ab-part1 -> ../../mmcblk0p1
?> ~ $ ll /dev/disk/by-id | grep mmc
...  mmc-SDU1_0x02400f04 -> ../../mmcblk0
...  mmc-SDU1_0x02400f04-part1 -> ../../mmcbl

?> ~ $ ll /dev/disk/by-id | grep mmc
...  mmc-SDU1_0x02400f04 -> ../../mmcblk0
...  mmc-SDU1_0x02400f04-part1 -> ../../mmcblk0p1
?> ~ $ ll /dev/disk/by-id | grep mmc
...  mmc-SE32G_0x0072e5ab -> ../../mmcblk0
...  mmc-SE32G_0x0072e5ab-part1 -> ../../mmcblk0p1
?> ~ $ ll /dev/disk/by-id | grep mmc
...  mmc-SDU1_0x02400f04 -> ../../mmcblk0
...  mmc-SDU1_0x02400f04-part1 -> ../../mmcblk0p1

../../mmcblk0[p1]/dev/mmcblk0[p1] seems to be the only constant here. Perhaps I can get a solution with this?

I added this to /etc/fstab (according to man page, the first param may also be a device path, if I understand correctly):

/dev/mmcblk0p1  /media/ExtSD01/  auto   auto,user,rw 0 0

This worked somewhat nicely, now that I can mount /dev/mmcblk0p1/ and unmount to the user-neutral path, not automatically but at least from command line (disadvantage 1). However my system hang an reboot – unless I have an SD card inserted before boot (disadvantage 2). So I removed that line again…

Maybe there's another place to edit mount options in Ubuntu Mate? system.d? Elsewhere?

Best Answer

To mount SD card at startup for all users, we need an entry in the fstab file. What is happening presently is, the SD card is getting mounted for the user who logs in which gives access permissions to only that user. By adding an entry in the fstab, the SD card will be mounted by root with access to all users. this r/w access can be controlled later on.

sudo blkid lists down all partitions(including of your SD card) available on your system. Note down the UUID of the partition that you want to mount at boot.

now create a folder, for example sudo mkdir /media/ExtSD01. This is the folder where your SD card partition will be mounted at. This folder will be owned by root. To give other users permission to r/w into this folder we need to give the proper permissions. so chmod -R 777 /media/ExtSD01 would be good enough. Now you need to edit your fstab file. to do so, type the following command.

sudo nano /etc/fstab

go to the bottom of the file and add the following line there.

UUID='enter your UUID here' /media/ExtSD01/     auto,user,rw 0 0

Reboot system and you should be good to go.

Related Question