Steps to set auto-mount points with udev rules:
------------------------------------------------
1. Create a directory where to mount the device.
2. go to "/etc/udev/rules.d/"
3. create a file with name "10-local-devs.rules"
4. copy and paste below udev rules.
# Begin - udev rules
# import : port 5-1
# The below rules are for the port 5-1 (KERNELS=="5-1" and KERNEL=="sd?").
# And the mount point expecting to be at /import directory.
ACTION=="add", SUBSYSTEM=="block", SUBSYSTEMS=="usb", KERNELS=="5-1", KERNEL=="sd?", OWNER="root", MODE="400", SYMLINK+="import", RUN+="/bin/su root -c '/bin/mount /dev/import /import"
ACTION=="remove", SUBSYSTEMS=="usb", SUBSYSTEM=="block", KERNELS=="5-1", KERNEL=="sd?", RUN+="/bin/umount /import"
ACTION=="remove", SUBSYSTEMS=="usb", SUBSYSTEM=="block", KERNELS=="5-1", KERNEL=="sd?", RUN+="socket:@import.drive.event"
ACTION=="remove", SUBSYSTEMS=="usb", SUBSYSTEM=="block", KERNELS=="5-1", KERNEL=="sd?", RUN+="socket:@import.bite.event"
# This is for a single device, need to add similar rules for multiple devices.
# End - udev rules
5. The above rules is for a single device, and need to add similar rules for each port.
There are two chages required to run in a machine.
1. KERNELS key
Modify the KERNELS key to correspoing port number. e.g., "5-1"
2. KERNEL key
Modify the KERNEL key to correspoing node name. e.g., "sd?"
To identify a KERNELS & KERNEL key values,
run "udevadm info -a -p <sysfs-path-to-parent-node>
If the attached node name is, /dev/sda1, the its sysfs-path will be
"/sys/block/sda"
6. After creating the rules, run "udevadm control --reload-rules"
7. Now, for the next time when the device is plug-in, the device automatically
mounted to specified paths
USB keyboard - udev rules:
--------------------------------------------
SUBSYSTEMS=="usb", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceProtocol}=="01", ENV{ID_CLASS}="kbd", SYMLINK+="input/keyboard0"
No comments:
Post a Comment