Page 1 of 1

udev for hot-swapping eSATA drives

Posted: Mon Apr 13, 2009 11:58 am
by bthylafh
I have an eSATA drive cradle hooked up to an Ubuntu 8.10 system. I want to write a udev rule such that any drive plugged into the cradle will have the same device name (it boots as /dev/sdb) and preferably the same /dev/sg* device as well. Hot-swap is working at the moment, but if I unplug one drive and plug in another, it gets a new devname (/dev/sde) and a different /dev/sg device.

Any suggestions?

Re: udev for hot-swapping eSATA drives

Posted: Mon Apr 13, 2009 12:40 pm
by notfred
When you hotswap is anything else already grabbing later devices? I wonder if you end up with sde as something else already has sdc and sdd (Optical drives, card readers etc).

I'm running Ubuntu 8.10 and I see /etc/udev/rules.d/61-persistent-storage-edd.rules that does hook up disks to /dev/disk/by-id/<blah> based on their id, although this is kind of the opposite of what you are looking for in that different disks will get farmed out to different paths, but at least the same disk always gets farmed out to the same path regardless of what /dev/sd<blah> it is. The network and CD stuff in 70-persistent-net.rules 70-persistent-cd.rules and their generators at 75-cd-aliases-generator.rules 75-persistent-net-generator.rules might be closer to what you are looking for, especially the network one.

Re: udev for hot-swapping eSATA drives

Posted: Mon Apr 13, 2009 12:48 pm
by bthylafh
notfred wrote:
When you hotswap is anything else already grabbing later devices? I wonder if you end up with sde as something else already has sdc and sdd (Optical drives, card readers etc).


This computer's got two hard drives in sdc and sdd, which are in a software RAID 1; sda is the boot drive. The two optical drives seem to be scd0 and scd1. The eSATA device is sdb on bootup.

I'm running Ubuntu 8.10 and I see /etc/udev/rules.d/61-persistent-storage-edd.rules that does hook up disks to /dev/disk/by-id/<blah> based on their id, although this is kind of the opposite of what you are looking for in that different disks will get farmed out to different paths, but at least the same disk always gets farmed out to the same path regardless of what /dev/sd<blah> it is. The network and CD stuff in 70-persistent-net.rules 70-persistent-cd.rules and their generators at 75-cd-aliases-generator.rules 75-persistent-net-generator.rules might be closer to what you are looking for, especially the network one.


OK, I'll have a look.

Re: udev for hot-swapping eSATA drives

Posted: Mon Apr 13, 2009 1:52 pm
by bthylafh
There's a utility called PySDM that can customize udev rules. I'm going to try that out.

Re: udev for hot-swapping eSATA drives

Posted: Mon Apr 13, 2009 3:09 pm
by bthylafh
It fails horribly, will start up but the window is grayed out and doesn't display anything. Pity.