Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #172552
| From | "Neal P. Murphy" <neal.p.murphy@alum.wpi.edu> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: 'Wiring down' hard disks |
| Date | 2016-09-20 23:20 +0200 |
| Message-ID | <sjACl-8nb-13@gated-at.bofh.it> (permalink) |
| References | <sjzwD-7F4-91@gated-at.bofh.it> <sjzwD-7F4-89@gated-at.bofh.it> |
| Organization | Murphy Retirement Home |
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.
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
'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
csiph-web