I killed my ZFS root pool, how to get going again from backup?

Hi!

Totally my fault, I killed my servers root ZFS pool. It can’t be imported no more (only with zfs_recover=1), I don’t know the exact message. I only know that all that I could find says: save what you can, start with a fresh pool. Good thing I do have backups.

So I created a new mirror on two SATA SSDs I had lying around (I don’t want to overwrite the NVMes just yet, and these two held the pool before) with the exact same naming of the pool and its datasets and mountpoints. After a few zfs send | zfs receive over SSH everything seems to be back where its supposed to.

But I hit a wall: I get a kernel panic everytime I try to boot, I think I have every other property set correctly. Here’s the bluescreen:

The pool imports fine with an Arch live iso with ZFS integrated, I can chroot into it just fine. Bootmanager is ZBM, just as it has been before.

Any idea what I must’ve missed?

Uploaded your screenshot and this URL to Copilot Premium at work. Here’s what it said:

Summary

I would not rebuild the pool again yet. The strongest clue is that the replacement pool imports normally from the Arch live environment and the restored system is chroot-able, while ZFSBootMenu gets far enough to launch the installed kernel. ZFSBootMenu itself is a small Linux environment that imports ZFS pools, locates a boot environment’s kernel/initramfs, and then launches them with kexec. [zfsbootmenu.org]

The screenshot then shows PID 1 (init) exiting with status 1, which causes the kernel panic. So I’d troubleshoot the installed system’s initramfs/root-pool handoff first.

Most likely fixes, in order

1. Rebuild the installed system’s initramfs

This is the first thing I would try.

zfs send | zfs receive restores datasets, but you have created an entirely new pool. Even with the same pool name and dataset names, the new pool is not literally the old pool.

Boot the Arch ZFS live ISO, import and mount the new root, chroot into it as you’ve already been doing, then regenerate the initramfs using whatever your Arch installation uses.

For standard Arch mkinitcpio:

mkinitcpio -P

Before doing so, inspect:

cat /etc/mkinitcpio.conf

and make sure the configuration you’re restoring actually contains the ZFS hooks/modules appropriate to the original installation.

This is particularly important because ZFS root pools are imported from the initramfs before the real root filesystem can be mounted. [openzfs.github.io]

If rebuilding the initramfs fixes it, my interpretation would be that the restored initramfs contained stale information or configuration from the original root pool.


2. Check /etc/hostid very carefully

This would be my second-highest-probability suspect, particularly because this is Arch + ZFSBootMenu.

From the live environment, compare:

hostid

against the restored system:

cat /mnt/etc/hostid | od -An -tx4

or, once chrooted:

hostid

ZFS records the host ID associated with the machine that imported a pool, and /etc/hostid provides that ID on Linux. A missing or conflicting host ID can cause pool-import problems. [openzfs.github.io]

This is especially relevant to ZFSBootMenu. The ZBM documentation states that /etc/hostid is copied into the generated initramfs/UEFI bundle, and ZBM supports spl_hostid= and zbm.import_policy specifically for controlling this behavior. [docs.zfsbootmenu.org]

And there is an Arch-specific wrinkle: a ZFSBootMenu maintainer notes that Arch’s mkinitcpio does not respect the spl_hostid command-line mechanism in the same way as dracut, and recommends ensuring the systems use the same host ID. [github.com]

If appropriate for this installation, generating the hostid is normally done with:

zgenhostid

Then rebuild the initramfs:

mkinitcpio -P

Do not blindly replace an existing valid hostid, though. First inspect what you have.


3. Verify the replacement pool’s bootfs

Check:

zpool get bootfs <pool>

For example:

zpool get bootfs zroot

Then list the hierarchy:

zfs list -r <pool>

The bootfs property should identify the dataset that is actually the boot environment.

This matters to ZFSBootMenu because when it selects a pool, it can use that pool’s bootfs property to choose the default boot environment. [docs.zfsbootmenu.org], [zfsbootmenu.org]

If the original pool had something conceptually like:

zroot/ROOT/arch

as bootfs, merely recreating:

zroot/ROOT/arch

doesn’t necessarily restore the pool-level bootfs property.

If you’ve verified that the desired root dataset is, say:

zroot/ROOT/arch

then the corresponding repair would be:

zpool set bootfs=zroot/ROOT/arch zroot

Use the actual names from zfs list, not that example.


4. Compare all ZFS dataset properties, not just names and mountpoints

This part of your description jumps out:

“with the exact same naming of the pool and its datasets and mountpoints”

That’s necessary, but it may not be sufficient.

Run:

zfs get -r all <pool>

Pay particular attention to:

mountpoint

canmount

org.zfsbootmenu:commandline

encryption

keylocation

keyformat

Also examine:

zpool get all <pool>

The important idea here is:

Reproducing the filesystem hierarchy does not necessarily reproduce every pool-level property involved in booting.

ZFSBootMenu behavior can be controlled through ZFS filesystem properties as well as its kernel command-line configuration. [docs.zfsbootmenu.org]


5. Check the ZFSBootMenu kernel command line

From the ZFSBootMenu recovery shell:

zbmcmdline

ZBM documents zbmcmdline specifically for displaying the aggregated command line coming from /etc/cmdline, /etc/cmdline.d/, and /proc/cmdline. [docs.zfsbootmenu.org]

Look especially for:

root=

spl_hostid=

zbm.prefer=

and anything that references the pool or root dataset.

I would compare what ZBM thinks it should boot against:

zpool get bootfs <pool>

zfs list -r <pool>

If root= points somewhere other than the restored boot environment, that’s an obvious lead.


6. Check for a stale zpool.cache

Inspect:

ls -l /etc/zfs/zpool.cache

and:

zdb /etc/zfs/zpool.cache

