On Tue, 20 Sep 2016 20:03:46 +0000 (UTC)
<ch_e...@yahoo.com> wrote:

> Hi
> Could someone please advise me the best way to ensure a particular hard disk 
> (SATA) always appears at a specific device node, i.e how can I be sure 
> /dev/sdb for example is always going to refer to a specific drive even if 
> others are added or removed?
> UUIDs only apply to partitions, is there no way to do a similar thing for a 
> physical disk?
> I have some existing partitioned and formatted disks in a server which I want 
> to plug into another machine and move the services over to a VM

Not possible; udev's detection order is not defined (meaning the order can 
change from boot to boot).

However, there are options that can accomplish almost the same thing. Look at 
the things in /dev/disk/.

If you know the drives' serial numbers (from the barcode on its front), you can 
symlink /dev/vdska to one drive's link in /dev/disk/by-id, and /dev/vdskb to 
the other drive's link there. Thus vdska and vdskb will always refer to those 
two drives, respectively. Or just use the link in /dev/disk/by-id and forget 
about the 'real' node.

Aside, I just happened to notice that .../by-uuid and .../by-partuuid both seem 
to link to partition nodes and none of the by-uuid UUIDs matches a disk or 

It would seem Dan is right. Use the wwn- nodes in by-id.

Something like this might help you correlate serial# and WWN:
  for i in /sys/block/sb*; do
    eval `/sbin/udevadm info -q all -p /sys/block/sdb|egrep -i 
"id_serial_short|id_wwn=" | cut -c 4-`
    if [ ! -z "$ID_SERIAL_SHORT" ]; then
      rm -f /dev/vdska
      ln -s /dev/disk/by-id/wwn-$ID_WWN /dev/vdska
  for i in /sys/block/sb*; do
    eval `/sbin/udevadm info -q all -p /sys/block/sdb|egrep "$SERIAL|WWN" | 
egrep "ID_SERIAL_SHORT|ID_WWN=" | cut -c 4-`
    if [ ! -z "$ID_SERIAL_SHORT" ]; then
      rm -f /dev/vdskb
      ln -s /dev/disk/by-id/wwn-$ID_WWN /dev/vdskb

Plug in the right serial numbers and this bit of script creates the dsk[ab] 

Reply via email to