Creating A New FreeBSD Boot Loader Option
The Use Case
There are multiple kernels installed on the FreeBSD host and an option to boot to this kernel is necessary.
Prerequisites
- This post assumes FreeBSD 8.x, but should apply with any version running loader(8)
- This post assumes that a secondary/debug kernel is installed
The Patch
This is the patch. Copy/paste it to /boot/beastie.patch for use in the procedure below.
Index: beastie.4th =================================================================== --- beastie.4th +++ beastie.4th @@ -41,6 +41,7 @@ variable bootkey variable bootacpikey variable bootsafekey +variable bootdebugkey variable bootverbosekey variable bootsinglekey variable escapekey @@ -194,6 +195,7 @@ printmenuitem ." Boot FreeBSD in Safe Mode" bootsafekey ! printmenuitem ." Boot FreeBSD in single user mode" bootsinglekey ! printmenuitem ." Boot FreeBSD with verbose logging" bootverbosekey ! + printmenuitem ." Boot FreeBSD with debug kernel" bootdebugkey ! printmenuitem ." Escape to loader prompt" escapekey ! printmenuitem ." Reboot" rebootkey ! menuX @ 20 at-xy @@ -286,6 +288,9 @@ s" YES" s" boot_single" setenv 0 boot then + dup bootdebugkey @ = if + s" /boot/DEBUG/kernel" 1 boot + then dup escapekey @ = if 2drop s" NO" s" autoboot_delay" setenv
Applying The Patch
Follow these steps to apply the patch to your target hosts:
# cd /boot # cp beastie.4th beastie.4th.orig # patch -p0 < beastie.patch
The new option will be loaded when loader called beastie.4th.
