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 Answer 1

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.

2
  • Thanks invert. Could you please share what does the first line mean? Commented Nov 25, 2013 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
    Commented Nov 26, 2013 at 13:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .