aboutsummaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorJulien Dessaux2023-01-05 15:05:50 +0100
committerJulien Dessaux2023-01-05 15:07:43 +0100
commit3d5875c0d58a7a23a2ef38e1c0ba95db1741919a (patch)
treefb8042cea658c5407818a6aec5a7181fcec00ef1 /content
parentAdded the lost metal book article (diff)
downloadwww-3d5875c0d58a7a23a2ef38e1c0ba95db1741919a.tar.gz
www-3d5875c0d58a7a23a2ef38e1c0ba95db1741919a.tar.bz2
www-3d5875c0d58a7a23a2ef38e1c0ba95db1741919a.zip
Added freebsd recovery boot blog article
Diffstat (limited to '')
-rw-r--r--content/blog/freebsd/recovery-boot.md64
1 files changed, 64 insertions, 0 deletions
diff --git a/content/blog/freebsd/recovery-boot.md b/content/blog/freebsd/recovery-boot.md
new file mode 100644
index 0000000..25cd422
--- /dev/null
+++ b/content/blog/freebsd/recovery-boot.md
@@ -0,0 +1,64 @@
+---
+title: Recover a FreeBSD system using a liveUSB
+description: How to attach your geli encrypted devices, mount zfs and chroot
+date: 2023-01-05
+tags:
+- FreeBSD
+- toolbox
+---
+
+## Introduction
+
+I reinstalled my backup server to FreeBSD after a few months [on Alpine Linux]({{< ref "phoenix_reinstall.md" >}}). I was happy with Alpine running on bare metal, but since I no longer needed to run Linux containers on this machine I wanted to come back to BSD for the simplicity and consistency of this system. I used the automated installation with an encrypted zfs mirror of two drives.
+
+When I ran my ansible automation for the first time on this fresh installation, I did not notice it messed up my `/boot/loader.conf` and removed two vital lines for this system:
+```
+aesni_load="YES"
+geom_eli_load="YES"
+```
+
+Of course the server could not boot without those, here is how to solve this issue if it happens to you.
+
+## Booting from a LiveUSB
+
+If you do not already have one, download a LiveUSB image from https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/13.1/FreeBSD-13.1-RELEASE-amd64-memstick.img and copy it to your USB flash drive with a command like:
+```sh
+dd if=/home/julien/Downloads/FreeBSD-13.1-RELEASE-amd64-memstick.img of=/dev/sdb bs=1M
+```
+
+Insert it into your computer then select the proper temporary boot device using the proper key during the bios loading process (F11 for this motherboard of mine). When you reach the installer screen, select the option to `Start a Shell`.
+
+## Unlocking your geli encrypted devices
+
+These commands are not complicated, but here they are for posterity:
+```sh
+geli attach /dev/ada0p4
+geli attach /dev/ada1p4
+```
+
+If you are unsure about your disks numbering, `geom disk list` is your friend.
+
+## Mount your zfs filesystems
+
+```sh
+zpool import -fR /mnt zroot
+mount -t zfs zroot/ROOT/default /mnt
+zfs mount -a
+```
+
+## Chroot into your system
+
+Contrary to Linux for which the chroot process requires a little preparation, FreeBSD is a breeze:
+```sh
+chroot /mnt
+```
+
+and voila! If you need access to more things and require the comfort of your desktop computer or laptop:
+```sh
+mount -t devfs none /dev
+ifconfig re0 inet 192.168.1.2/24
+route add default 192.168.1.1
+service sshd start
+```
+
+You can now enjoy your system as if it booted normally and fix whatever you need to fix.