I have a USB flash memory, I created two partitions on it, when it is attached sometimes it takes sda , sda1 and sda4 instead of sdb, sdb1, sdb4. To prevent that confusion I decided to create a udev rule to symlink it under /dev persistently.
I created the below rule
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0461", ATTRS{idProduct}=="4d81", SYMLINK+="myusb"
When I reboot it creates symlink under /dev/myusb
but I can not mount it.
sudo mount /dev/myusb /media/myusb
mount: /dev/bus/usb/002/003 is not a block device
I think I get that error because it contains two partitions. So what shoul I do?
I think the problem is that you cannot mount a whole drive with several partitions at once. You have to mount each partition for itself. Mounting means getting access to the filesystem, which can be very different on two different partitions. And how would you put two filesystems into one directory? You have to have at least two subdirectories like
/media/myusb/part1
.That said we are back to UUIDs and labels.
You could create an udev rule triggering a script that mounts the two partitions by their uuid, like
Alternatively you could place the partitions into /etc/fstab, and let udev do a
mount -a
.Use 'blkid' to print the universally unique identifier for a device; this may be used with UUID= as a more robust way to name devices that works even if disks are added and removed.
Maybe you could try that:
For partition one:
For partition two
Not sure if it works, but you could give it a try.
https://oracle-base.com/articles/linux/udev-scsi-rules-configuration-in-oracle-linux https://wiki.ubuntuusers.de/udev/
First of all I want to thank all who responded, they guided me on the right path.
At first I checked out devices to locate usb stick
My usb stick grabbed
sda
sda1
andsda4
(I haven't found a way to assign sda to primary disk yet)Then I did an
attribute-walk
to get related parameters withI used
ATTRS{serial}
andATTR{partition}==1
,ATTR{partition}==2
as distinguishing IDs.works for partition 1