Whenever I insert/remove SD card, my ubuntu doesn't recognize those behaviors automatically. I have to run lspci command to manually tell ubuntu about the hardware change.
I want to make my ubuntu automatically detect the SD card. (auto-detecting the hardware change, not auto-mounting the file system)
Here is the detailed steps to use SD card on my ubuntu:
- Insert SD card to the computer. No new messages on
dmesg. - Run
lspcicommand on terminal. Then the new messages appear ondmesg. - Mount the SD card and do something. When finished, unmount the SD card.
- Remove SD card physically from the computer.
dmesgsays nothing about this detachment. - Run
lspcicommand again. Thendmesgsaysmmc0: card aaaa removed.
Some additional information:
- I'm using ubuntu 18.04.3 LTS with RTS5227 card reader.
- No problem with mount, read, write and unmount.
Any suggestions appreciated.
1 Answer
A lengthy Q&A on Unix & Linux addresses this issue:
After many pages of scrolling the solution is a new udev rule:
# enable in-kernel media-presence polling
ACTION=="add", SUBSYSTEM=="module", KERNEL=="block", ATTR{parameters/events_dfl_poll_msecs}=="0", ATTR{parameters/events_dfl_poll_msecs}="2000"
ACTION=="add", ATTR{removable}=="1", ATTR{events_poll_msecs}=="-1", ATTR{events_poll_msecs}="2000"The Q&A is far too long to repost here, but please read the entire link to learn more.