Boot RAMDisk Kernel
Here is an example of booting bsd.rd on an i386 system:
Using Drive: 0 Partition: 3
reading boot.....
probing: pc0 com0 com1 apm mem[639k 255M a20=on]
disk: fd0 hd0+
>> OpenBSD/i386 BOOT 2.10
boot> boot hd0a:/bsd.rd
--------------------------------------------------------------------------------
Boot Floppy
http://www.openbsd.org/faq/faq4.html#MkFlop
If you have a system that is used to boot OpenBSD infrequently (or don't
wish other users of the computer to note anything has changed), consider
using a boot floppy. Simply use one of the standard OpenBSD install
floppies, and create an /etc/boot.conf file (yes, you will also have to
create an /etc directory on the floppy) with the contents:
#/etc/boot.conf:
boot hd0a:/bsd
to cause the system to boot from hard drive 0, OpenBSD partition 'a',
kernel file /bsd. Note you can also boot from other drives with a line
like: "boot hd2a:/bsd" to boot off the third hard drive on your system.
To boot from OpenBSD, slip your floppy in, reboot. To boot from the other
OS, eject the floppy, reboot.
In this case, the boot(8) program is loaded from the floppy, looks for and
reads /etc/boot.conf. The "boot hd0a:/bsd" line instructs boot(8) where to
load the kernel from -- in this case, the first HD the BIOS sees. Keep in
mind, only a small file (/boot) is loaded from the floppy -- the system
loads the entire kernel off the hard disk, so this only adds about five
seconds to the boot process.
Floppy Bootdisk Methods (and recovery):
o /usr/mdec/installboot
/usr/mdec/installboot /path/to/boot /usr/mdec/biosboot wd0
o "path/to /boot" must be on the drive/partition specified by "disk";
you cannot perform cross-device installboots.
o Creat Bootable Floppy
newfs /dev/rfd0Bc
mount /dev/fd0Ba /mnt/floppy
cp /usr/mdec/boot /mnt/floppy/boot
/usr/mdec/installboot -v /mnt/floppy/boot /usr/mdec/biosboot fd0Bc
? cp /bsd /mnt/floppy/bsd
o Recovery with bootable Floppy
boot the floppy.fs filesystem floppy
fsck /dev/rwd0a
mount /dev/wd0a /mnt
cp /usr/mdec/boot /mnt/boot
/usr/mdec/installboot -v /mnt/boot /usr/mdec/biosboot wd0
o Auto specify /path/to/boot
mkdir /mnt/floppy/etc
echo "set device hd1a" >/mnt/floppy/etc/boot.conf
_or_
echo "boot hd0a:/bsd" >/mnt/floppy/etc/boot.conf
--------------------------------------------------------------------------------
Disk Setup / Muliboot
http://www.openbsd.org/faq/faq14.html
To multi-boot with NT, you need a copy of your OpenBSD Partition Boot
Record (PBR). After running installboot, you can copy it to a file using
dd(1), following a process similar to:
# dd if=/dev/rsd0a of=openbsd.pbr bs=512 count=1
# dd if=/dev/rwd0a of=openbsd.pbr bs=512 count=1
Add c:\openbsd.pbr to boot.ini.
--------------------------------------------------------------------------------
The Master Boot Record (MBR)
Master Boot Record (MBR): The Master Boot Record is the first physical sector
(512 bytes) on the disk. It contains the primary partition table and a small
program to load the Partition Boot Record (PBR).
While OpenBSD includes an MBR, you are not obliged to use it, as virtually any
MBR can boot OpenBSD. The MBR is manipulated by the fdisk(8) program, which is
used both to edit the partition table, and also to install the MBR code on the
disk.
You may install the OpenBSD MBR on your hard disk using the fdisk program.
Boot from your install media, choose "Shell" to get a command prompt:
# fdisk -u wd0
You may also install a specific MBR to disk using fdisk:
# fdisk -u -f /usr/mdec/mbr wd0
OpenBSD's MBR announces itself with the message:
Using drive 0, partition 3.
--------------------------------------------------------------------------------
Partition Boot Record (PBR)
Partition Boot Record (PBR): The Partition Boot Record, also called the
PBR or biosboot(8) (after the name of the file that holds the code) is the
first physical sector of the OpenBSD partition of the disk. The PBR is the
"first-stage boot loader" for OpenBSD. It is loaded by the MBR code, and
has the task of loading the OpenBSD second-stage boot loader, boot(8).
Like the MBR, the PBR is a very tiny section of code and data, only 512
bytes, total. That's not enough to have a fully filesystem-aware application,
so rather than having the PBR locate /boot on the disk, the BIOS-accessible
location of /boot is physically coded into the PBR at installation time.
The PBR is installed by installboot.
The PBR announces itself with the message:
Loading...
printing a dot for every file system block it attempts to load. Again,
the PBR shows if it is using LBA or CHS to load, if it has to use CHS
translation, it displays a message with a semicolon:
Loading;...
Second Stage Boot Loader, /boot: /boot is loaded by the PBR, and has the
task of accessing the OpenBSD file system through the machine's BIOS, and
locating and loading the actual kernel. boot(8) also passes various options
and information to the kernel.
boot(8) is an interactive program. After it loads, it attempts to locate and
read /etc/boot.conf, if it exists (which it does not on a default install),
and processes any commands in it. Unless instructed otherwise by
/etc/boot.conf, it then gives the user a prompt:
probing: pc0 com0 com1 apm mem[636k 190M a20=on]
disk: fd0 hd0+
>> OpenBSD/i386 BOOT 2.10
boot>
It gives the user (by default) five seconds to start giving it other tasks,
but if none are given before the timeout, it starts its default behavior:
loading the kernel, bsd, from the root partition of the first hard drive.
The second-stage boot loader probes (examines) your system hardware,
through the BIOS (as the OpenBSD kernel is not loaded).
Kernel: /bsd: This is the goal of the boot process, to have the OpenBSD
kernel loaded into RAM and properly running. Once the kernel has loaded,
OpenBSD accesses the hardware directly, no longer through the BIOS.
--------------------------------------------------------------------------------
Notes
When installboot(8) installs the partition boot record, it writes the block
number and offset of /boot's inode into the PBR. Therefore, deleting and
replacing /boot without re-running installboot(8) will render your system
unbootable, as the PBR will load whatever happens to be pointed to by the
inode specified in it, which will almost certainly no longer be the desired
second-stage boot loader!
To fix your boot block so that you can boot normally, just put a boot floppy
in your drive (or use a bootable CD-ROM) and at the boot prompt, type
"b hd0a:/bsd" to force it to boot from the first hard disk (and not the
floppy). Your machine should come up normally. You now need to update the
first-stage boot Loader to see the new geometry (and re-write the boot block
accordingly).
Our example will assume your boot disk is sd0 (but for IDE it would be wd0,
etc..):
# cd /usr/mdec; ./installboot /boot biosboot sd0
If a newer version of bootblocks are required, you will need to compile
these yourself. To do so simply:
# cd /sys/arch/i386/stand/
# make && make install
# cd /usr/mdec; cp ./boot /boot
# ./installboot /boot biosboot sd0 (or whatever device your hard disk is)
http://www.openbsd.org/faq/faq14.html#InstBoot
--------------------------------------------------------------------------------
Notes pertaining to boot installation
cd /usr/mdec; ./installboot /boot biosboot sd0
cp /usr/mdec/boot /boot
/usr/mdec/installboot -v -n /boot /usr/mdec/biosboot sd0
if the output information looks correct, use w/o the -n option
boot
The name of the second-stage boot program in the mounted file
system where the first-stage boot program is to be installed.
This should be a full pathname.
biosboot
The name of the prototype file for the first stage boot program,
usually /usr/mdec/biosboot.
disk
The name of the disk containing the partition in which the
second-stage boot program resides and the first-stage boot program
is to be installed. This can either be specified in short form
(i.e., `sd0' or `wd0'), or as the explicit device node, such as
/dev/rsd0c or /dec/rwd0c.
Note that you must be in single-user mode or have your kernel
in insecure mode (see the sysctl(8) kern.securelevel variable
or /etc/rc.securelevel) to enable access to the raw partition
of a mounted disk.
biosboot
This small program (roughly 256 bytes of code) is responsible for loading
the second stage boot(8) program, which in turn, will load the kernel.
It takes no input or options directly.
In order for biosboot to load the second-stage bootstrap, it has a table
inside it which describes boot(8)'s location. biosboot must be in-
stalled by, and have its block table filled in by, the installboot(8)
program. As this data is BIOS dependant, you must re-run installboot(8)
each time you reinstall boot(8) or move your disk or software between ma-
chines and/or controllers.
When biosboot receives control from either the BIOS or the MBR it will
print the message:
loading /boot
followed by a dot for every successfully loaded block, and then put cur-
sor on the next line right before switching into protected mode and
transferring control to the just loaded /boot program.
--------------------------------------------------------------------------------
boot
COMMANDS
The following commands are accepted at the boot prompt:
boot [image [-acds]]
Boots the kernel image specified by image with any options giv-
en. Image specification consists of a pair device:filename; ei-
ther or both can be omitted (`:' is not needed if both are omit-
ted), in which case values from boot variables will be used.
When selecting the device to boot from, boot makes no distinc-
tion between SCSI and IDE type drives; they are detected as `hd'
devices. Therefore, to boot kernel /bsd from slice `a' on the
first hard drive (irrespective of device type), specify ``boot
hd0a:/bsd''.
-a Causes the kernel to ask for the root device to use.
-c Causes the kernel to go into boot_config(8) before perform-
ing autoconf(4) procedures.
-d Causes the kernel to drop into ddb(4) at the earliest con-
venient point.
-s Causes the kernel to boot single-user.
echo [args]
Displays args on the console device.
help Prints a list of available commands and machine dependent com-
mands, if any.
machine [command]
Issues machine-dependent commands. These are defined for i386
architecture:
diskinfo Prints a list of hard disks installed on your system
including: BIOS device number, and the BIOS geometry.
memory If used without any arguments this command will print
out the memory configuration as determined through
BIOS routines. Otherwise the arguments would specify
the expressions to modify the memory configuration.
The expression would have a form of:
[+-]@
Meaning to add(+) or exempt(-) the specified by the
amount of memory at the location specified by
the argument. Both size and base address
could be specified as octal, decimal, or hexadecimal
numbers, as accepted by the strtoul(3) routine. Memo-
ry segments are not required to be adjacent to each
other, the only requirement is that there is real
physical memory under the range added. For example:
machine mem +0x2000000@0x1000000
would add 32M of memory right after the first 16M.
The other useful command would be to withdraw a range
of memory from OS usage (might be wrongfully reported
as useful by the BIOS).
machine mem -0x100000@0xf00000
which effectively excludes 15-16M range from the map
of useful memory.
regs Prints contents of processor registers if compiled
with DEBUG.
ls [directory]
Prints contents of the specified directory in long format in-
cluding: attributes and file type, owner, group, size, filename.
reboot Reboots the machine by initiating a warm boot procedure.
set [varname [value]]
If invoked without arguments, prints a list of variables and
their values. If only varname is specified, displays contents
of that variable. If varname and value are both specified, sets
that variable to the given value. Variables include:
addr Address at which to load the kernel.
debug Debug flag if boot was compiled with DEBUG defined.
device Boot device name (e.g., fd0a, hd0a).
howto Options to pass to the loaded kernel.
image File name containing the kernel image.
timeout Number of seconds boot will wait for human intervention
before booting the default kernel image.
tty Active console device name (e.g., com0, com1, pc0).
stty [device [speed]]
Displays or sets the speed for a console device. If changing
the baudrate for the currently active console, boot offers you
five seconds of grace time before committing the change to allow
you to change your terminal's speed to match. If changing speed
not for the active console, the baudrate is set for the next
time you switch to a serial console. The baudrate value is not
used for the pc0 console.
The default baudrate is 9600bps.
time Displays system time and date.
FILES
/usr/mdec/biosboot first stage bootstrap
/usr/mdec/pxeboot PXE bootstrap
/boot system bootstrap
/etc/boot.conf system bootstrap's startup file
/bsd kernel image
/bsd.mp kernel image for multiprocessor machines
/bsd.rd kernel image for installation/recovery
EXAMPLES
Boot the default kernel:
boot> boot
Remove the 5 second pause at boot-time permanently, causing boot to load
the kernel immediately without prompting:
# echo "boot" > /etc/boot.conf
Use serial console. A null modem cable should connect the specified se-
rial port to a terminal. Useful for debugging.
boot> set tty com0
Invoke the serial console at every boot:
# echo "set tty com0" > /etc/boot.conf
Boot the kernel named /bsd from the second hard disk in ``User Kernel
Configuration'' mode (see boot_config(8)). This mechanism allows for the
explicit enabling and disabling of devices during the current boot se-
quence, as well as the modification of device parameters. Once booted,
such changes can be made permanent by using config(8)'s -e option.
boot> boot hd1a:/bsd -c