The OpenZFS documentation specifically says /etc/zfs/zpool.cache records imported pools for subsequent automatic import. It also notes that stale or absent cache data can be bypassed by scanning devices. [openzfs.github.io]

Because the replacement pool was newly created, I would be suspicious of a zpool.cache restored from the old system.

I wouldn’t immediately delete it, though. First inspect whether it corresponds to the old configuration.


7. Use ZFSBootMenu’s recovery shell to isolate ZBM from the installed initramfs

This is probably the best diagnostic step.

ZFSBootMenu has several tools designed specifically for this:

zreport

zbmcmdline

zfs-chroot <dataset>

zkexec <dataset> <kernel> <initramfs>

zreport displays ZFS module, pool, and dataset information. zfs-chroot enters the selected boot environment, while zkexec allows a specific kernel and initramfs from the boot environment to be launched directly. [docs.zfsbootmenu.org]

That tells you quite a lot.

If ZBM can:

  1. import the replacement pool,

  2. see the restored boot environment,

  3. mount it,

  4. chroot into it,

but executing its kernel/initramfs produces this panic, the evidence increasingly points to the restored OS’s initramfs/root configuration, rather than the ZFSBootMenu EFI image itself.


8. Try an older kernel/initramfs from ZFSBootMenu

If the restored /boot contains multiple kernel generations, try another one.

That’s useful diagnostically:

Every kernel fails identically

→ shared configuration such as hostid, root dataset, ZFS properties or initramfs construction becomes more suspicious.

Only the newest kernel fails

→ investigate that kernel/initramfs/ZFS module combination.

ZFSBootMenu is explicitly designed to find kernel/initramfs combinations within ZFS boot environments and launch them. [zfsbootmenu.org]


9. Verify that /sbin/init and the actual root filesystem are sane

Since the panic literally says:

PID: 1 Comm: init

verify what init is in the restored OS:

ls -l /sbin/init

readlink -f /sbin/init

On a systemd installation you’d normally expect this eventually to resolve to the systemd executable.

I’d also inspect:

ls -l /usr/lib/systemd/systemd

The fact that the system chroots successfully makes catastrophic root-filesystem damage less likely, but it doesn’t prove that the early-boot transition is valid.


The diagnostic sequence I’d use

Since you still have the NVMe drives untouched, I would leave them untouched until the SATA recovery pool boots.

From the Arch live ISO:

zpool import

zpool import <newpool>

zpool status <newpool>

zpool get bootfs <newpool>

zpool get cachefile <newpool>

zfs list -r <newpool>

zfs get -r mountpoint,canmount <newpool>

Then inspect:

hostid

cat /mnt/etc/hostid | od -An -tx4

Once the root is properly mounted and you’ve chrooted into it:

cat /etc/mkinitcpio.conf

ls -l /etc/zfs/zpool.cache

ls -l /sbin/init

readlink -f /sbin/init

Then rebuild:

mkinitcpio -P

After that, boot back into ZFSBootMenu and use its recovery shell to run:

zreport

zbmcmdline

ZBM explicitly provides both commands for exposing the relevant ZFS state and effective command line. [docs.zfsbootmenu.org]

My probability ranking

Based specifically on new pool + restored datasets + Arch + ZFSBootMenu + pool accessible from live ISO + chroot works + installed kernel reaches PID 1, I’d prioritize the investigation this way:

  1. Stale/incorrect installed initramfs

  2. hostid mismatch between ZBM/initramfs/restored installation

  3. bootfs or ZFSBootMenu/root-dataset property not recreated

  4. stale /etc/zfs/zpool.cache

  5. wrong root=/ZBM kernel command line

  6. incorrect canmount/mountpoint properties

  7. broken systemd/init in the restored filesystem

  8. kernel/ZFS-module problem

  9. actual hardware problem

That’s a diagnostic ranking from the symptoms, not a measured probability distribution.

One more useful clue: the screenshot doesn’t show ZFS failing to load or the kernel failing to find storage. It gets all the way to:

Kernel panic - not syncing:

Attempted to kill init!

exitcode=0x00000100

So I would resist the temptation to recreate the pool yet again. First rebuild mkinitcpio, validate /etc/hostid, bootfs, canmount, the ZBM command line, and zpool.cache. There is a good chance the restored data is fine and the remaining problem is the metadata/configuration needed to bridge ZFSBootMenu → kernel/initramfs → new root pool.

Confidence: 95%. The ZFSBootMenu/OpenZFS documentation strongly supports the hostid, bootfs, initramfs and pool-import areas as the right troubleshooting targets. The remaining uncertainty is that the screenshot contains the consequence of PID 1 exiting, not the earlier error message that caused init to return status 1.

Another option is do a clean install, set up the datasets as you had them previously, and then rsync the non-system files to their respective previous locations, then reboot.

IIRC from my r/datahoarder days, bare metal *nix recovery is best done that way as opposed to image based (recovering the entire disk at once) which Windows tends towards.

I got it working again! What must’ve fixed it was importing the pool, setting the cachefile pool property, copy that new cachefile into the mounted root pool.

On the next reboot the ZBM init complained that it couldn’t find the pool but didn’t panic. I waited patiently, then the boot resumed.

The following reboots went without this message, it just booted!

So far anything works fine, will test if really everything is there an works. If so, I can zpool replace back to the NVMe drives.

Thanks to you and Copilot, I had a good list to follow through. The pure GPT-5.4 (without RAG) I have access to at work didn’t produce that much of a detailed help. ChatGPT Free was even worse. I guess I have to bug the AI manager to give me access to better models and/or finally allow web search in our tool. Damn compliance :sweat_smile:

Thank you!

1 Like

Glad it worked!

If you’re an E365 org then Copilot Premium and Cowork access is a click and an approval signature away :stuck_out_tongue: