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.

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}"
  • 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 '15 at 15:49

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.