In my case, the motherboard battery had also died and so I needed to install a new battery and reset the bios to boot in EFI mode
Ubuntu ZFS Recovery Guide
Consolidated from a successful recovery session following a CMOS battery failure.
This guide outlines the exact process used to recover an Ubuntu system with a ZFS layout (bpool for /boot and rpool for /) after a motherboard battery failure wiped the BIOS settings and corrupted the boot configuration flags.
Prerequisites & Hardware Fixes
Before repairing the software, the underlying hardware clock and motherboard configurations must be stabilized to ensure the settings stick permanently.
- Replace the CMOS Battery: Install a new CR2032 battery on the motherboard.
- Set the Hardware Clock: Enter the BIOS, update the system date, and correct the time.
- Configure Storage Mode: Ensure the SATA/Storage mode is explicitly set to AHCI (do not leave it on RAID or Intel RST).
- Configure Boot Mode: Set the motherboard to boot exclusively in UEFI Mode (Disable CSM / Legacy boot configuration options).
Phase 1: Boot the Live USB in UEFI Mode
- Insert an Ubuntu Live USB matching your installed system version as closely as possible.
- Open your motherboard's boot selection menu (usually
F12,F11,F8, orF2). - Select the option that explicitly begins with
UEFI:next to your flash drive's name. - Choose "Try Ubuntu" and launch a terminal.
Phase 2: Install ZFS Tools & Force Import Pools
Because the machine suffered an ungraceful power loss from the dead battery, the ZFS datasets must be forcefully imported to clear lingering "dirty" flags.
- Gain root privileges:
bash sudo -i - Install the ZFS utilities into your Live environment:
bash apt update && apt install -y zfsutils-linux - Force import the root pool (
rpool) onto the alternate mount path:bash zpool import -f -R /mnt rpool(Note: If using native ZFS encryption, add the-lflag:zpool import -f -l -R /mnt rpooland type your passphrase). - Force import the boot pool (
bpool):bash zpool import -f -R /mnt bpool
Phase 3: Mount Your EFI Partition & System Trees
Note: During recovery, the Live USB may register as /dev/sda, shifting your primary operating system drive to /dev/sdb.
- Mount your actual system EFI partition (which is partition 1 on your true OS drive, e.g.,
/dev/sdb1):bash mount /dev/sdb1 /mnt/boot/efi - Bridge the critical virtual filesystems and API links from the Live environment into your target path:
bash mount --bind /dev /mnt/dev mount --bind /proc /mnt/proc mount --bind /sys /mnt/sys mount --bind /sys/firmware/efi/efivars /mnt/sys/firmware/efi/efivars - Chroot straight into your native Ubuntu operating system environment:
bash chroot /mnt
Phase 4: Rebuild the Bootloader
Now that you are safely executing commands inside your own system, synchronize your modules and rewrite the EFI boot registers.
- Re-generate and update your kernel modules and ZFS drivers:
bash update-initramfs -u -k all - Reinstall GRUB directly to the EFI directory to re-register Ubuntu with your newly-reset motherboard NVRAM:
bash grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck - Refresh the GRUB bootloader configuration menu:
bash update-grub
Phase 5: Clean Exit & Safe Unmounting
To prevent dataset errors or stuck locks on the next hardware boot, you must break background system hooks cleanly.
- Exit the chroot session:
bash exit - Force-unmount stuck hooks or busy errors on the boot structures using a lazy unmount:
bash umount -l /mnt/boot - Unmount remaining system elements and the EFI path:
bash umount /mnt/sys/firmware/efi/efivars umount /mnt/sys /mnt/proc /mnt/dev umount /mnt/boot/efi - Export both ZFS pools to cleanly close their file access flags:
bash zpool export -f bpool zpool export -f rpool - Restart your machine and remove the flash drive:
bash reboot