From 43d36f5eb013275a5581b7430b8eeebb64df0d6a Mon Sep 17 00:00:00 2001 From: 53hornet Date: Mon, 20 Dec 2021 22:16:39 -0500 Subject: feat: finish rescue --- includes/style.css | 4 ++ posts/2021-12-15-rescuing-freebsd-the-unix-way.php | 78 ++++++++++++++++------ 2 files changed, 63 insertions(+), 19 deletions(-) diff --git a/includes/style.css b/includes/style.css index 431747c..4d73999 100644 --- a/includes/style.css +++ b/includes/style.css @@ -64,6 +64,10 @@ a:visited { color: var(--charcoal); } +a:visited code { + color: var(--slate); +} + a:hover { transition: 0.25s; background-color: var(--slate); diff --git a/posts/2021-12-15-rescuing-freebsd-the-unix-way.php b/posts/2021-12-15-rescuing-freebsd-the-unix-way.php index 57937bd..39be005 100644 --- a/posts/2021-12-15-rescuing-freebsd-the-unix-way.php +++ b/posts/2021-12-15-rescuing-freebsd-the-unix-way.php @@ -1,4 +1,4 @@ -

Rescuing FreeBSD, the UNIX Way!

+

Rescuing FreeBSD, the UNIX Way (And a Free Upgrade Too!)

@@ -34,11 +34,13 @@ Now came the hard part. Un-effing everything I didn't know was missing or broken. Who knows what else got removed during that operation. I can reinstall my entire package tree pretty easily, so I'm not that worried about anything missing from /usr/local. Maybe I have one or two config files in /usr/local/etc that I can live without. I know /usr/home is safe and restored. So all that's left is stuff like lib, sbin, include, lib32, share and a few others that aren't very unique to my system (packages notwithstanding).

-Here's where the YOLO part begins. I was already in the middle of building my system from source to track FreeBSD 13.0-STABLE, instead of RELEASE. So instead of using a rescue CD to copy just the right files back or completely reinstalling my system, I'll just make buildworld and upgrade/replace my system in-place to track STABLE. The install/upgrade/switching process is well-documented, and there are already difftools/mergetools responsible for making sure that all of the new artifacts go exactly where they're supposed to (overtop of your old or broken existing ones). - -https://docs.freebsd.org/en/books/handbook/cutting-edge/#makeworld +

+ Here's where the YOLO part begins. I was already in the middle of building my system from source to track 13.0-STABLE, instead of RELEASE. So instead of using a rescue CD to copy just the right files back or completely reinstalling my system, I'll just upgrade my system in-place to track STABLE. The install/upgrade/switching process is well-documented, and there are already mergetools responsible for making sure that all of the new artifacts go exactly where they're supposed to (over top of your old or broken existing ones). +

-So let's follow the Handbook shall we? I'll start where I left off when everything imploded. Clean out /usr/src and clone the source tree. +

+ Time for the Handbook. I'll start where I left off when everything imploded. Clean out /usr/src and clone the source tree, but with an absolute path this time. +

 
@@ -47,7 +49,9 @@ So let's follow the Handbook shall we? I'll start where I left off when everythi
 
 
-And then start by compiling the world (userland) and the kernel. I'm going to use the GENERIC kernel for now so I can just get back up and running. +

+ And then start compiling the world (userland, services, utilities) and the kernel. I'm going to use the GENERIC kernel for now so I can just get back up and running. This part takes a really really long time. +

 
@@ -55,7 +59,9 @@ And then start by compiling the world (userland) and the kernel. I'm going to us
 
 
-It took literally hours. Poor little dual-core i5. It was already well on its way to completing when I realized I could have done this on my 8-core/16-thread server. "Oh, so you're reckless and stupid." Don't worry, I redeem myself later. Now I can actually install the new kernel and reboot into it. This is required before installing the world (userland). +

+ It took literally half the day. Poor little dual-core i5. It was already well on its way to completing when I realized I could have done this on my 8-core/16-thread server. "Oh, so you're reckless and stupid." Don't worry, I redeem myself later. Now I can actually install the new kernel and reboot into it. This is required before installing the world (userland). +

 
@@ -65,7 +71,9 @@ It took literally hours. Poor little dual-core i5. It was already well on its wa
 
 
-After rebooting I can check out my new version. +

+ After rebooting I can check out my new version. +

 
@@ -74,7 +82,9 @@ After rebooting I can check out my new version.
 
 
-Hmm, probably can't use freebsd-version because it's tied to the userland and freebsd-update. Let's try uname: +

+ Hmm, probably can't use freebsd-version(1) because it's tied to the userland and freebsd-update(1). Let's try uname(1): +

 
@@ -83,7 +93,9 @@ Hmm, probably can't use freebsd-version because it's tied to the us
 
 
-Success. Kernel is rebuilt, reinstalled, and tracking STABLE. Now it's time to install/upgrade everything else. Side note: this is one of the cool things about FreeBSD. It's a complete operating system, not just a kernel or a userland. All of the pieces were made to fit together instead of being glued together into a distro. +

+ Success. Kernel is rebuilt, reinstalled, and tracking STABLE. Now it's time to install/upgrade everything else. Side note: this is one of the cool things about FreeBSD. It's a complete operating system, not just a kernel or just a userland with a compiler and some utilities. All of the pieces were made to fit together instead of being glued together into a distro. +

 
@@ -91,9 +103,20 @@ Success. Kernel is rebuilt, reinstalled, and tracking STABLE. Now it's time to i
 
 
-This took a little bit longer, but from the output I could see that all of my important, potentially-missing binaries were being installed. Libraries, core utilities, applications, daemons, and man pages all got put back in their proper place. My system is totally back to life nad I'm confident that I'm running an un-maimed FreeBSD 13.0-STABLE. +

+ This took a little bit longer, but from the output I could see that all of my important, potentially-missing files were being restored. Libraries, core utilities, applications, daemons, config, and man pages all got put back in their proper place. My system is totally back to life and I'm confident that I'm running an un-maimed FreeBSD 13.0-STABLE: +

+ +
+
+% freebsd-version
+13.0-STABLE
+
+
-Now comes the sanity checking part of this job. I'm actually running a newer system now than I was before the upgrade. One of the components that was upgraded was ZFS, and with every major ZFS upgrade, I'm going to reinstall my ZROOT bootloader: +

+ Now comes the sanity checking part of this job. I'm actually running a newer system now than I was before the upgrade. One of the components that was upgraded was ZFS, and with every major ZFS upgrade, I'm going to reinstall my root-on-ZFS bootloader before I reboot: +

 
@@ -103,11 +126,17 @@ Now comes the sanity checking part of this job. I'm actually running a newer sys
 
 
-This may be unecessary, but it ensures that my root-on-ZFS will load correctly after a reboot with the new ZFS. And to be fair, it is mentioned in the UPDATING guide in the source. +

+ This may be unecessary, but it ensures that my root-on-ZFS will load correctly after a reboot with the new ZFS. And to be fair, it is mentioned in the UPDATING guide in the source. +

-After a reboot, I've got one more sanity check. FreeBSD comes with etcupdate(8), which you can use to manage merging upgrades with local changes to your /etc /usr/local/etc system config. If you run etcupdate diff you can see a diff of all of your customized system config. This is so good, I can't believe something like this doesn't exist on your typical Linux distro. Maybe it does and I just never realized it, but I'm betting they're all just different enough to not be able to share something like this. Anyway, after reviewing the diff, I applied any changes/merges by running etcupdate. +

+ After a reboot, I've got one more sanity check. FreeBSD comes with etcupdate(8), which you can use to manage merging upgrades with local changes to your /etc, /usr/local/etc system config. If you run etcupdate diff you can see a diff of all of your customizations. This is so good, I can't believe something like this doesn't exist on your typical Linux distro. Maybe it does and I just never realized it, but I'm betting they're all just different enough to not be able to share something like this. Anyway, after reviewing the diff, I applied any changes/merges by running etcupdate. +

-Now for one last bit of housekeeping, and this comes straight from the handbook. After an upgrade, the world installation leaves behind old libraries and files that the new system doesn't need but old applications or ports built against an older target might still require. To get rid of them, you can use the Makefile directives in /usr/src +

+ Now for one last bit of housekeeping, and this comes straight from the handbook. After an upgrade, the world installation leaves behind old libraries and files that the new system doesn't need but old applications or ports built against an older target might still require. To get rid of them, you can use the Makefile directives in /usr/src +

 
@@ -115,7 +144,9 @@ Now for one last bit of housekeeping, and this comes straight from the handbook.
 
 
-After reviewing the list and ensuring you don't need those files, you can clean them up with +

+ After reviewing the list and ensuring you don't need those files, you can clean them up with +

 
@@ -123,7 +154,16 @@ After reviewing the list and ensuring you don't need those files, you can clean
 
 
-// TODO: pkg reinstall -//I'm a pkg leaf | xargs pkg install -f away from completely restoring those. +

+ And finally, I'll force install my entire package tree to make sure any third-party missing files are reinstalled: +

+ +
+
+# pkg leaf | xargs pkg install -f
+
+
-Redemption. I went from attempting to customize my kernel to annihilating /usr to restoring my entire system by building from FreeBSD's source tree via git and make. And I got an upgrade in the process too! Moving forward, I'm running slightly frequent automatic full-system snapshots. It should make it a lot easier to rescue accidental deletions of system files. I'm also going to take the time to learn more about the rescue disk process using the FreeBSD installer image. All told, not too bad for something that could have gone a lot worse. +

+ Redemption. I went from attempting to customize my kernel to annihilating /usr to restoring my entire system by building from FreeBSD's source tree via git(1) and make(1). And I got a free upgrade out of it! Moving forward, I'm running slightly frequent automatic full-system snapshots. It should make it a lot easier to rescue accidental deletions of system files. I'm also going to take the time to learn more about the rescue disk process using the FreeBSD installer image. All told, not too bad for a disaster-turned-learning-experience. +

-- cgit v1.2.3