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/.
- Display the status of zfs pool using zpool status command.
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.