I'm trying to write a udev rule to not mount USB devices plugged into my system if they're bootable, but I don't know how to specify in udev if a device is bootable in a rule. Is that possible? If so, what needs to go into my rule?To be clear, by bootable, I mean the device has an OS that I can boot into at start up.
How to detect if USB device is bootable in udev?
boot;usb;udev
udev adds some environment variables to the partition node (leaf node) including partition entry flags for MBR table. Bootable partition should have ID_PART_ENTRY_FLAGS=0x80.Try this rule and you gonna see all environment variables (source: Pass ATTR{idVendor} as argument in udev script): KERNEL=sd[a-z][1-9], RUN+=/bin/sh -c 'echo == >> /home/username/Desktop/usb-storage.txt; env >> /home/username/Desktop/usb-storage.txt'A rule that works for me in Ubuntu 14.04:ACTION==add, KERNEL==sd[a-z][1-9], ENV{ID_PART_ENTRY_FLAGS}==0x80, RUN+=/bin/sh -c 'echo 0 > /sys%p/../../../../../../../authorized'