1

I need to have udev mount a USB device that has raw data, which appears like /dev/sdc, but in the same time if another stick has partitions I only need to have folders mounted only for those partitions.

I have attempted with a udev rules like:

ACTION=="add", ENV{myBusID}!="", ENV{myDevID}!="", ENV{myPartition}!="", ENV{dir_name}="usb-%k-%E{myBusID}-%E{myDevID}-%E{myPartition}", GOTO="skip_device"


#Set mount directory for partitionaless sticks
SUBSYSTEM=="block", ACTION=="add",  ENV{myBusID}!="", ENV{myDevID}!="", ENV{myPartition}=="",  ENV{dir_name}="usb-%k-%E{myBusID}-%E{myDevID}--%E{myPartition}"


#Label
LABEL="skip_device

However, with the above example I will have a folder created for the device too if the USB stick has partitions.

A use-case would be buying a brand new USB stick, stick it in a Windows device, format it VFAT and then insert it in the Linux system.

Mentions: I cannot use udisks or other similar software, I'm quite bound to have this running by using udev rules.

1 Answer 1

2

Try this:

# Set mount directory for partition-less sticks
SUBSYSTEM=="block", ACTION=="add", ENV{myBusID}!="", ENV{myDevID}!="", ENV{myPartition}=="", ENV{ID_PART_TABLE_TYPE}=="", ENV{dir_name}="usb-%k-%E{myBusID}-%E{myDevID}--%E{myPartition}"
1
  • Indeed, it looks like the ID_PART_TABLE_TYPE is the only difference between the two cases and has the value "dos" for the USB stick with partitions
    – Alex C
    Mar 4, 2015 at 15:49

You must log in to answer this question.

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