0

I have an ASUS laptop with Realtek Card Reader RTL8411B. I must install Debian with kernel version 4.15.3 - there is no any other option.

The first problem was in standard rtsx_pci driver which seems to ignore this card reader at all. Connecting SD card to laptop didn't cause appearance of any device in /dev directory or any new records in syslog and other logs too.

After reading some forums I understood that this problem in driver and there are two possible options to solve it:

  1. Change kernel version with all kernel modules.

  2. Build new driver for current kernel.

So I choose the second one and build custom driver form https://github.com/M0Rf30/rts_bpp. Driver problem was solved. And now I get a new device /dev/sdb:

brw-rw---- 1 root disk 8, 16 may 13 13:47 /dev/sdb

But when the common user from disk group is trying to mount /dev/sdb to his own directory he recieves an error.

$ mount /dev/sdb /home/user/media
mount: /dev/sdb: Operation not permitted

I also created udev rule to set MODE="0666" for /dev/sdb device and now I have a device with permissions:

brw-rw-rw- 1 root disk 8, 16 may 13 13:53 /dev/sdb

But mount is still finishes with error. And not only mount.

$ mount /dev/sdb /home/user/media
mount: /dev/sdb: Operation not permitted
$ ls -l /dev/sdb
ls: can't get access to '/dev/sdb': Operation not permitted

Using this device with 'sudo' perfectly works but reading and writing data to/from SD card is available only for superuser.

So what I need to change to give access for all users to card reader device?

1 Answer 1

1

The actual 'mount' system call is only available to root. The device node's permissions are irrelevant (and should be left as 0660, and you really shouldn't be putting unprivileged users in the 'disk' group).

There are several options for unprivileged access:

  • Run the mount command via sudo, and specify the correct synthetic UID/GID/permissions through filesystem options – most cards hold the FAT filesystem, so you have to specify uid=.

    sudo mount /dev/sdb /mnt -o uid=$(id -u),gid=$(id -g)
    
  • Add an /etc/fstab entry for the SD card, with the 'user' option (relying on the fact that the 'mount' command is setuid):

    /dev/disk/by-path/usb-Foo-Bar-part1 /mnt auto user 0 0
    

    Using the symlinks from /dev/disk/by-path allows you to identify that specific card reader regardless of it being 'sdb' or 'sdc' today.

  • Use the pmount wrapper to mount the card, which will enforce the correct options:

    pmount /dev/sdb
    
  • Use the UDisks service to mount the card, which will always be mounted under /run/media/$USER (though there is an udev property to make it use /media instead):

    udisksctl mount -b /dev/sdb
    

    With UDisks, the card will always be mounted under /run/media/$USER (though there is an udev property to make it use /media instead). This is the same mechanism that's used by GNOME, KDE and Xfce to allow unprivileged USB stick access.

4
  • I have already try to add /etc/fstab entry. Result is the same - operation not permitted. Commented May 13, 2021 at 11:09
  • I also tried to mount like this "sudo mount /dev/sdb /mnt -o uid=$(id -u),gid=$(id -g)". But after that mount point looks like this "d????????? ? ? ? ? ? media" with ls command. When I try to enter directory by cd I get "operation not permitted" error. Commented May 13, 2021 at 11:13
  • udisksctl mount -b /dev/sdb - the same result, device is mounted but it's impossible to enter directory. And I don't have pmount in my OS and local repository, but I thinks it will not help as other options. Commented May 13, 2021 at 11:17
  • And I don't have any problems with usb devices. I can add user to floppy group or add /etc/fstab entry and user can mount and use usb device. Commented May 13, 2021 at 11:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .