Fix ZFS device names

So you screwed up and created zpool using /dev/sdb instead of /dev/disk/by-id/ata-* as a device? Then you tried to fix it and ended up with cryptic wwn- as device name. Here's dirty solution. Make sure to run those commands right after each other. Otherwise it will get imported back with wrong device names automatically -- before you have time to do it with correct names.

root@pve:~# zpool status -v
  pool: jemmapool
 state: ONLINE
  scan: scrub repaired 0B in 01:42:18 with 0 errors on Mon Jan  8 12:37:01 2024
config:
        NAME                               STATE     READ WRITE CKSUM
        jemmapool                          ONLINE       0     0     0
          sdb                              ONLINE       0     0     0
errors: No known data errors

root@pve:~# zpool export jemmapool && \
            mv -f /dev/disk/by-id/wwn* /dev/disk/by-id/usb* /dev/disk && \
            zpool import -d /dev/disk/by-id/ jemmapool && \
            mv -f /dev/disk/wwn* /dev/disk/usb* /dev/disk/by-id/

root@pve:~# zpool status -v
  pool: jemmapool
 state: ONLINE
  scan: scrub repaired 0B in 01:42:18 with 0 errors on Mon Jan  8 12:37:01 2024
config:
        NAME                               STATE     READ WRITE CKSUM
        jemmapool                          ONLINE       0     0     0
          ata-ST8000DM004-2CX188_WSC0ZW9T  ONLINE       0     0     0
errors: No known data errors


Comments