Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #172549 > unrolled thread

'Wiring down' hard disks

Started by<ch_edge@yahoo.com>
First post2016-09-20 22:10 +0200
Last post2016-09-21 17:20 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.debian.user

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  'Wiring down' hard disks <ch_edge@yahoo.com> - 2016-09-20 22:10 +0200
    Re: 'Wiring down' hard disks Dan Ritter <dsr@randomstring.org> - 2016-09-20 22:20 +0200
    Re: 'Wiring down' hard disks "Neal P. Murphy" <neal.p.murphy@alum.wpi.edu> - 2016-09-20 23:20 +0200
    Re: 'Wiring down' hard disks Reco <recoverym4n@gmail.com> - 2016-09-21 17:20 +0200

#172549 — 'Wiring down' hard disks

From<ch_edge@yahoo.com>
Date2016-09-20 22:10 +0200
Subject'Wiring down' hard disks
Message-ID<sjzwD-7F4-89@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

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
Many thanks 

Sent from Yahoo Mail. Get the app

[toc] | [next] | [standalone]


#172550

FromDan Ritter <dsr@randomstring.org>
Date2016-09-20 22:20 +0200
Message-ID<sjzGh-7MY-9@gated-at.bofh.it>
In reply to#172549
On Tue, Sep 20, 2016 at 08:03:46PM +0000, ch_edge@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

That's a WWN -- look in /dev/disk/by-id/*

It identifies the disk itself, plus a -part* for partitions on
it.

-dsr-

[toc] | [prev] | [next] | [standalone]


#172552

From"Neal P. Murphy" <neal.p.murphy@alum.wpi.edu>
Date2016-09-20 23:20 +0200
Message-ID<sjACl-8nb-13@gated-at.bofh.it>
In reply to#172549
On Tue, 20 Sep 2016 20:03:46 +0000 (UTC)
<ch_edge@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 partition.

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

Something like this might help you correlate serial# and WWN:
(
  SERIAL=Y3Q3DK9N
  for i in /sys/block/sb*; do
    unset ID_SERIAL_SHORT ID_WWN
    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
    fi
  done
  SERIAL=Y3GA2FXN
  for i in /sys/block/sb*; do
    unset ID_SERIAL_SHORT ID_WWN
    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
    fi
  done
)

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

[toc] | [prev] | [next] | [standalone]


#172589

FromReco <recoverym4n@gmail.com>
Date2016-09-21 17:20 +0200
Message-ID<sjRtw-2de-13@gated-at.bofh.it>
In reply to#172549
	Hi.

On Tue, Sep 20, 2016 at 08:03:46PM +0000, ch_edge@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

It's possible, although unless you're trying to change device's
permissions permanently you'd better use those /dev/disk/by-id symlinks
instead.

What you'd need is a custom udev rule like this (in a single line):

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/lib/udev/scsi_id -g -d $devnode",
RESULT==<UUID>, NAME=<devicename>

Where device UUID can be obtained by:

/lib/udev/scsi_id -g <your_block_device_here>


Another dirty hack (as it's not intended to be used this way) whould be
configuring multipathing with a single path representing your disk
device.

Reco

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web