2

I had one ZFS pool attached to a system that crashed. I was looking for ways to bring that pool to a new system however it looked like I need to use zfs export first, given I do not have access to the original system any more so I can't do zfs export etc.

The main complication is that I had 4 external drives attached to that system and only two of those were part of the ZFS pool. I actually do not remember how I set them up or which of those 4 USB drives part of the the ZFS pool, but I remember that only two of those 4 drives were part of the ZFS pool.

How do I mount the pool on a new system, given I do not have the initial conditions anymore?

I am using 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux

Thanks

yarun can
  • 1,060

1 Answers1

2

zpool import is indeed the one and only command to import ZFS pools, both those that were properly zpool exported before and those that were not.

You should first check with zpool list if the pool hasn’t already be imported. If that is not the case, zpool import will list all pools available for import. If the pool was not exported first, you may need the -f flag. You can look at specific devices using zpool import -d.

Combined, it could look like this:

# zpool import -d /home/daniel/zpool-test-1.img
   pool: test123
     id: 12638011090530745002
  state: DEGRADED
status: One or more devices are missing from the system.
 action: The pool can be imported despite missing or damaged devices.  The
        fault tolerance of the pool may be compromised if imported.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-2Q
 config:
    test123                           DEGRADED
      mirror-0                        DEGRADED
        /home/daniel/zpool-test-1.img  ONLINE
        /home/daniel/zpool-test-b.img  UNAVAIL  cannot open

(I forced this problem by renaming the files.)

You would then simply import the pool:

zpool import -d /home/daniel/zpool-test-1.img test123

I recommend you do not use zpool import -a, just to make sure you only deal with the ZFS pool you want to.

You can then use zfs list to find out where stuff is mounted. ZFS takes care of that automatically (unless specifically told not to).


You can inspect pool devices without importing them using zdb:

# zdb -l zpool-test-1.img
------------------------------------
LABEL 0
------------------------------------
    version: 5000
    name: 'test123'
    state: 1
    txg: 19
    pool_guid: 12638011090530745002
    errata: 0
    hostname: 'server'
    top_guid: 6892256335198247059
    guid: 11629412553399697108
    vdev_children: 1
    vdev_tree:
        type: 'mirror'
        id: 0
        guid: 6892256335198247059
        metaslab_array: 64
        metaslab_shift: 29
        ashift: 9
        asize: 5363990528
        is_log: 0
        create_txg: 4
        children[0]:
            type: 'file'
            id: 0
            guid: 11629412553399697108
            path: '/home/daniel/zpool-test-a.img'
            create_txg: 4
        children[1]:
            type: 'file'
            id: 1
            guid: 1859957653576985949
            path: '/home/daniel/zpool-test-b.img'
            create_txg: 4
    features_for_read:
        com.delphix:hole_birth
        com.delphix:embedded_data
        com.klarasystems:vdev_zaps_v2
    labels = 0 1 2 3

Just try all the partitions until you find the right one(s).


You should be able to identify the devices/partitions containing ZFS with fdisk -l unless you chose “incorrect” (non-descriptive) partition type IDs. For “full-disk” vdevs, ZFS creates two GPT partitions nowadays, one of type “Solaris /usr & Apple ZFS” and one of type “Solaris reserved 1”.

But ideally, just connect all the drives and let ZFS figure it out, it really should find the pool automatically on regular block devices, USB or not.

user219095
  • 65,551