Recovering Conf Directory ZFS Volume on OPNsense Installation
OPNsense is a popular open-source firewall and routing software based on FreeBSD. In some cases, an OPNsense installation may encounter issues, such as a broken installation without a recent backup. In such situations, it may be necessary to recover the Conf directory and ZFS volume. This article provides a step-by-step guide on how to do this.
Prerequisites
Before proceeding, ensure you have the following:
- A bootable system (e.g., LMDE USB stick, DD image, or external disk)
- Access to the affected OPNsense system (e.g., via console or SSH)
Recovering Conf Directory
-
Boot the system with the bootable media.
-
Mount the OPNsense system's root filesystem. For example, if the system's disk is
da0, execute the following command:mount /dev/da0s1 /mnt -
Navigate to the OPNsense system's Conf directory:
cd /mnt/etc/pfsense -
Copy the required configuration files from the backup or a known working OPNsense installation. For example, if you have a backup in
/backup/pfsense/conf/, execute the following commands:mkdir -p /mnt/etc/pfsense/conf cp -R /backup/pfsense/conf/* /mnt/etc/pfsense/conf/ -
Save the current system time:
cp /mnt/etc/rc.conf /mnt/etc/pfsense/conf/ -
Modify the
/mnt/etc/rc.conffile to set the correct timezone and NTP server:timezone="America/Los_Angeles" ntp_enable="YES" ntp_servers="0.pool.ntp.org 1.pool.ntp.org 2.pool.ntp.org" -
Recreate the OPNsense system's fstab file:
cp /mnt/boot/fstab /mnt/etc/pfsense/conf/ -
Save the changes and exit the system.
Recovering ZFS Volume
-
Boot the system with the bootable media.
-
Mount the OPNsense system's root filesystem and ZFS pool:
mount /dev/da0s1 /mnt zpool import -d /mnt -f /mnt/etc/zfs/zpool.cache -
If the ZFS pool was imported successfully, you should see the pool's name in the output. If not, investigate the error messages and try to resolve the issues.
-
Once the ZFS pool is imported, unmount the root filesystem and ZFS pool:
umount /mnt zpool export /mnt/zpool -
Exit the system.
-
Boot the OPNsense system normally.
Summary
This article demonstrated how to recover a broken OPNsense installation without a recent backup by recovering the Conf directory and ZFS volume. By following the steps outlined above, you should be able to restore your OPNsense system to a functional state.