7

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?

1

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.

  • Well, trouble is, if I insert two different SDs, one after the other, they both show (on sudo blkid) two new lines: /dev/mccblk0: PTTYPE="dos") and /dev/mmcblk0p1: LABEL="EOS_DIGITAL" UUID="####-####" TYPE="vfat", albeit the latter with different IDs... – Frank Nocke Jan 10 '18 at 20:35
  • I put an update / idea into the OP. – Frank Nocke Jan 10 '18 at 20:47
  • What else could I do? maybe adding a UUID-entry for every SD card in my household? (only 3-4, so kinda feasible, but…) – Frank Nocke Jan 15 '18 at 10:20
0

What about not having the USB drives automount when they are connected. In which case, you can manually mount them as you wish. To disable automount, use dconf-editor and go to org/gnome/desktop/media-handling and disable automount by setting it to false. Then manually mount the SD card to a folder with the permissions set as you wish.

0

You could try to add a new group called sdcard and write a udev rule for your sd cards.

Let's start with the easy part and create a new group:

    sudo groupadd sdcard

Now add the user(s) to the sdcard group:

    sudo usermod -aG sdcard username

Now we have to dig for additional information about the sd card(s) you are using.
We need a product name or product id and a vendor name or vencor id

  1. plug in your sd card and type

    lsblk
    

    In my case it is /dev/sda.
    I know your device names are different, but for simplicity I will refer to the sd card as /dev/sda.

  2. Search your devices for the desired information using

    sudo lshw
    

These additional commands could help you finding the vendor and product:

  • lsusb
  • usb-devices
  • dmesg

In my case lshw provided the following information:

    *-usb:0
        description: Mass storage device
        product: USB2.0-CRW
        vendor: Generic
        physical id: 1
        bus info: usb@3:1
        logical name: scsi0
        version: 57.13
        serial: 20120926571200000
        capabilities: usb-2.00 scsi emulated scsi-host
                  configuration: driver=usb-storage maxpower=500mA speed=480Mbit/s
      *-disk
           description: SCSI Disk
           product: SD/MMC/MS PRO
           vendor: Generic-
           physical id: 0.0.0
           bus info: scsi@0:0.0.0
           logical name: /dev/sda
           version: 1.00
           serial: 2012062914345300
           capabilities: removable
           configuration: ansiversion=4 logicalsectorsize=512 sectorsize=512
         *-medium
              physical id: 0
              logical name: /dev/sda

As you can see my product is USB2.0-CRW and vendor is Generic.

  1. You can now create a file in /etc/udev/rules.d/ and call it i.e. 10-sdcard.rules

    # /etc/udev/rules.d/10-sdcard.rules
    # This file allows the group sdcard to mount sd cards
    # without administrative permissions
    
    SUBSYSTEM=="usb", ATTRS{product}="USB2.0-CRW", ATTRS{vendor}=="Generic", ACTION=="add", OWNER="root", GROUP="sdcard", MODE="0664"
    

This will add the device node for the sdcard and provide read and write permission to the sdcard group.
If you find a product id (i.e. 1234) or vendor id (i.e. abcd) instead of product name and vendor name use ATTRS{idProduct}="1234", ATTRS{idVendor}="abcd".

If your two sd cards have the same vendor id/name and product id/name this one line should be sufficient. If not add an additional line providing the information for the other sd card.

  1. Reboot your system

The users in the sdcard group should now be able to mount the sd cards.

  • Thank you! I will look at your solution, soon. – Please be patient with me, as I will only have access to my Laptop in question by Tuesday (in 5 days)… – Frank Nocke Jan 18 '18 at 8:28
0

You 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

Assuming you have a Microsoft file system (NTFS, FAT32 or exFAT) in the SD card, I suggest the following modifications:

  • Replace the mount option auto with noauto to make the system boot nicely without an SD card inserted.

    Disadvantage: You must mount the drive manually, which you can do very easily, and it will be mounted according to the line in /etc/fstab,

    sudo mount /media/ExtSD01/
    

    If you wish, you can make an alias for it,

    alias mtsd='sudo mount /media/ExtSD01/'
    
  • Add the mount option umask to provide the desired permissions for all users

The result is the following line in /etc/fstab,

/dev/mmcblk0p1  /media/ExtSD01/  auto   noauto,user,rw,umask=000  0  0

See the following link, if you want to fine-tune the mount options,

How do I use 'chmod' on an NTFS (or FAT32) partition?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.