Recovering OPNSense
Nov 6, 2024 - ⧖ 2 minI woke up to faulty internet and after some troubleshooting it turns out the root zfs dataset that OPNSense boots from got corrupted...
PRO-TIP - Auto backup your OPNSense config to Google Drive, git, or nextcloud... But if you won't then at least back up your OPNSense config somewhere everytime you update it.
It's too much to recount every issue, so here's a bullet list what worked.
- On a fresh drive install OPNSense
- Plug in the old drive through a USB enclosure - now I'm not sure what would
happen if you plugged it in along with the new drive and then booted up.
Because both drives will have a zfs pool
zroot
and the boot dataset is automounted at/zroot/ROOT/default
. My oldzroot
pool wasSUSPENDED
so it didn't automount - Because the old
zoot/ROOT/default
was corrupted I did this to mount it RO:zpool import -d <path to zfs partition - /dev/stuff> -N zroot zrootrecovery
-d is the zfs flag to import the pool by disk id, -N it to not mount any of the datasets (we need to change mountpoints) and the
zroot zrootrecovery
imports thezroot
pool with a new name
- Change the mountpoints for all the
zrootrecovery
datasets to somewhere like/mnt/zrootrecovery
- Depending on the mount point you set you'll find a
config
directory around/mnt/zrootrecovery/ROOT/default/config
- copy the file you want to another machine via scp or whatever - Go to OPNSense webui and recover from that config!
All in all this process took me around 8 hours but I did run into about ever issue under the sun (several bad disks in the mix, a laptop that wouldn't live boot into a BSD system, etc.)