Boot-Time Kernel Configuration


You may find that you don't know exactly what configuration your system should have. Suppose you have one of our famous NE2000 network cards, but you don't know the IRQ or port address. You could keep reconfiguring the kernel and rebooting, but that's a lot of work. You can configure the kernel at boot, boot to single-user mode to see to see if the card is recognized, and either reboot to try again or write your changes to your kernel. This is much faster than booting to full multi-user to check each hardware change. Sadly you cannot alter the kernel constants here, such as NMBCLUSTERS.

Interrupt the boot as described in Chapter 6 and then tell the system to boot to configure mode with the "-c" flag and to single-user mode with the "-s" flag.

 boot> boot -cs 

You'll get a couple lines of boot output, and then be presented with a prompt.

 UKC> 

This looks an awful lot like our "config -e" prompt, doesn't it? Well, it should; it's almost exactly the same. You can edit the kernel to your heart's content at this prompt and then boot off of this modified kernel. This will allow you to change IRQ or memory port addresses so you can get your computer on the network, tweak the settings on other cards, and so on. When you exit the configuration tool, the system will continue the boot into single-user mode.

This is extremely useful for testing. If you're not sure if a change will help your problem, you can edit the kernel at boot and see what effect the changes have upon your system's behavior. These changes are not permanently written to the kernel, however; the next time you reboot, they vanish.

Making Boot-Time Kernel Changes Permanent

If you tweak your kernel at boot and like the results, you probably want to make the changes permanent. You can use config(8) to write the changes you made to a kernel file, which is a lot like editing a kernel binary by adding the "-u" flag to the mix. This applies any changes you made during the boot process to the kernel file.

For example, suppose you disabled all the "ahc" devices during a boot. Perhaps you removed your last ahc SCSI card, relying instead on some other card in the system. Here, we write an updated kernel to /bsd.new by running the following. We looked at "-e" and "-o" earlier in this chapter; only the "-u" flag is new.

 # config -e -u -o /bsd.new /bsd OpenBSD 3.1 (GENERIC) #59: Sat Apr 13 15:28:52 MDT 2002     deraadt@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC Processing history...  34 ahc* disabled 189 ahc0 disabled 192 ahc* disabled Enter 'help' for information ukc> quit Saving modified kernel. # 

Here, you see that the system remembered the changes you made. All you have to do is run the command, and the program handles the changes you requested. Config(8)'s memory isn't perfect, and it might not always remember your changes. In this case, you'd need to run a standard "config -e" and add your changes by hand.

We've now taken simple kernel changes with config and sysctl about as far as they can go. To make more complex or drastic changes, you'll need to compile a custom kernel. We'll look at that in the next chapter.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net