Changeboot

The purpose of changeboot is to change the boot devices (ie, the devices the bios tries to boot from on power-on or reset. These devices are set in the nvram (non-volatile ram). The nvram on PCs are bios-specific; not just the brand but also the version of the bios.

Usage

This tool is written for our groupC hardware. It does not work on groupA or groupB hardware. The tool accesses the nvram directly, so it must be run as root.

bash-2.00# ./changeboot --help
changeboot 1.0, changes boot devices on AMI BIOS
Usage: changeboot [OPTION]

 -h, --help             Print this help.
 -d, --dump             Dump current setup.
     --boot0=DEV        Set first boot device to DEV
     --boot1=DEV        Set second boot device to DEV
     --boot2=DEV        Set third boot device to DEV

DEV is one the following devices:
        0               disabled
        1               ide0
        2               ide1
        3               ide2
        4               ide3
        5               floppy a:
        6               floppy b:
        7               zip a: ls120
        8               atapi zip c:
        9               cdrom
        10              scsi
        11              network

So you can run: changeboot --dump, which will output something like:

bash-2.00# ./changeboot --dump
boot0: floppy a:
boot1: ide0
boot2: disabled

Suppose you want to boot from ide2 (master on the second controller), and then boot from floppy, do the following:

 	changeboot --boot0=3 --boot1=5 --boot2=0

It will not give any output, like any good tool. :-) You can verify the setting with changeboot --dump again.

Suppose the first boot device (--boot0) is set to floppy a: (5), the bios tries to boot from that device unless is not ready; so it will only fall through to boot1 if there is no disk in the drive. Similary, if the first boot device is ide0 and there is no OS (=boot sector etc) but the drive is ready, it will hang there. Only if ide0 is not present will it fall-through to boot1.

Getting and compiling

changeboot is in CVS: /ncc/test-traffic/CVS/testbox/tb_source/changeboot/

To compile for FreeBSD, do gcc -o changeboot *.c -DFREEBSD -I. and Linux gcc -o changeboot *.c -DLINUX -I..

Background

nvram (or CMOS) is bios specific. AFAIK, there is no driver for it in FreeBSD. The linux driver does not give access to the full 128 bytes, only to the lower 64 bytes minus the clock information. Therefore direct I/O to the rtc (which controls the nvram) is needed.

The bios does loads of initializing for legacy OSes like DOS; better operation systems like Linux and FreeBSD hardly require any information from the BIOS, and efforts are being done to simply put the linux kernel into the BIOS flashable ROM. Parameters to the kernel could be set before rebooting, and also rebooting would be a lot faster. However these efforts are very primilinary so at this stage I would not recommend using them.