MikeL's FreeBSD Broken boot

I just typoed in my rc.conf and had to go through this mess to get back to a running system. I was able to copy the emacs "~" file back into place, and reboot and all was well. But I'm tired of bumping into this, I want a tester app. I'm pretty sure I'll be able to train myself to run it when I make changes. Maybe I can find a way to build it into shutdown -- I'll have to look into that later.

Anyways - dirt simple /etc/rc.conf checker:
cd into your local bin directory, and create the following:
    echo sysrc -a>rccheck
    chmod 755 rccheck
If you prefer a simple y/n, you could do:
    echo 'sysrc -a >& /dev/null' > rccheck
    echo 'echo $?'>>rccheck (must use apostrophe, not quote) -- 1 means error, zero is success

I just replaced my second drive with a larger one. It's actually RAID config, but this should not matter. Bottom line is that I forgot to modify /etc/fstab and remove the 2nd drive entry before doing the replacement. The system now boots to "mountroot" - badness.
First is to get to the disk: ufs:mfid0s1
Now you should be able to modify /etc/fstab and comment out that 2nd disk line. You may have to play some games as below to get a writable filesystem. I could not seem to get 'vi', so I tried using 'ex'. All this achieved was to nuke (delete) my fstab file. Very, very badness.
Next boot you get to a command prompt and are unable to do anything. You cannot change the drive to writable as the mount command will puke due to missing fstab. The only fix is configure a memstick image and boot that, then mount the drive manually, and fix the file.
Unfortunately for me, there was something else fucked up ('libdev6.so' missing or some such), and simply putting a new fstab into place did not fix it. In the end I had to boot to command shell, 'newfs' each partition on the drive, then reinstall the OS from the memory key.
Everything on the base drive (/, /usr, /var) was lost to a blank install. It took several days of messing around and googling just to get to this point. All this because I simply forgot to comment out the fstab entry for the 2nd disk.
Ok, you've fucked up a boot config file, and the system won't start enough to get in. This can happen by: Here's how to recover.
  1. Reboot/power cycle if necessary.
  2. When you get to the FreeBSD beastie screen, hit ESC.
  3. At the "OK" prompt, boot to "single user" mode.
    boot -s
  4. When prompted, hit Enter to start /bin/sh.
  5. If filesystem was not shut down nicely, we need to fix it. We only need to worry about the root filesystem at this time.
    fsck -y /
  6. Update root filesystem to read/write mode from read-only.
    mount -u /
  7. You can now 'cd' to the affected directory, and fix the problem. If you use 'emacs' as I do, simply 'mv' the broken file out, and 'mv' the emacs backup file (same filename with trailing tilda '~') into place.
  8. You'll need to start over with a full reboot.

Copyright © 1995-2023 Mike Lempriere (running on host pedicel)