Keeping same /dev/sdX disk device name after hot swap

Issues related to hardware problems
Post Reply
jhistar
Posts: 3
Joined: 2021/11/16 17:08:04

Keeping same /dev/sdX disk device name after hot swap

Post by jhistar » 2021/11/16 17:21:37

A Dell 730XD hot swap NLS SAS drive named /dev/sda failed and was replaced, but the replacement drive now has device name /dev/sdj. How do we make the device appear as /dev/sda again without rebooting ?

I've tried :
echo 1 > /sys/block/sda/device/delete
echo 1 > /sys/block/sdj/device/delete

followed by
echo "- - -" > /sys/class/scsi_host/host0/scan

with the result that the replacement drive just remains as /dev/sdj.

There is no hardware or software raid or LVM in use.

Background: There are many identically configured nodes and currently each physical drive slot maps to the same /dev/sdN device name on each node - hence I'd like to preserve that uniformity.

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Keeping same /dev/sdX disk device name after hot swap

Post by TrevorH » 2021/11/16 18:02:58

You don't. It gets whatever device name it feels like giving it and that could potentially change at every reboot. This is why things like UUIDs and LABELs exist so that you can refer to the device by something that it carries with it.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

BShT
Posts: 583
Joined: 2019/10/09 12:31:40

Re: Keeping same /dev/sdX disk device name after hot swap

Post by BShT » 2021/11/17 13:48:56

if you don´t have RAID you don´t have hot swap...

how the disk structure is rebuild?

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Keeping same /dev/sdX disk device name after hot swap

Post by jlehtone » 2021/11/17 15:24:52

BShT wrote:
2021/11/17 13:48:56
if you don´t have RAID you don´t have hot swap...
Isn't "hotswap/hotplug" what we do with USB drives too?

However, if drive was named 'sda', not part of redundant layer, did fail, got filesystem(s) mounted from it into peculiar state ... and system is still "fine" ... then can we be envious or at least curious?

The hdX/sdX/vdX are not persistent and predictable names. LABELs, UUIDs, LVM identifiers, RAID metadata, iSCSI ids are more "in the disk". (With them one hos different challenges.)

A configuration is ideally parametrized so that unpredictable names are not part of it.

BShT
Posts: 583
Joined: 2019/10/09 12:31:40

Re: Keeping same /dev/sdX disk device name after hot swap

Post by BShT » 2021/11/18 11:14:51

jlehtone wrote:
2021/11/17 15:24:52
BShT wrote:
2021/11/17 13:48:56
if you don´t have RAID you don´t have hot swap...
Isn't "hotswap/hotplug" what we do with USB drives too?

no, try to remove it on the fly then tell me...

hotplug is not hotswap and if it was, there was no doubt, no post, the plugged HD should work "out of the swap"...

jhistar
Posts: 3
Joined: 2021/11/16 17:08:04

Re: Keeping same /dev/sdX disk device name after hot swap

Post by jhistar » 2021/11/18 15:04:36

BShT wrote:
2021/11/17 13:48:56
if you don´t have RAID you don´t have hot swap...
My understanding is that hot swap isn't synonymous only with RAID eg many JBOD configurations are also hot swap. To me it seems the default way the OS behaves after a hot swap in this case makes it, well, just a swap rather than a "hot" swap.
TrevorH wrote:
2021/11/16 18:02:58
... This is why things like UUIDs and LABELs exist so that you can refer to the device by something that it carries with it.
Also my understanding is that UUIDs and LABELs are for logical not physical structures i.e. partitions, filesystems LVM entities not disk devices themselves. The drives in question do not contain either partitions or filesystems.

Disk WWNs may be viable but would require some level of human hard coding and maintenance of the 288 WWNs spread over 24 servers - exactly the kind of error prone task that computing technology was conceived to avert!

But all of this speaks to a different question than the one posed: namely how it might be best to re-implement that element of the system but as this is an inherited live production system it isn't amenable to such a fundamental change on the fly - hence my original question was necessarily limited to the expedient of solving the problem of reestablishing device naming for the single device in question on one node only.

Digressing into that same question myself though, if I was to re-implement that part of the system I'd currently be tempted to use the device names in /dev/disk/by-path (rather than /dev/sdN) as the final digit sequence of the filenames designates Host:Bus:Target:LUN where, after a bit of experimentation, Target always seems to be synonymous with the physical disk slot number on the chassis. This seems invulnerable to /dev/sdN or major/minor renumbering (but not controller renumbering) but avoids hard coding a large list of WWNs. If anyone has a better idea I'd like to hear it though.

Whoever
Posts: 1357
Joined: 2013/09/06 03:12:10

Re: Keeping same /dev/sdX disk device name after hot swap

Post by Whoever » 2021/11/19 03:34:16

jhistar wrote:
2021/11/16 17:21:37
A Dell 730XD hot swap NLS SAS drive named /dev/sda failed and was replaced, but the replacement drive now has device name /dev/sdj. How do we make the device appear as /dev/sda again without rebooting ?
What on your system is tied to the device name /dev/sda?

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Keeping same /dev/sdX disk device name after hot swap

Post by jlehtone » 2021/11/19 07:11:19

This discusses pros and cons of by-id and by-path: https://wiki.archlinux.org/title/persis ... ice_naming

jhistar
Posts: 3
Joined: 2021/11/16 17:08:04

Re: Keeping same /dev/sdX disk device name after hot swap

Post by jhistar » 2021/11/22 10:23:35

Whoever wrote:
2021/11/19 03:34:16
jhistar wrote:
2021/11/16 17:21:37
A Dell 730XD hot swap NLS SAS drive named /dev/sda failed and was replaced, but the replacement drive now has device name /dev/sdj. How do we make the device appear as /dev/sda again without rebooting ?
What on your system is tied to the device name /dev/sda?
The tying first takes place when an Ansible setup script enumerates each disk (eg sda) to be used by the application for it's own storage. I'm trying to avoid the script needing to have some kind of conditional around the device name that matches say a list of WWNs with one list of hardcoded numbers for each server. In short I'm trying to retain just the one simple, correctly parameterised setup script for all 24 machines.

Post Reply