How to import a child of a broken zpool mirror on a different host

zfszfsonlinux

I have a hard disk lying around which once belonged to a 3-disk ZFS mirrored pool on a Ubuntu 12.04 server, called d510. The disk was properly detached but its filesystem tank0 was not exported.

I would now like to recover a handful of files off this disk by mounting it on a different, Xubuntu 14.04 desktop system. On this desktop system, the disk is seen as:

$ ls /dev/disk/by-id/
...
ata-WDC_WD10EADS-00M2B0_WD-WCAV51264701
ata-WDC_WD10EADS-00M2B0_WD-WCAV51264701-part1
ata-WDC_WD10EADS-00M2B0_WD-WCAV51264701-part9
...

The data appears to be solely on the part1 partition as part9 is very small. However, the zdb command reveals that this particular disk partition was once child 2 and called differently on the Ubuntu 12.04 server, namely scsi-SATA_WDC_WD10EADS-00_WD-WCAV51264701-part1.

$ sudo zdb -l /dev/disk/by-id/ata-WDC_WD10EADS-00M2B0_WD-WCAV51264701-part1
--------------------------------------------
LABEL 0
--------------------------------------------
    version: 5000
    name: 'tank0'
    state: 0
    txg: 0
    pool_guid: 8764435549195071605
    hostname: 'd510'
    top_guid: 4212287141343472152
    guid: 10584802241354722513
    vdev_children: 1
    vdev_tree:
        type: 'mirror'
        id: 0
        guid: 4212287141343472152
        metaslab_array: 31
        metaslab_shift: 33
        ashift: 12
        asize: 1000189984768
        is_log: 0
        create_txg: 4
        children[0]:
            type: 'disk'
            id: 0
            guid: 4518508443267048848
            path: '/dev/disk/by-id/scsi-SATA_WDC_WD10EARS-00_WD-WCAV56475795-part1'
            whole_disk: 1
            DTL: 118
            create_txg: 4
            resilvering: 1
        children[1]:
            type: 'disk'
            id: 1
            guid: 12490123066008148558
            path: '/dev/disk/by-id/scsi-SATA_WDC_WD10EARS-00_WD-WCAV56524564-part1'
            whole_disk: 1
            DTL: 120
            create_txg: 4
            resilvering: 1
        children[2]:
            type: 'disk'
            id: 2
            guid: 10584802241354722513
            path: '/dev/disk/by-id/scsi-SATA_WDC_WD10EADS-00_WD-WCAV51264701-part1'
            whole_disk: 1
            DTL: 126
            resilvering: 1
    features_for_read:
    create_txg: 0
--------------------------------------------
LABEL 1
--------------------------------------------
...

Because of this difference in id name, I created the following soft links:

sudo ln -s ata-WDC_WD10EADS-00M2B0_WD-WCAV51264701 scsi-SATA_WDC_WD10EADS-00_WD-WCAV51264701
sudo ln -s ata-WDC_WD10EADS-00M2B0_WD-WCAV51264701-part1 scsi-SATA_WDC_WD10EADS-00_WD-WCAV51264701-part1
sudo ln -s ata-WDC_WD10EADS-00M2B0_WD-WCAV51264701-part9 scsi-SATA_WDC_WD10EADS-00_WD-WCAV51264701-part9

Still, as with previous less sophisticated attempts, the filesystem will not import (nor export for that matter):

$ sudo zpool import -o rdonly=on -d . -D -f -X -R /mnt 8764435549195071605
no pools available to import

Any suggestions about how to import this orphaned ZFS mirror disk on this different host?

Should I perhaps create even more soft links for the other drives and partitions pointing to this single drive?

The data for sure is still available on the disk, however ZFS on Linux seems to be rather picky about what it is allowed to be imported. ZFS pools are great on the system where these are created, but recovery and upgrade scenarios seem to be severely hindered by this behaviour.

From the Oracle Solaris documentation

When a pool is created, it is intrinsically tied to the host system. The host system maintains information about the pool so that it can detect when the pool is unavailable. source

but still

If you do not explicitly export the pool, but instead remove the disks manually, you can still import the resulting pool on another system. However, you might lose the last few seconds of data transactions, and the pool will appear faulted on the original system because the devices are no longer present. source

Best Answer

Some thoughts:

  • According to the man page, -D only imports pools that have been destroyed. Maybe your pool was never destroyed and will therefore not show up?

  • Maybe those options could help you?

    -F
        Recovery mode for a non-importable pool.
        Attempt to return the pool to an importable
        state by discarding the last few transactions.
        Not all damaged pools can be recovered by
        using this option. If successful, the data
        from the discarded transactions is
        irretrievably lost. This option is ignored if
        the pool is importable or already imported.
    
    
     -n
        Used with the -F recovery option. Determines
        whether a non-importable pool can be made
        importable again, but does not actually
        perform the pool recovery. For more details
        about pool recovery mode, see the -F option,
        above.
    
Related Topic