I have a server and one of it's jobs is to clone images created by DD to one of 3 targets:
- USB > SATA 2
- USB > CF (Compact Flash)
- USB > CFAST
I have written bash scripts that allows the user to select the type of image they want to clone and it does everything for them, it works great with one exception.
The device IDs of these USB Storage devices changes each time the system reboots, and what was once the system disk /dev/sda after a reboot can become /dev/sde which my script is for example assigned to CF Cloning.
So how can I force a USB device to use a specific device ID whenever it is connected or whenever the device is rebooted.
For example,
- USB > SATA 2) /dev/sdx
- USB > CF (Compact Flash) /dev/sdy
- USB > CFAST /dev/sdz
Or is there an alternative solution where I can refer to the USB device when using dd to read or write to it ??
Thanks
Edit
I tried creating a rule but it did not seem to work:
# lsusb | grep Sony
Bus 001 Device 002: ID 054c:01bd Sony Corp. MRW62E Multi-Card Reader/Writer
# udevadm info --name=/dev/sdb --attribute-walk | grep 054c
ATTRS{idVendor}=="054c"
# udevadm info --name=/dev/sdb --attribute-walk | grep 01bd
ATTRS{idProduct}=="01bd"
Created a file:
nano /etc/udev/rules.d/10-usb.rules
ACTION=="add", ATTRS{idProduct}=="01bd", ATTRS{idVendor}=="054c", SYMLINK+="sonycf"
Then tried activating it:
udevadm trigger
But /dev/sonycf does not appear in my devices.
Edit 2
Thanks @grawity
ACTION=="add", SUBSYSTEM=="block", ATTRS{idProduct}=="01bd", ATTRS{idVendor}=="054c", SYMLINK+="sonycf"
udevadm trigger --action=add --subsystem-match=block
Works a treat :-)
udev
rules which will assign a symlink such as/dev/sdX
to a particular device based on its VID and PID.