1 BOOT(8) BSD System Manager's Manual (i386) BOOT(8)
4 boot, boot.cfg, ldbsd.com, pxeboot - i386 second-stage boot loader
7 The boot system programme, often called ldbsd.com, aims to load the sys-
8 tem kernel into core memory from disc or network and run it, as well as
9 do some auxiliary functions, while dealing with the problems arising from
10 the history of the i386 architecture since 1978, incompatibilities, ex-
11 tensions, bugs, El Torito booting, Intel's Preboot Execution Environment
12 (PXE) for network boot, etc. MirOS floppies use a specially limited ver-
13 sion optimised for size, lacking support for any filesystem other than
14 4.2FFS and most commands.
16 It can be loaded either directly from the BIOS (most commonly via PXE;
17 earlier versions could also be loaded using El Torito), the bootxx first
18 stage boot loader (from floppy, hard disc, compact flash card, USB stick,
19 and the likes; recently, since bootxx itself was made El Torito capable,
20 this has become the desired method for El Torito boot), any bootloader
21 compliant with the Multiboot specification (as boot is a Multiboot com-
22 pliant OS Kernel image), or after renaming to ldbsd.com by any bootloader
23 implementing the COMBOOT API (specified by SYSLINUX, EXTLINUX, ISOLINUX,
24 PXELINUX) or MS-DOS(R) (unless DOS occupies the HMA). Once loaded, it can
25 be used, in a more or less limited fashion, to boot a MirOS kernel from a
26 supported filesystem (4.2FFS, ISO 9660, FAT12, FAT16, FAT28, TFTP, NFS),
27 inspect the filesystems, get or set machine information, or load other
28 bootloaders (see below for details). It can inflate gzip(1) compressed
29 files, set up serial console, and provides an interactive prompt.
31 Basic operation procedure is as follows:
35 BIOS We are loaded to 0x07C00. The drive used to load us from
36 is passed in the DL register. The ES:BX and DS:SI regis-
37 ters and the stack contain additional data. While we do
38 not care about the actual address, we expect to be whole.
40 bootxx We are loaded at the final address. The drive used to
41 load us from is passed in a special memory location. The
42 DS:SI registers are set up if we were loaded from a HDD
43 partition. The Master Boot Record (/usr/mdec/mbrldr or
44 /usr/mdec/mbrmgr) takes care to set these up correctly.
46 PXE The NIC's PXE boot ROM initialises the NIC, network
47 driver, UNDI and PXE interfaces, contacts a DHCP server
48 by broadcasting an IPv4 request on the network, gets an
49 IP address and the name of a file to load from the DHCP
50 server, and downloads the file indicated via TFTP to
51 0x07C00. That would be boot. Control is then passed to
52 address 0x07C00 with ES:BX and the stack set up.
54 PXE booting is useful for diskless(8) clients or initial
55 download and execution of the installation kernel,
56 bsd.rd, or for rescue system purposes.
58 DOS We are loaded to xxxx:0100h with no drive or PXE informa-
59 tion set up. The interrupt vectors are hooked by DOS, so
60 if we overwrite any memory in use by DOS, we lose. That
61 would be the case if xxxx is larger than our final ad-
62 dress, any hooks point to an address between our final
63 address and 9000:0000h, the HMA is in use (because that's
64 where the kernel is loaded to), or somesuch. This also
65 implies we cannot chain any other bootloader. Further-
66 more, we require the machine to be in Real Mode, not in
67 VM86 mode, so EMM386.SYS, Win32 or similar must not be
68 active. We ask DOS for the current drive to use this in-
71 COMBOOT We are loaded in a similar way as from DOS, except the
72 machine state is not changed as much from the initial
73 state. After determining that we are in fact loaded via
74 COMBOOT and not DOS, we ask SYSLINUX to terminate after
75 gathering information about the boot drive, partition, or
76 PXE; the UNDI and PXE stacks are kept active if any.
78 Multiboot We request to be loaded to 0x00100000 (the HMA) due to
79 GNU GRUB's limitations, save the boot device off the MBI
80 structure, copy ourselves to the final location, and
81 switch back to Real Mode.
83 During the initial operation, the stack is located about 80 KiB
84 behind the start of our own memory area, and switched to the final
85 location if the position in memory is known to be correct early.
87 2. System information (boot drive, potential partition table entry,
88 PXENV+ and !PXE structure pointers) are stored in safe locations.
90 3. The code is relocated to the final address once or twice if needed.
91 The final address is 4000:0000h with the stack beginning at
92 3000:FFFCh. The stack is shared between Real Mode and 32-bit Virtual
93 Protected Address Mode. The code is mostly organised using the small
94 memory model, with everything within 64 KiB (although the real limit
95 is more than 256 bytes less than that due to initial loading is-
96 sues), except some rather large uninitialised areas and the disc I/O
97 bounce buffer, which begin at 3000:0000 and grow upwards. The heap
98 begins after the bss section and grows up to just short of
101 4. If the bootloader is compiled to do so, for example on a Live CD, it
102 displays a boot menu unless the shift key is pressed, and retains
103 the numeric return value for later, to replace the cfg suffix of the
104 configuration file with it.
106 5. The IDT for the Protected Mode is set up.
108 6. The system is switched to Protected Mode.
110 7. The hardware is probed:
112 + o Console devices: the default BIOS console (INT 10h, which may be
113 a MDA/MGA/Hercules, CGA/EGA or VGA CRT/LCD, plus DIN or PS/2 or
114 emulated keyboard) as well as up to four serial ports (via the
116 + o Memory: ask the BIOS and probe page by page through the address
117 space, in case the BIOS reports wrong information.
121 8. Unless a control key is held, the files /x.x.x.x/boot.cfg (where
122 x.x.x.x is our own IPv4 address) and /boot.cfg (with cfg possibly
123 replaced from the menu) are read and executed as if the commands had
124 been entered on the loader prompt.
126 9. The bootloader prompt
130 is issued, and a command line is read. If no key is pressed within
131 five seconds, the kernels /bsd and /bsd.old are tried, in order, to
132 be booted with the current parameters; if unsuccessful or any key is
133 pressed, the timeout is disabled (it can be manipulated from the
134 configuration file or command line). The system will be unable to
135 boot if no suitable kernel image is found.
137 Commands from the configuration file and the loader prompt are read line
138 by line and executed as read. Empty lines and lines beginning with the
139 comment character, '#', are ignored when reading from the configuration
140 file. Just entering an empty line at the loader prompt, however, will do
141 the default action of booting a kernel with the current parameters. To
142 pass multiple commands on a line, use the U+0060 character, '`', as del-
143 imiter. To pass multiple commands into a macro definition, use the tilde,
144 '~', as delimiter. Leading and trailing whitespace is ignored.
147 The following commands are accepted at the loader prompt:
150 Boots the kernel image specified by image with any options given.
151 If the image file specification, or one of its device or filename
152 parts (see below) is omitted, values from variables will be used.
154 -a Causes the kernel to ask for the root filesystem to use.
156 -c Causes the kernel to go into UKC(8) before performing
159 -d Causes the kernel to drop into ddb(4) at the earliest con-
162 -s Attempts to boot into single-user mode.
165 Displays the file onto the console. Output is paginated every 24
168 echo Displays the arguments onto the console.
170 env On i386, this command is not used.
172 help Prints a list of available commands.
175 Prints the content of the specified directory in long format.
176 Output is paginated every 24 lines.
178 The cd9660, tftp and nfs filesystems do not support this command.
179 They will either always fail or always succeed with sane but
180 unusable results. The FAT12, FAt16 and FAT28 filesystems have
181 hardcoded perms and uid/gid.
184 Issues machine-specific commands:
186 boot dev Load a bootsector (MBR or PBR) from the indicated dev-
187 ice and boot it. Possible devices are fd0 (floppy
188 boot), hd0 (MBR), hd0a, hd0b, hd0c, hd0d (PBR), and
189 some more useless combinations.
191 diskinfo Display a list of probed floppy and hard disc drives
192 including BIOS and geometry information.
195 Load a bootsector or other bootloader from an image
196 file and execute it. Currently known values for type:
198 grub GNU GRUB 0.9x stage2 file
199 GNU GRUB 0.9x stage2_eltorito file
200 GNU GRUB2 core.img file
202 sector Boot sector or image, loaded to 0000:7C00h
203 MirOS boot second-stage loader
206 Displays the idea boot has about the disklabel of the
207 currently active or the specified device.
210 If used without any arguments, print the current idea
211 boot has about the memory configuration taken from BIOS
212 or probed. Arguments having the form of
216 add (+) or exempt (-) the specified amount of memory.
217 Both size and base address can be specified in decimal,
218 octal or hexadecimal, using standard C prefixes.
220 Memory segments are not required to be adjacent to each
221 other; the only requirement is that there is real phy-
222 sical memory under the range added. The following exam-
223 ple adds 32 MiB of memory right after the first 16 MiB:
225 boot> machine mem +0x2000000@0x01000000
227 Another useful command is to withdraw a range of memory
228 from OS usage, which may have been wrongfully reported
229 as useful by the BIOS. This example excludes the 1516
230 MiB range from the map of useful memory:
232 boot> machine mem -0x100000@0x00F00000
234 regs Debugging command displaying register dumps.
236 oldbios Enable or disable the so-called "Old BIOS / Soekris
237 helper", which restricts boot from loading more than
238 one sector at a time from disc.
240 macro Displays the names of all currently defined macros. Up to four
241 can be defined, holding up to 256 characters.
244 Deletes the macro name, or defines it to cmd.
246 reboot Initiates a warm machine reboot.
249 If invoked without arguments, prints a list of variables and
250 their values. If only a name is given, the value of that variable
251 is displayed. Otherwise, the variable is set to the new value.
252 The following variables are defined:
254 addr Address at which to load the kernel
258 device Boot device name (see below)
260 doboot "0" disables automatic boot on entering an empty line
262 howto Options passed to the loaded kernel, see boot
264 image File name containing the kernel image
266 timeout Number of seconds to wait for human intervention before
269 tty Name of the active console device, for example:
274 stty [device [speed]]
275 Displays or sets the speed for a console device. If the baudrate
276 for the currently active console device is changed, boot offers
277 you five seconds of grace period to switch your terminal to
278 match. If the baudrate for an inactive device is changed, it will
279 only become active on the next switch to a serial console device;
280 it is not used on the PC CRT console.
282 The default baudrate is 9600 bps. boot uses eight data bits, no
283 parity, one stop bit.
285 time Displays the system date and time.
288 An image specification consists of two parts, the device name and a path-
289 name, separated by a colon (':'). In most circumstances, both can be om-
290 itted, and pathnames do not need to begin with a leading slash even if
291 they are absolute. Note that, for some filesystems, you are limited to an
292 8.3 character naming scheme with case insensitive (mapped to lowercase)
293 filenames. Other filesystems may not provide directory listing informa-
294 tion or the ability to stat files (especially remote filesystems).
296 Examples of valid image specifications are:
300 + o cd0a:/boot/grub/stage2
302 Disklabels are read from hard discs (BIOS drive >= 80h) by searching for
303 a primary MirOS partition first. The default partition type, 0x27, can be
304 changed at installboot(8) time, where it is hardcoded into the partition
305 boot record. If no suitable MBR partition was found or we're on a floppy,
306 the disklabel is searched at the beginning of the drive instead. The la-
307 bel offset for the i386 architecture is one 512-byte sector. On MirOS
308 DuaLive CDs, it may be embedded in the first-stage sparc bootloader. If
309 no disklabel can be read from the disc, one is faked. The device size
310 ('c' slice) defaults to the size of an 1440 KiB floppy disc, but if any
311 MBR primary partitions are found which span more space, their values are
312 used instead. The 'd', 'e', 'f' and 'g' slices are filled with the four
313 MBR primary partitions, if any. The 'a' slice is filled, in this order,
314 with: the partition passed via DS:SI if plausible, the first non-empty
315 MBR partition ('d'-'g' slices), the whole disc ('c' slice).
318 /usr/mdec/bootxx first stage bootloader (PBR)
319 /usr/mdec/boot second stage bootloader
320 /usr/mdec/mbrldr hard disc MBR, simple version
321 /usr/mdec/mbrmgr MBR, bootmanager version
322 /boot usual location of installed loader
323 ldbsd.com alternative name for boot
324 /boot.cfg boot configuration file
325 /bsd standard kernel image
326 /bsd.rd kernel image for installation/recovery
327 /bsd.old alternative kernel image
328 /etc/dhcpd.conf dhcpd(8) configuration file
329 /tftpboot/boot standard location of boot for netboot
330 /tftpboot/boot.cfg common/shared boot configuration file on the TFTP
331 server; /tftpboot/10.11.12.13/boot.cfg contains
332 peer-specific configuration to be used instead
333 /tftpboot/bsd kernel image
334 /tftpboot/pxeboot deprecated, no longer in use
337 A sample configuration file for dhcpd(8) is already contained with MirOS
338 and might look as follows:
340 shared-network KICKSTART {
341 subnet 172.23.42.0 netmask 255.255.255.0 {
342 option routers 172.23.42.1;
344 range 172.23.42.10 172.23.42.199;
348 Boot the default kernel:
352 Remove the 5 second pause at boot-time permanently, causing boot to load
353 the kernel immediately without prompting:
355 # echo "boot" >/boot.cfg
357 Remove the 5 second pause at boot-time permanently, causing boot to do
358 nothing automatically:
360 # echo "set timeout 0" >/boot.cfg
362 Use serial console. A null modem cable should connect the specified seri-
363 al port to a terminal. Useful for debugging.
367 Invoke the serial console at every boot:
369 # echo "set tty com0" >/boot.cfg
371 Multiple commands on one line are useful for machines whose serial con-
372 sole is unusable from within the boot loader, but the only way to talk to
373 the kernel, e.g. for installation on a Soekris/WRAP:
375 boot> stty com0 38400 ` set tty com0 ` boot /bsd.rd
377 Boot the kernel named /bsd from the second hard disc in "User Kernel
378 Configuration" mode (see boot_config(8)). This mechanism allows for the
379 explicit enabling and disabling of devices during the current boot se-
380 quence, as well as the modification of device parameters. Once booted,
381 such changes can be made permanent by using config(8)'s -e option.
383 boot> boot hd1a:/bsd -c
386 gzip(1), compress(3), autoconf(4), ddb(4), dhcpd.conf(5), boot_config(8),
387 boot_i386(8), dhcpd(8), diskless(8), fdisk(8), httpd(8), inetd(8),
388 installboot(8), reboot(8), tftpd(8)
390 Intel Corporation, Preboot Execution Environment (PXE) Specification,
391 Version 2.1, September 20, 1999.
394 This bootloader is based on code written by Michael Shalayeff for
395 OpenBSD 2.1. The separate pxeboot command first appeared in OpenBSD 3.5,
396 based upon work from NetBSD. In OpenBSD and MirOS #7 and below, the
397 boot.cfg file was called boot.conf, it has been renamed for ISO 9660 and
398 FAT compatibility. A version called cdboot appeared in MirOS #8 and went
399 away for MirOS #10. The separate versions got merged into one bootloader,
400 DOS, COMBOOT, Multiboot support, pagination, macros, the machine exec and
401 cat commands, working chainbooting of bootsectors and GNU GRUB, faked
402 disklabels (if none exist on disc), FAT filesystem support, and many more
403 things were added or rewritten for MirOS #11 and grml by Thorsten Glaser.
406 The default location of the kernels and the boot.cfg file can be changed
409 MirOS BSD #10-current February 1, 2009 6