0

The following is taken from an embedded system which does not have hard drive in it.

KERNEL=="sd?", SUBSYSTEMS=="usb", DRIVERS=="usb-storage", NAME="sda"
KERNEL=="sd?2", SUBSYSTEMS=="usb", DRIVERS=="usb-storage", NAME="sda2" RUN+="/bin/mount -n -o sync /dev/sda2 /media/usb2"
KERNEL=="sda2" ACTION=="remove", RUN+="/bin/umount -n /media/usb2"

Is it for auto mount and unmount? Can anyone provide brief explanation?

Thanks.

1

This is for both mounting and unmounting, the clue is in the RUN+= command.

KERNEL=="sd?", SUBSYSTEMS=="usb", DRIVERS=="usb-storage", NAME="sda"

# mounting
KERNEL=="sd?2", SUBSYSTEMS=="usb", DRIVERS=="usb-storage", NAME="sda2" RUN+="/bin/mount -n -o sync /dev/sda2 /media/usb2"

# unmounting
KERNEL=="sda2" ACTION=="remove", RUN+="/bin/umount -n /media/usb2" 

Particularly for USB devices that get mapped to sda2. Usually your fixed drive gets mapped to the sda space, so this rule might not ever get triggered, unless it is on an embedded system without an internal drive or running in a live environment.

I see you tagged with embedded so this rule seems valid indeed.

  • Thanks invert. Could you please share what does the first line mean? – New to Rails Nov 25 '13 at 7:46
  • The first line will match like the rest of the rules, but there is no action associated with it. It is obviously added as a template for you to reuse in your own rules. For more on udev see reactivated.net/writing_udev_rules.html – invert Nov 26 '13 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.