Identify ZFS disks using /dev/disk/by-id/

by RamWise
Published: Last Updated on 5.4k views

Identifying disks in ZFS pool based on /dev/disk/by-id identifier in Linux/Debian.

Linux creates unique persistent block device identifiers to access hard drives in multiple ways. by-id is one of them, and it is derived from the disk’s serial number. More on how this identifier is computed is here

You can view all existing by-id identifiers using the below ls command.

ls -l /dev/disk/by-id/ 

It is important to create ZFS pools based on these persistent identifiers instead of their mount points like /dev/sda since they can change after a reboot or a hardware change.

Sometimes, we lose track of the device identifiers and their corresponding hard drives. Particularly, replacing the hard drives from the pool will be a nightmare, without knowing the exact mount points. Here is a way to figure it out, when you have created the zpools already using /dev/disk/by-id/.

/dev/disk/by-id

zpool status -v tank 
  • Display the disks’ serial numbers using lsblk command
lsblk -o NAME,SIZE,SERIAL,LABEL,FSTYPE 

As shown in the below screenshot you can connect the HDD names in the zpool results to the serial numbers in the lsblk command

There you go, now you can peacefully do anything with the hard drives’ mount-point that matches the serial number in the ZFS pool.

2 comments

Johan Bennink May 21, 2022 - 10:20 am

The SERIAL does not list the Id given from the zpool status command. I had to use the WWN instead of SERIAL to display the correct value. So

zpool status -v tank

lsblk -o NAME,SIZE, WWN,LABEL,FSTYPE

Reply
Johan Bennink May 21, 2022 - 10:34 am

For Sorry that was not the correct value either. For me there as no column that gave the right number but I could find that number associated with the id in /dev/disk/by-id

Reply

Leave a Comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More