zfsonfreebsd / ZoF

ZFS on FreeBSD - the official out of tree OpenZFS implementation for FreeBSD
https://freebsd.org
Other
100 stars 8 forks source link

`unable to read the metaslab array [error=5]` while importing the pool #159

Closed kandeshvari closed 4 years ago

kandeshvari commented 4 years ago

Maybe wrong place to ask this, but give me hope...

FreeBSD 12.1-p8

I had mirror on two geli partitions. I have replaced one disk with bigger one, resilvered it completely but I mixed up with geli encryption keys. After reboot new vdev didn't attached, so the pool was running on the one old vdev. I have detached new vdev for fixing geli keys issue. Fixed it and reboot again, but I forgot to attach new vdev back to pool! After reboot this pool has switched to FAILURE state and doesn't want to import now.

I've tried to do some magic with zpool import -Ffm zroot, but it fails:

cannot import 'zroot': I/O error
        Destroy and re-create the pool from
        a backup source.

I tried to use zdb -e zroot for debugging, but it fails also with:

zdb: can't  open 'zroot': Input/output error

...debug messages...
disk vdev '/dev/ada0p4.eli': best uberblock found for spa zroot. txg 26002478
disk vdev '/dev/ada0p4.eli': unable to read the metaslab array [error=5]
disk vdev '/dev/ada0p4.eli': vdev_load: metaslab_init failed [error=5]
...

So I can't import pool and can't add new vdev to exported pool (if it possible - I don't know how to do it).

In the result, I have one broken pool on one vdev and two detached vdevs with recent data (old vdev and new one).

My questions:

  1. How to fix broken pool? ))
  2. Is it possible to add second, good vdev to the exported pool and try to import it again?
  3. Can I assemble new pool with data from old pool and those two detached disks with data? Maybe some tools for-internal-use exists?
  4. If all above is negative - where to start to learn zfs internals to debug my issue thoroughly, and create tool that would create "Frankenstain's pool" from these three disks?

Any help will be appreciated

allanjude commented 4 years ago

Can you summarize the state of each disk.

I expect you should be able to import the pool using one of the 2 detached disks (although this version of the pool will be behind from the time where it was detached).

Did something happen to the ada0p4.eli vdev? I don't understand how it might have been damaged if you only detached ada1p4.eli etc.

kandeshvari commented 4 years ago

Thank you for answering, Allan.

Let me describe all steps I done

In the result:

You have mentioned there is a possibility to extract pool metadata from the detached disks. If I understand you right - how to do it?

kandeshvari commented 4 years ago

I have solved it. I recovered old pool from detached mirrored vdev.

For future searchers: https://gist.github.com/kandeshvari/6d6a267263585123009c98120957131f