d3f263a925a32dc2b3add01798cb083e1cd08552
[grml-live.git] / templates / boot / addons / bsd4grml / ldbsd.txt
1 BOOT(8)               BSD System Manager's Manual (i386)               BOOT(8)
2
3 NAME
4      boot, boot.cfg, ldbsd.com, pxeboot - i386 second-stage boot loader
5
6 DESCRIPTION
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, the Multiboot Specification, etc. MirOS floppies
13      use a specially limited version optimised for size, lacking support for
14      any filesystem other than 4.2FFS and most commands.
15
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      and a pseudo filesystem called lmbmfs), inspect the filesystems, get or
28      set machine information, or load other bootloaders (see below for de-
29      tails). It can inflate gzip(1) compressed files (with LZMA compression
30      planned), set up serial console, and provides an interactive prompt.
31
32      Basic operation procedure is as follows:
33
34      1.   Be loaded.
35
36           BIOS       We are loaded to 0x07C00. The drive used to load us from
37                      is passed in the DL register. The ES:BX and DS:SI regis-
38                      ters and the stack contain additional data. While we do
39                      not care about the actual address, we expect to be whole.
40
41           bootxx     We are loaded at the final address. The drive used to
42                      load us from is passed in a special memory location. The
43                      DS:SI registers are set up if we were loaded from a HDD
44                      partition. The Master Boot Record  (/usr/mdec/mbrldr or
45                      /usr/mdec/mbrmgr) takes care to set these up correctly.
46
47           PXE        The NIC's PXE boot ROM initialises the NIC, network
48                      driver, UNDI and PXE interfaces, contacts a DHCP server
49                      by broadcasting an IPv4 request on the network, gets an
50                      IP address and the name of a file to load from the DHCP
51                      server, and downloads the file indicated via TFTP to
52                      0x07C00. That would be boot. Control is then passed to
53                      address 0x07C00 with ES:BX and the stack set up.
54
55                      PXE booting is useful for diskless(8) clients or initial
56                      download and execution of the installation kernel,
57                      bsd.rd, or for rescue system purposes.
58
59           DOS        We are loaded to xxxx:0100h with no drive or PXE informa-
60                      tion set up. The interrupt vectors are hooked by DOS, so
61                      if we overwrite any memory in use by DOS, we lose. That
62                      would be the case if xxxx is larger than our final ad-
63                      dress, any hooks point to an address between our final
64                      address and 9000:0000h, the HMA is in use (because that's
65                      where the kernel is loaded to), or somesuch. This also
66                      implies we cannot chain any other bootloader. Further-
67                      more, we require the machine to be in Real Mode, not in
68                      VM86 mode, so EMM386.SYS, Win32 or similar must not be
69                      active. We ask DOS for the current drive to use this in-
70                      formation later. DOS has set up a PSP (Program Segment
71                      Prefix) for us, which may contain a command line which we
72                      store away for later perusal if it is not empty.
73
74           COMBOOT    We are loaded in a similar way as from DOS, except the
75                      machine state is not changed as much from the initial
76                      state. After determining that we are in fact loaded via
77                      COMBOOT and not DOS, we ask SYSLINUX to terminate after
78                      gathering information about the boot drive, partition, or
79                      PXE; the UNDI and PXE stacks are kept active if any. The
80                      COMBOOT API has set up a PSP like DOS as well, which we
81                      handle the same.
82
83           Multiboot  We request to be loaded to 0x00100000 (the HMA) due to
84                      GNU GRUB's limitations, save the boot device off the MBI
85                      structure, copy ourselves to the final location, and
86                      switch back to Real Mode. Modules passed to us by the
87                      Multiboot compliant boot loader will be moved off to just
88                      above 20 MiB in memory; their dirnames as well as any
89                      command lines to the Multiboot modules are discarded. If
90                      a command line is passed to the Multiboot OS kernel, i.e.
91                      this bootloader, the pathname of the loader is skipped;
92                      it is then cut off after a certain size limit (currently,
93                      256 bytes) and stored away for later use. The modules are
94                      made available as regular files using the virtual lmbm
95                      (Loadable Multiboot Modules) device and filesystem (in-
96                      RAM file store, really).
97
98           During the initial operation, the stack is located about 80 KiB
99           behind the start of our own memory area, and switched to the final
100           location if the position in memory is known to be correct early.
101
102      2.   System information (boot drive, potential partition table entry,
103           PXENV+ and !PXE structure pointers, multiboot module information)
104           are stored in safe locations.
105
106      3.   The code is relocated to the final address once or twice if needed.
107           The final address is 4000:0000h with the stack beginning at
108           3000:FF7Ch. The 128 bytes in between, from 3000:FF80h onwards, con-
109           tains a potentially stored away PSP command line, before it is moved
110           to the buffer after the bss and ssbss sections have been initialised
111           (zeroed out). The stack is shared between Real Mode and 32-bit Vir-
112           tual Protected Address Mode. The code is mostly organised using the
113           small memory model, with everything within 64 KiB (although the real
114           limit is more than 256 bytes less than that due to initial loading
115           issues), except some rather large uninitialised areas and the disc
116           I/O bounce buffer, which begin at 3000:0000 and grow upwards, nick-
117           named the ssbss section. The heap begins after the bss section and
118           grows up to just short of 9000:0000h.
119
120      4.   If the bootloader is compiled to do so, for example on a Live CD, it
121           displays a boot menu unless the shift key is pressed, and retains
122           the numeric return value for later, to replace the cfg suffix of the
123           configuration file with it, unless a (non-empty) command line is
124           passed.
125
126      5.   The system is switched to Protected Mode.
127
128      6.   If a command line was passed, it is moved from its original (Multi-
129           boot, above 1 MiB or way below in the real mode area) or temporary
130           (0x3FF80) location to cmd_buf.
131
132      7.   The hardware is probed:
133
134         + o Console devices: the default BIOS console (INT 10h, which may be
135               a MDA/MGA/Hercules, CGA/EGA or VGA CRT/LCD, plus DIN or PS/2 or
136               emulated keyboard) as well as up to four serial ports (via the
137               BIOS interface).
138         + o Memory: ask the BIOS and probe page by page through the address
139               space, in case the BIOS reports wrong information.
140         + o APM support
141         + o PXE support
142         + o Loadable Multiboot Modules (if any, they are moved off to safe
143               locations and the virtual lmbm device and lmbmfs are set up)
144         + o Floppy disc drives
145         + o Hard disc drives, including El Torito CD-ROM drives
146
147      8.   If a command line was passed, it is executed. If it contained a boot
148           command, the kernel is attempted to be loaded; otherwise, or if it
149           fails, execution flow continues at the command prompt (see below)
150           with no timeout or auto-boot enabled.
151
152      9.   Unless a control key is held or a command line was passed, the files
153           /x.x.x.x/boot.cfg if loaded via PXE (where x.x.x.x is our own IPv4
154           address) and /boot.cfg, with "cfg" possibly replaced from the Live
155           CD menu, are read and executed as if the commands had been entered
156           on the loader prompt.
157
158      10. The bootloader prompt
159
160                 boot> _
161
162           is issued, and a command line is read. If no key is pressed within
163           five seconds, the kernels /bsd and /bsd.old are tried, in order, to
164           be booted with the current parameters; if unsuccessful or any key is
165           pressed, the timeout is disabled (it can be manipulated from the
166           configuration file or command line). The system will be unable to
167           boot if no suitable kernel image is found.
168
169      Commands from the configuration file and the loader prompt are read line
170      by line and executed as read. Empty lines and lines beginning with the
171      comment character, '#', are ignored when reading from the configuration
172      file. Just entering an empty line at the loader prompt, however, will do
173      the default action of booting a kernel with the current parameters. To
174      pass multiple commands on a line, use the U+0060 character, '`', as del-
175      imiter. To pass multiple commands into a macro definition, use the tilde,
176      '~', as delimiter. Leading and trailing whitespace is ignored.
177
178 COMMANDS
179      The following commands are accepted at the loader prompt:
180
181      boot [image [-acds]]
182              Boots the kernel image specified by image with any options given.
183              If the image file specification, or one of its device or filename
184              parts (see below) is omitted, values from variables will be used.
185
186              -a   Causes the kernel to ask for the root filesystem to use.
187
188              -c   Causes the kernel to go into UKC(8) before performing
189                   autoconf(4).
190
191              -d   Causes the kernel to drop into ddb(4) at the earliest con-
192                   venient point.
193
194              -s   Attempts to boot into single-user mode.
195
196      cat image
197              Displays the file onto the console. Output is paginated every 24
198              lines.
199
200      echo    Displays the arguments onto the console.
201
202      env     On i386, this command is not used.
203
204      help    Prints a list of available commands.
205
206      ls [dirspec]
207              Prints the content of the specified directory in long format.
208              Output is paginated every 24 lines.
209
210              The cd9660, tftp and nfs filesystems do not support this command.
211              They will either always fail or always succeed with sane but
212              unusable results. The FAT12, FAT16 and FAT28 filesystems have
213              hardcoded perms and uid/gid.
214
215      machine [command]
216              Issues machine-specific commands:
217
218              boot dev  Load a bootsector (MBR or PBR) from the indicated dev-
219                        ice and boot it. Possible devices are fd0 (floppy
220                        boot), hd0 (MBR), hd0a, hd0b, hd0c, hd0d (PBR), and
221                        some more useless combinations.
222
223              diskinfo  Display a list of probed floppy and hard disc drives
224                        including BIOS and geometry information.
225
226              exec dos  Execute INT 21h, AH=4Ch, to return to DOS or SYSLINUX,
227                        if possible. This will not always work and may hang
228                        your system.
229
230              exec type image
231                        Load a bootsector or other bootloader from an image
232                        file and execute it. Currently known values for type:
233
234                        grub    GNU GRUB 0.9x stage2 file
235                                GNU GRUB 0.9x stage2_eltorito file
236                                GNU GRUB2 core.img file
237
238                        sector  Boot sector or image, loaded to 0000:7C00h
239                                MirOS boot second-stage loader
240
241              label [device]
242                        Displays the idea boot has about the disklabel of the
243                        currently active or the specified device.
244
245              memory [arg]
246                        If used without any arguments, print the current idea
247                        boot has about the memory configuration taken from BIOS
248                        or probed. Arguments having the form of
249
250                              [+-]<size>@<address>
251
252                        add (+) or exempt (-) the specified amount of memory.
253                        Both size and base address can be specified in decimal,
254                        octal or hexadecimal, using standard C prefixes.
255
256                        Memory segments are not required to be adjacent to each
257                        other; the only requirement is that there is real phy-
258                        sical memory under the range added. The following exam-
259                        ple adds 32 MiB of memory right after the first 16 MiB:
260
261                              boot> machine mem +0x2000000@0x01000000
262
263                        Another useful command is to withdraw a range of memory
264                        from OS usage, which may have been wrongfully reported
265                        as useful by the BIOS. This example excludes the 1516
266                        MiB range from the map of useful memory:
267
268                              boot> machine mem -0x100000@0x00F00000
269
270              regs      Debugging command displaying register dumps.
271
272              oldbios   Enable or disable the so-called "Old BIOS / Soekris
273                        helper", which restricts boot from loading more than
274                        one sector at a time from disc.
275
276      macro   Displays the names of all currently defined macros. Up to four
277              can be defined, holding up to 256 characters.
278
279      macro name [cmd]
280              Deletes the macro name, or defines it to cmd.
281
282      reboot  Initiates a warm machine reboot.
283
284      set [name [value]]
285              If invoked without arguments, prints a list of variables and
286              their values. If only a name is given, the value of that variable
287              is displayed. Otherwise, the variable is set to the new value.
288              The following variables are defined:
289
290              addr     Address at which to load the kernel
291
292              debug    Debug flag
293
294              device   Boot device name (see below)
295
296              doboot   "0" disables automatic boot on entering an empty line
297
298              howto    Options passed to the loaded kernel, see boot
299
300              image    File name containing the kernel image
301
302              timeout  Number of seconds to wait for human intervention before
303                       auto-booting
304
305              tty      Name of the active console device, for example:
306                     + o com0
307                     + o com1
308                     + o pc0
309
310      stty [device [speed]]
311              Displays or sets the speed for a console device. If the baudrate
312              for the currently active console device is changed, boot offers
313              you five seconds of grace period to switch your terminal to
314              match. If the baudrate for an inactive device is changed, it will
315              only become active on the next switch to a serial console device;
316              it is not used on the PC CRT console.
317
318              The default baudrate is 9600 bps. boot uses eight data bits, no
319              parity, one stop bit.
320
321      time    Displays the system date and time.
322
323 IMAGE SPECIFICATIONS
324      An image specification consists of two parts, the device name and a path-
325      name, separated by a colon (':'). In most circumstances, both can be om-
326      itted, and pathnames do not need to begin with a leading slash even if
327      they are absolute. Note that, for some filesystems, you are limited to an
328      8.3 character naming scheme with case insensitive (mapped to lowercase)
329      filenames. Other filesystems may not provide directory listing informa-
330      tion or the ability to stat files (especially remote filesystems).
331
332      Examples of valid image specifications are:
333    + o fd0a:/bsd
334    + o hd0o:/bsd.rd
335    + o / (for "ls")
336    + o hd0a:/ (for "ls")
337    + o lmbm:/ (for "ls")
338    + o cd0a:/boot/grub/stage2
339    + o tftp:/bsd.rd.i386
340    + o lmbm:/bsd4grml
341    + o /bsd
342
343      Disklabels are read from hard discs (BIOS drive >= 80h) by searching for
344      a primary MirOS partition first. The default partition type, 0x27, can be
345      changed at installboot(8) time, where it is hardcoded into the partition
346      boot record. If no suitable MBR partition was found or we're on a floppy,
347      the disklabel is searched at the beginning of the drive instead. The la-
348      bel offset for the i386 architecture is one 512-byte sector. On MirOS
349      DuaLive CDs, it may be embedded in the first-stage sparc bootloader. If
350      no disklabel can be read from the disc, one is faked. The device size
351      ('c' slice) defaults to the size of an 1440 KiB floppy disc, but if any
352      MBR primary partitions are found which span more space, their values are
353      used instead. The 'd', 'e', 'f' and 'g' slices are filled with the four
354      MBR primary partitions, if any. The 'a' slice is filled, in this order,
355      with: the partition passed via DS:SI if plausible, the first non-empty
356      MBR partition ('d'-'g' slices), the whole disc ('c' slice).
357
358 FILES
359      /usr/mdec/bootxx    first stage bootloader (PBR)
360      /usr/mdec/boot      second stage bootloader
361      /usr/mdec/mbrldr    hard disc MBR, simple version
362      /usr/mdec/mbrmgr    MBR, bootmanager version
363      /boot               usual location of installed loader
364      ldbsd.com           alternative name for boot
365      /boot.cfg           boot configuration file
366      /bsd                standard kernel image
367      /bsd.rd             kernel image for installation/recovery
368      /bsd.old            alternative kernel image
369      /etc/dhcpd.conf     dhcpd(8) configuration file
370      /tftpboot/boot      standard location of boot for netboot
371      /tftpboot/boot.cfg  common/shared boot configuration file on the TFTP
372                          server; /tftpboot/10.11.12.13/boot.cfg contains
373                          peer-specific configuration to be used instead
374      /tftpboot/bsd       kernel image
375      /tftpboot/pxeboot   deprecated, no longer in use
376
377 EXAMPLES
378      A sample configuration file for dhcpd(8) is already contained with MirOS
379      and might look as follows:
380
381            shared-network KICKSTART {
382                    subnet 172.23.42.0 netmask 255.255.255.0 {
383                            option routers 172.23.42.1;
384                            filename "boot";
385                            range 172.23.42.10 172.23.42.199;
386                    }
387            }
388
389      Boot the default kernel:
390
391            boot> boot
392
393      Remove the 5 second pause at boot-time permanently, causing boot to load
394      the kernel immediately without prompting:
395
396            # echo "boot" >/boot.cfg
397
398      Remove the 5 second pause at boot-time permanently, causing boot to do
399      nothing automatically:
400
401            # echo "set timeout 0" >/boot.cfg
402
403      Use serial console. A null modem cable should connect the specified seri-
404      al port to a terminal. Useful for debugging.
405
406            boot> set tty com0
407
408      Invoke the serial console at every boot:
409
410            # echo "set tty com0" >/boot.cfg
411
412      Multiple commands on one line are useful for machines whose serial con-
413      sole is unusable from within the boot loader, but the only way to talk to
414      the kernel, e.g. for installation on a Soekris/WRAP:
415
416            boot> stty com0 38400 ` set tty com0 ` boot /bsd.rd
417
418      Boot the kernel named /bsd from the second hard disc in "User Kernel
419      Configuration" mode (see boot_config(8)). This mechanism allows for the
420      explicit enabling and disabling of devices during the current boot se-
421      quence, as well as the modification of device parameters. Once booted,
422      such changes can be made permanent by using config(8)'s -e option.
423
424            boot> boot hd1a:/bsd -c
425
426 SEE ALSO
427      gzip(1), compress(3), autoconf(4), ddb(4), dhcpd.conf(5), boot_config(8),
428      boot_i386(8), dhcpd(8), diskless(8), fdisk(8), httpd(8), inetd(8),
429      installboot(8), reboot(8), tftpd(8)
430
431      Intel Corporation, Preboot Execution Environment (PXE) Specification,
432      Version 2.1, September 20, 1999.
433
434      Free Software Foundation, Inc., Multiboot Specification, Version 0.6.93.
435
436 HISTORY
437      This bootloader is based on code written by Michael Shalayeff for
438      OpenBSD 2.1. The separate pxeboot command first appeared in OpenBSD 3.5,
439      based upon work from NetBSD. In OpenBSD and MirOS #7 and below, the
440      boot.cfg file was called boot.conf, it has been renamed for ISO 9660 and
441      FAT compatibility. A version called cdboot appeared in MirOS #8 and went
442      away for MirOS #10. The separate versions got merged into one bootloader,
443      DOS, COMBOOT, Multiboot support (including modules), pagination, macros,
444      the machine exec and cat commands, working chainbooting of bootsectors
445      and GNU GRUB, faked disklabels (if none exist on disc), FAT filesystem
446      support, and many more things were added or rewritten for MirOS #11 and
447      MirOS bsd4grml by Thorsten Glaser.
448
449 CAVEATS
450      The default location of the kernels and the boot.cfg file can be changed
451      at compile time.
452
453   FILESYSTEM SPECIFIC NOTES
454
455      ISO 9660   Filesystems above 4 GiB in size definitively do not work. We
456                 do not know at this time if there is a 2 GiB or 4 GiB limit,
457                 nor if this affects any other filesystems.
458
459                 The ls command does not work.
460
461      lmbmfs     This filesystem and device will only appear if loaded via a
462                 Multiboot compliant boot loader, masquerading as Multiboot
463                 compliant OS kernel, and when modules are passed. ls is possi-
464                 ble only on the root directory ("/", "/."). Files keep the
465                 names passed by the Multiboot boot loader, but have the direc-
466                 tory part stripped, and can be accessed with any directory
467                 leading. If they have no names, they are given an enumerated
468                 hex number as name.
469
470      tftp, nfs  These filesystems and devices will only appear of loaded via
471                 PXE. They obviously do not support ls.
472
473      http       There are plans to support this if pxebsd.0 is loaded from
474                 gPXE, but no code yet. For now, gPXE can load boot using Mul-
475                 tiboot, and any passed modules are handled via lmbmfs.
476
477      ustarfs    This filesystem will be implemented soon.
478
479 MirOS BSD #10-current          October 24, 2009                              7