GEOM Boot Problems, fixing
gmirror boot problems
How to fix boot problems caused by errors in loader.conf when using GEOM/GMIRROR
Recently I had a problem where adding an entry into loader.conf caused my machine to fail at boot stage 3 (/boot/loader). This problem was compounded by the fact my boot disks were running on a GEOM mirror; the GEOM module not being loaded by a FixIt cd and my inability to load it using kldload once FixIt was loaded.
Background I have scsi 4 disks on dual bus. Disks 1 and 3 are a gmirror (/dev/mirror/FreeBSD) and hold my whole FreeBSD install. The other 2 are for data and are using setup using a zfs stripe (but not relevant). After making an addition to /boot/loader.conf and rebooting, the bootstrap hangs at /boot/defaults/loader.conf. So, I presumed the entry I just made was causing problems.
Normally, booting to a FixIt CD, mounting /boot and editing the file would have resolved this sort of problem. However, the geom_mirror module isn't loaded into the kernel by the disc and as such, there is no /dev/mirror/FreeBSDs1x to mount. I was also unable to add the module manually because either kldload is unavailable from the CD; or it returned an error (I forget which now).
To get around this problem I performed the following steps:
1) break out to the loader prompt during boot from CD - select option 6
2) unload all the currently loaded modules run unload. I found this had to be done because just telling it to load geom_mirror, still didn't work. It may have conflicted with another module. All other necessary modules are loaded at a later stage anyway.
3) tell loader to include geom_mirror run enable-module geom_mirror
4) carry on with boot, but when its ready to mount the root filesystem, stop and ask what to boot run boot -a -v
This will then continue with verbose output, then stop and return a mountroot> prompt. ? here shows a list of devices that can be mounted. Specify your root partition and its filesystem. I continued as follows:
5) mount gmirror type ufs:mirror/FreeBSDs1a
6) because this was a bit of trial and error I had to scan my filesytems. So if you receive a root shell fsck the devices - fsck /dev/mirror/FreeBSDs1a, fsck /dev/mirror/FreeBSDs1b etc.
7) your computer should continue to boot as it did before editing loader.conf. Let it finish, login, remove your erroneous entries
8) remove your FixIt CD and reboot. Your computer should now boot to its GEOM Mirror as before.