You are not logged in.

#1 2011-03-27 07:20:45

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Card reader and udev

Hello, I have an internal usb card reader. It works but not perfectly.

The problem that I have is that udev does not recognise media insertion/removal. It only recognises the usb device insertion/removal.

I can make it work by emulating a usb device insertion/removal by giving it to a VirtualBox Windows VM (where, incidentally, it "just works"). Upon releasing the device from the VM the host regains it and creates a device node for any inserted media at that time.

It does not sense any removal/insert of media after that. To force it I have to emulate a device removal/insert as above.

I have tried a "udevadm control restart" but this does not detect any inserted media.

My workaround is ok but somewhat cumbersome. Is there something that I am missing here that I need to do? Please any help appreciated...

Last edited by starfry (2011-03-27 07:21:27)

Offline

#2 2011-03-27 14:15:33

lagagnon
Member
From: an Island in the Pacific...
Registered: 2009-12-10
Posts: 1,087
Website

Re: Card reader and udev


Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.

Offline

#3 2011-03-27 15:48:18

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Re: Card reader and udev

That's just for auto-mounting, if I understand correctly?

The problem I have is that the device files for the media aren't created so even mounting manually is impossible.

What I need is for something to trigger udev when a medium is added or removed from the card reader (not when the card reader itself is added or removed from the computer).

Windows does this flawlessly, surely we can...?

Offline

#4 2011-03-28 01:56:42

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: Card reader and udev

starfry wrote:

udev does not recognise media insertion/removal

So have you tried udev's logging, or not?

Offline

#5 2011-03-28 20:19:49

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 230

Re: Card reader and udev

brebs wrote:

So have you tried udev's logging, or not?

Yes. I enabled logging with

udevadm control --log-priority=debug

Lots of stuff in log file for device insertion/removal. Nothing in log for media insertion/removal.

Offline

#6 2011-04-09 20:31:08

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: Card reader and udev

Thanks!  Solved my problems.

File: /etc/udev/rules.d/11-sd-cards-auto-mount.rules

KERNEL!="mmcblk[0-9]p[0-9]", GOTO="sd_cards_auto_mount_end"

# Global mount options
ACTION=="add", ENV{mount_options}="relatime"
# Filesystem specific options
ACTION=="add", IMPORT{program}="/sbin/blkid -o udev -p %N"
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"

ACTION=="add", RUN+="/bin/mkdir -p /media/sd-%k", RUN+="/bin/ln -s /media/sd-%k /mnt/sd-%k", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/sd-%k"
ACTION=="remove", RUN+="/bin/umount -l /media/sd-%k", RUN+="/bin/rmdir /media/sd-%k"
LABEL="sd_cards_auto_mount_end"


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#7 2011-04-24 18:50:03

moose jaw
Member
From: Milwaukee
Registered: 2007-08-20
Posts: 104

Re: Card reader and udev

starfry wrote:

The problem I have is that the device files for the media aren't created so even mounting manually is impossible.

What I need is for something to trigger udev when a medium is added or removed from the card reader (not when the card reader itself is added or removed from the computer).

I have just the same problem with the card reader on my laptop. Udev doesn't register card insertion/removal at all: no device nodes show up under /dev/sd* or /dev/mmcblk*

One solution that works for me is to use hal instead. I don't use hal for anything else, but it's easy enough to "/etc/rc.d/hal start", and then upon insertion the card shows up under /dev/sd*. The problem, long term, is that hal is deprecated and is going away, and that there doesn't seem to be any udev-based solution, at least with this hardware.

Edit: FWIW, the laptop in question is a Lenovo Thinkpad Edge 13

Last edited by moose jaw (2011-04-24 18:52:28)

Offline

Board footer

Powered by FluxBB