Test platform-hisi-dv500
To implement automatic mounting on a Linux system after a TF card (Micro SD card) is inserted, similar to the fact that the insertion of an SD card/TF card will also trigger kernel events. You can use the udev tool to monitor and process these events and create a udev rule file. To capture the TF card insertion event.
1: Create a udev rules file, such as /etc/udev/rules.d/100-tfcard.rules, and add rules
2:添加SUBSYSTEM=="block", ACTION=="add", KERNEL=="mmcblk*", RUN+="/opt/sdcard.sh"
Where mmcblk* is your tfcard, /opt/sdcard.sh is your mounting script
3: Create a mount script
#!/bin/sh
# device node
DEVICE="/dev/mmcblk1" #sd card
MOUNT_POINT="/opt/sd" # mount dir
# check if mount dir exit if not create it
if [ ! -d "$MOUNT_POINT" ]; then
mkdir -p "$MOUNT_POINT"
fi
# mount
mount "$DEVICE" "$MOUNT_POINT"
4: Make rules take effect udevadm control --reload-rules
5: Give the script permission chmod a+x sdcard.sh
Test: automatic mounting successful