mount - how to create a udev rule for usb flash with two partitions to create persistent node under /dev? - Ask Ubuntu


i have usb flash memory, created 2 partitions on it, when attached takes sda , sda1 , sda4 instead of sdb, sdb1, sdb4. prevent confusion decided create udev rule symlink under /dev persistently.

i created below rule

action=="add", subsystem=="usb", attrs{idvendor}=="0461", attrs{idproduct}=="4d81", symlink+="myusb" 

when reboot creates symlink under /dev/myusb can not mount it.

 sudo mount /dev/myusb /media/myusb   mount: /dev/bus/usb/002/003 not block device 

i think error because contains 2 partitions. shoul do?

i think problem cannot mount whole drive several partitions @ once. have mount each partition itself. mounting means getting access filesystem, can different on 2 different partitions. , how put 2 filesystems 1 directory? have have @ least 2 subdirectories /media/myusb/part1.

that said uuids , labels.

you create udev rule triggering script mounts 2 partitions uuid, like

#!/bin/bash  mount /dev/disk/by-uuid/xxxxx-xxxx-xxxxx-xxxxxx /media/myusb/part1 mount /dev/disk/by-uuid/yyyyy-yyyy-yyyyyy-yyyyy /media/myusb/part2 

alternatively place partitions /etc/fstab, , let udev mount -a .

use 'blkid' print universally unique identifier device; may used uuid= more robust way name devices works if disks added , removed.

maybe try that:

for partition one:

kernel=="sd?1", subsystems=="usb", attrs{idvendor}=="0461", attrs{idproduct}=="4d81", symlink+="myusb1" 

for partition two

kernel=="sd?4", subsystems=="usb", attrs{idvendor}=="0461", attrs{idproduct}=="4d81", symlink+="myusb2" 

not sure if works, give try.

https://oracle-base.com/articles/linux/udev-scsi-rules-configuration-in-oracle-linux https://wiki.ubuntuusers.de/udev/


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User