It is important to know a position of a bad drive in a multi-bay device, however default naming of drives e.g /dev/sda, /dev/sdb etc. does not provide a clue where a particular drive is residing physically.

I have an 8-bay external JBOD enclosure used for backup. It hosts a ZFS pool and is connected to an Arch Linux box. Is it possible on a Linux system which uses systemd/udev to name drives according to their physical location in the enclosure instead of /dev/sd*?

I would like the names to reflect the physical position of a drive in the enclosure /dev/encl1, /dev/encl2... or similar. I would prefer these labels to appear by default instead of /dev/sd* in lsblk and zpool status.

I do know location of every drive in the enclosure, and keep this information in a file, but it would be way better to see it with lsblk and other commands directly.

I tried to create rules at /etc/udev/rules.d like


And I do get such symlinks after running udevadm trigger, but they are not equivalent to /dev/sd* and I was not able to use them as a substitution.

  • There are already names that are more informative than /dev/sd*. Take a look at /dev/disk/by-id/ and the other directories under /dev/disk.
    – larsks
    Jan 7 at 14:43
  • @larsks, my specific usecase it to know the position of a drive in the enclosure by its name, so I can find it quickly in case of trouble.
    – dimus
    Jan 7 at 15:38
  • How about the by-path?
    – vidarlo
    Jan 7 at 15:46
  • @vidarlo, by-path still does not allow to tell that this particular drive is for example located 2nd from the top in the enclosure
    – dimus
    Jan 7 at 15:47
  • Can you use lshw -c disk -c storage | grep -E 'bus info|logical name to give you a hint on the disk bays? I expect that the bus info will be incrementing uniformly following the bay numbers.
    – doneal24
    Jan 9 at 17:00

2 Answers 2


Writing up my comment as an answer.

Use the command

lshw -c disk -c storage | grep -E 'bus info|logical name’

to map device names to pci devices. The device id’s will increment uniformly, with the lowest id for bay 1.

You can also use udevadm to get the device id in devices.

udevadm info --name=/dev/nvme6

You can now give the disk devices names corresponding to the physical slot they are installed in. Edit or create /etc/udev/rules.d/my.rules. You can rename the device with the rules.

KERNEL=="nvme*", SUBSYSTEM=="nvme", ENV{PHYSDEVPATH}=="*pci0000:20/0000:20:01.3/0000:25:00.0*", NAME="bay6"
KERNEL=="nvme*", ENV{DEVTYPE}=="partition", SUBSYSTEM=="nvme", ENV{PHYSDEVPATH}=="*pci0000:20/0000:20:01.3/0000:25:00.0*", NAME="bay6p%n"

If you have sd devices instead or nvme, change the SUBSYSTEM to block.

It's possible to put in an alias instead of renaming the device. Look at SYMLINK+="bay6" in the udev documentation.

  • in my case it is already known where drives are located in the enclosure, the question is how to show this information conveniently in the name of the drives. For example multipath does it well by creating an alias to wwid data, and this alias appears as the default name for a drive
    – dimus
    Jan 10 at 1:48
  • @dimus Added device renaming to my answer.
    – doneal24
    Jan 10 at 13:24
  • Thank you for expansion of your answer @doneal24, as you can see in my question, I did succeed in making aliases, how can I make them show by default though?
    – dimus
    Jan 10 at 14:20
  • @dimus I don't use zfs so this is a guess. Look at this and the man page for zpool-import. It looks like you can use something like zpool-import -d /dev/bay1 -d /dev/bay2 -d... poolname.
    – doneal24
    Jan 10 at 14:37
  • yes, i did post an answer about doing just that, but it is only a partial answer, I would love to be able to change default names for drives to have a more general solution.
    – dimus
    Jan 10 at 14:39

This is only a partial answer to the question which does work to provide a bay position information for ZFS:

  1. I used parted to change labels for ZFS paritions to something like encl1-3DS where the first part is the bay position and the second is the unique part of the drive's serial.
(parted) p
Model: xxx (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name       Flags
 1      1049kB  4001GB  4001GB               encl4-28P
 9      4001GB  4001GB  8389kB
  1. zpool export <zpool-name>

  2. zpool import -d /dev/disk/by-partlabel <zpool-name>

  3. Now zpool status -v shows

❯ zpool status -v
  pool: ext
 state: ONLINE
  scan: scrub repaired 0B in 05:42:24 with 0 errors on Fri Jan  6 20:15:57 2023

    ext            ONLINE       0     0     0
      raidz1-0     ONLINE       0     0     0
        encl1-PT8  ONLINE       0     0     0
        encl7-C32  ONLINE       0     0     0
        encl4-28P  ONLINE       0     0     0
        encl2-N75  ONLINE       0     0     0
        encl5-ZT1  ONLINE       0     0     0
        encl6-9RP  ONLINE       0     0     0
        encl8-88F  ONLINE       0     0     0

errors: No known data errors

Not sorted, but it is already much better than /dev/sd*

Still, I would love to have a more general solution that would make a custom alias a default.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .