0
John Henry

opi3 sdcard hotplug via udev, but fail. Why?

Recommended Posts

I have move system to emmc, and want to use sdcard to storage videos from camera. So I want to sdcard can automount/umount after hotplug.

I have try to use udev to fulfill it. But it seems not work.

I add a rules for udev at /etc/udev/rules.d:

ACTION=="add",KERNEL=="mmcblk2p1",RUN+="/etc/udev/sdcard_hotplug.sh add /home/opi/Videos/sdcard %k"
ACTION=="remove",KERNEL=="mmcblk2p1",RUN+="/etc/udev/sdcard_hotplug.sh remove /home/opi/Videos/sdcard %k"

And add a shell file at /etc/udev/sdcard_hotplug.sh

#!/bin/bash
case $1 in
	add)
		mkdir -p $2
		mount -t exfat -o iocharset=utf8,rw,sync,umask=0000,dmask=0000,fmask=0000 /dev/$3 $2
		;;
	remove)
		umount $2
		rm -rf $2
		;;
esac

Add chmod a+x for it. Test it ok.

 

But udev seems not work!

I have use udev monitor to test if remove and insert sdcard can generate event. It works. 

And use udevadm test, and it also ok.

 

Anybody can help me?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
0