Ubuntu: How to list drives by ID

If you’re creating a  zpool on Ubuntu you have several options when it comes to referring to the drives; the most common is /dev/sda, /dev/sdb and so on. This can cause problems with zpools as the letter designated to a drive can change if you move the drives around, add or remove a drive – causing your zpool to come up as faulty. One way to avoid this is to use a more specific name for the disk, one of which is the ID. You can find this on Ubuntu through the following command:

 

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

 

This gives an output similar to the following:

 

lrwxrwxrwx 1 root root  9 Oct 19 08:48 ata-ST2000DM001-9YN164_W1F01W57 -> ../../sdd

lrwxrwxrwx 1 root root  9 Oct 19 08:48 ata-ST2000DM001-9YN164_W2400946 -> ../../sdc

lrwxrwxrwx 1 root root  9 Oct 19 08:48 ata-ST2000DM001-9YN164_W24009TB -> ../../sde

lrwxrwxrwx 1 root root  9 Oct 19 08:48 ata-ST2000DM001-9YN164_W2402PBQ -> ../../sdb

lrwxrwxrwx 1 root root  9 Oct 19 08:48 ata-ST2000DM001-9YN164_Z24064V7 -> ../../sda

 

You can see that the command helpfully points which ID is associated with which /dev/sd?.