Recovering from external zroot

My favourite terrible computer has been locking up after a VM panics and I need to panic a VM a lot to find a firmware crash. The hard power cycle reboot loop is taking too long and I'm done with it.

More annoyingly is is also hard locking up copying the VM off the machine. Thisb forced a trip to the attic, a reinstall of my large memory host (which for reasons had a 128GB NVMe, which is silly on a machine with 128GB of RAM!).

That is fine, I can pull the NVMe and drop it in an enclosure and just copy locally. For a zfs disk on a machine with an existing zroot this was turned out to be very painful. Somehow no one has written down how to do this either:

Normally zpool import take a name argument, but it can take a pool id. If you are using a machine with zfs on root then you will already have a pool called zroot , so trying to import your pool from an external drive will fail with the name already in use.

Finding the pool id can be done with the -d argument to zpool import . This takes a device to use as a pool.

# zpool import -d /dev/da3p4
  pool: zroot
    id: 647281366119489090
 state: ONLINE
status: Some supported features are not enabled on the pool.
    (Note that they may be intentionally disabled if the
    'compatibility' property is set.)
action: The pool can be imported using its name or numeric identifier, though
    some features will not be available without an explicit 'zpool upgrade'.
config:

    zroot       ONLINE
     da3p4     ONLINE

Now you can use the pool id instead of a name with zpool import

# zpool import -R /mnt -N -f 647281366119489090 -t oldzroot

With this command I ask zpool to import with a different root location ( -R ) so I don't clobber my existing file system, to not mount anything ( -N ), use the id and to use a temporary name for the pool ( -t oldzroot ).

With the pool imported you can find your dataset and mount it with zfs list and mount -t zfs .