oe7drt-website/content/posts/2022/24-pfsense-restore-broken-config/index.md

100 lines
2.7 KiB
Markdown
Raw Normal View History

---
2024-09-29 01:48:06 +02:00
title: "pfSense: restore broken config"
aliases:
2024-09-29 01:48:06 +02:00
- /posts/2022-07-04-pfsense-restore-broken-config
- /posts/2022-07-04-pfsense-restore-broken-config-file
summary: >
Restoring a configuration file for pfSense when it actually stays in a
boot-loop
date: 2022-07-04T18:14:13+02:00
categories: [computerstuff]
2024-09-29 01:48:06 +02:00
tags: [pfsense, networking]
---
My pfSense firewall at home got a pretty heavy misconfiguration by myself and
that resulted in an annoying boot-loop. This took me quite a while to research,
but I finally got it working again. Thank god pfSense makes backups of its
configuration so this recovery process works quite well.
## Follow these steps
2024-09-29 01:48:06 +02:00
1. Boot into **single user mode**
2024-09-29 01:48:06 +02:00
Connect to your firewall (with a serial console) and choose option
`5) Reboot system` and confirm with the letter `S` (capital s).
2. **ZFS version only**
2024-09-29 01:48:06 +02:00
1. Remount root slice as read-write:
2024-09-29 01:48:06 +02:00
```console
$ /sbin/mount -u /
```
2024-09-29 01:48:06 +02:00
2. Mount all ZFS filesystems, datasets etc.
2024-09-29 01:48:06 +02:00
```console
$ /sbin/zfs mount -a
```
2024-09-29 01:48:06 +02:00
3. Working within the mounted filesystems
2024-09-29 01:48:06 +02:00
1. Enter **/cf/conf**
2024-09-29 01:48:06 +02:00
```console
$ cd /cf/conf
```
2024-09-29 01:48:06 +02:00
2. Copy the newest backup file back
2024-09-29 01:48:06 +02:00
```console
$ cp backup/config-1648889613.xml config.xml
```
2024-09-29 01:48:06 +02:00
3. Clear the config cache
2024-09-29 01:48:06 +02:00
```console
$ rm /tmp/config.cache
```
2024-09-29 01:48:06 +02:00
4. Reload system and it's services
2024-09-29 01:48:06 +02:00
```console
$ /etc/rc.reload_all start
```
2024-09-29 01:48:06 +02:00
This may take a while. At this point we are done, we can now remove
the single user mode boot configuration and reboot the firewall.
2024-09-29 01:48:06 +02:00
4. Clear the single user mode boot configuration
2024-09-29 01:48:06 +02:00
```console
$ /sbin/nextboot -D
```
2024-09-29 01:48:06 +02:00
ZFS does not clear the single user mode boot configuration by itself,
that's why we have to delete it after we are done with our work.
2024-09-29 01:48:06 +02:00
5. Reboot the system
2024-09-29 01:48:06 +02:00
```console
$ /sbin/reboot
```
2024-09-29 01:48:06 +02:00
You could also use exit, but that would only continue booting into
multi user mode without rebooting the system first. I personally think
that we would benefit from a full reboot.
Okay, that's it all for now. Please note that I do not use the UFS filesystem
any more, so I won't add this to my little instruction set.
2022-12-05 22:32:44 +01:00
{{< alert circle-info >}}
This post was actually older, I've saved the instructions in a textfile until I
found the time to format it and publish it on my website.
2022-12-05 22:32:44 +01:00
{{< /alert >}}
## Sources
- <https://docs.netgate.com/pfsense/en/latest/troubleshooting/single-user-mode.html#ufs-systems>
- <https://www.agix.com.au/restore-pfsense-from-backup-using-the-cli-command-line/>