1*6a103917Sjmc.\" $OpenBSD: biosboot.8,v 1.20 2004/04/03 10:15:37 jmc Exp $ 2df1f5d3aSweingart.\" 391a78840Stom.\" Copyright (c) 2003 Tom Cosgrove <tom.cosgrove@arches-consulting.com> 4897f5cfcSmickey.\" Copyright (c) 1997 Michael Shalayeff 5897f5cfcSmickey.\" All rights reserved. 6df1f5d3aSweingart.\" 7df1f5d3aSweingart.\" Redistribution and use in source and binary forms, with or without 8df1f5d3aSweingart.\" modification, are permitted provided that the following conditions 9df1f5d3aSweingart.\" are met: 10df1f5d3aSweingart.\" 1. Redistributions of source code must retain the above copyright 11df1f5d3aSweingart.\" notice, this list of conditions and the following disclaimer. 12df1f5d3aSweingart.\" 2. Redistributions in binary form must reproduce the above copyright 13df1f5d3aSweingart.\" notice, this list of conditions and the following disclaimer in the 14df1f5d3aSweingart.\" documentation and/or other materials provided with the distribution. 15df1f5d3aSweingart.\" 16897f5cfcSmickey.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17897f5cfcSmickey.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18897f5cfcSmickey.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19df1f5d3aSweingart.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20df1f5d3aSweingart.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21df1f5d3aSweingart.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 228855a495Smickey.\" OR SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23df1f5d3aSweingart.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24df1f5d3aSweingart.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25df1f5d3aSweingart.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26df1f5d3aSweingart.\" SUCH DAMAGE. 27df1f5d3aSweingart.\" 2891a78840Stom.Dd December 23, 2003 29897f5cfcSmickey.Dt BIOSBOOT 8 i386 30fc8533a3Saaron.Os 31df1f5d3aSweingart.Sh NAME 32897f5cfcSmickey.Nm biosboot 33df1f5d3aSweingart.Nd 348855a495Smickeyi386-specific first-stage system bootstrap 35df1f5d3aSweingart.Sh DESCRIPTION 361d7096c9SmickeyThis small program (roughly 512 bytes of code) is responsible for 3791a78840Stomloading the second-stage 38897f5cfcSmickey.Xr boot 8 3991a78840Stomprogram (typically /boot), which in turn will load the kernel. 40df1f5d3aSweingart.Pp 41e20327dbSflipk.Nm 4291a78840Stommust be installed by 4391a78840Stom.Xr installboot 8 . 4491a78840StomAs part of the installation, 4591a78840Stom.Xr installboot 8 4691a78840Stompatches 47e20327dbSflipk.Nm 4891a78840Stomwith information about the location of 4997ce4b56Sweingart.Xr boot 8 5091a78840Stomon disk. 5191a78840StomSpecifically, it writes the filesystem block number of 5291a78840Stom.Xr boot 8 's 5391a78840Stominode, 5491a78840Stomthe offset within this block of the inode, 5591a78840Stomand various filesystem parameters (taken from the superblock) 5691a78840Stomrequired to convert filesystem blocks to disk sectors. 5791a78840Stom.Pp 5891a78840StomYou must re-run 5991a78840Stom.Xr installboot 8 6091a78840Stomwhenever 6191a78840Stom.Xr boot 8 6291a78840Stomis changed, as its inode may change. 6391a78840StomWhile it should not be necessary, 6491a78840Stomit may also be advisable to re-run 6591a78840Stom.Xr installboot 8 6691a78840Stomif you move your disk between machines and/or controllers. 6797ce4b56Sweingart.Pp 6897ce4b56SweingartWhen 6997ce4b56Sweingart.Nm 7091a78840Stomreceives control from either the BIOS or the 7191a78840Stommaster boot record (MBR) it will print the message: 72df1f5d3aSweingart.Pp 7391a78840Stom.Dl Loading 74df1f5d3aSweingart.Pp 7591a78840Stomfollowed by a dot for every filesystem block it attempts to load. 7691a78840StomIf /boot is loaded successfully, 7791a78840Stom.Nm 7891a78840Stomwill put the cursor on the next line just before 7991a78840Stomtransferring control to the newly-loaded program. 8091a78840Stom.Pp 8191a78840StomIf possible, 8291a78840Stom.Nm 8391a78840Stomwill read disk sectors using calls detailed in the Phoenix 8491a78840StomEnhanced Disk Drive Specification (EDD, sometimes known as LBA, reads). 8591a78840StomIt will fall back to CHS reads only if EDD calls are not available. 8691a78840StomHowever, to allow users to boot on hardware that claims LBA capability, 8791a78840Stombut which requires CHS reads in order to boot, 8891a78840Stomthe user may hold down either Shift key during boot. 8991a78840StomIf 9091a78840Stom.Nm 9191a78840Stomdetects this, it will force itself to use CHS calls, ignoring 9291a78840Stomany LBA capability. 9391a78840StomThis will of course prevent booting if /boot lies above the 8 GB 9491a78840StomCHS limit. 9591a78840StomThere is an exported symbol 9691a78840Stom.Dq force_chs 9791a78840Stomof type u_int8_t 9891a78840Stomwhich may be set to 1 to force CHS reads always. 9991a78840Stom(However, no tool is currently provided to set this flag.) 100897f5cfcSmickey.Sh DIAGNOSTICS 10191a78840Stom.Nm 10291a78840Stomprints a 10391a78840Stom.Sq !\& 10491a78840Stombefore the 10591a78840Stom.Dq Loading 10691a78840Stommessage if it is being forced to use CHS rather than LBA reads 10791a78840Stom(by the user holding down either Shift key during boot, 10891a78840Stomor having set the 10991a78840Stom.Dq force_chs 11091a78840Stomflag in the boot sector). 11197ce4b56Sweingart.Pp 11291a78840Stom.Nm 11391a78840Stomprints a 11491a78840Stom.Sq ;\& 11591a78840Stomafter the 11691a78840Stom.Dq Loading 11791a78840Stommessage if it is going to use CHS reads for any reason. 11891a78840StomFor example, when booting from floppy or CD-ROM. 11991a78840Stom.Pp 12091a78840Stom.Nm 12191a78840Stommay fail with any of the following error messages: 12291a78840Stom.Bl -tag -width ERR_X__ 12391a78840Stom.It Er ERR I 12491a78840StomToo many indirect blocks. 12591a78840Stom.Nm 12691a78840Stomis capable of reading the direct blocks in 12791a78840Stom.Xr boot 8 's 12891a78840Stominode (the location of which is patched into 12991a78840Stom.Nm 13091a78840Stomby 13191a78840Stom.Xr installboot 8 ) 13291a78840Stomand the first indirect block, 13391a78840Stombut it is not capable of reading further indirect blocks. 13491a78840StomThis error indicates that further such indirect blocks were found. 13591a78840StomThe system will not be able to boot. 13691a78840Stom.Pp 13791a78840StomThis is unlikely to ever happen in practice, as 13891a78840Stom.Xr boot 8 13991a78840Stomhas to be quite large for this to be an issue. 14091a78840StomThe smallest possible filesystem block size is 512 bytes 14191a78840Stom(one sector per filesystem block). 14291a78840StomOn such a system, there are 140 filesystem blocks that 14391a78840Stom.Nm 14491a78840Stomcan read, so 14591a78840Stom.Xr boot 8 14691a78840Stomcan be up to 70 KB. 14791a78840Stom.Pp 14891a78840StomHowever, even on floppy disks the filesystem block size is 1024 bytes. 14991a78840StomThis allows 15091a78840Stom.Xr boot 8 15191a78840Stomto occupy up to 268 disk blocks, 15291a78840Stomi.e. to be 268 KB. 15391a78840StomOn hard disks (default filesystem block size 16 KB) 15491a78840Stom4,108 disk blocks are available, to allow 15591a78840Stom.Xr boot 8 15691a78840Stomto be over 64 MB in size! 15791a78840Stom(Only direct blocks are required for 15891a78840Stom.Xr boot 8 s 15991a78840Stomof up to 192 KB.) 16091a78840Stom.It Er ERR M 16191a78840StomBad magic. 16291a78840StomThe ELF 16391a78840Stom.Dq magic number 16491a78840Stom\e7fELF in 16591a78840Stom.Xr boot 8 's 16691a78840Stomheader was not found. 16791a78840StomThis indicates that the first block of 16891a78840Stom.Xr boot 8 16991a78840Stomwas not read correctly. 17091a78840StomThis could be due to disk corruption, 17191a78840Stomfailing to run 17291a78840Stom.Xr installboot 8 , 17391a78840Stomgiving an invalid 17491a78840Stom.Xr boot 8 17591a78840Stomprogram as the 17691a78840Stom.Ar boot 17791a78840Stomargument to 17891a78840Stom.Xr installboot 8 , 17991a78840Stomor 18091a78840Stomincorrect geometry translation. 18191a78840Stom.It Er ERR R 18291a78840StomRead error. 18391a78840StomThe BIOS returned an error indication when 18491a78840Stom.Nm 18591a78840Stomattempted to read a disk sector. 18691a78840StomThis might be any media error, including bad sectors (common on floppy disks), 18791a78840Stomand invalid sectors (can occur with bad geometry translations). 18891a78840Stom.Pp 18991a78840StomIf this error occurs during an LBA boot (no 19091a78840Stom.Sq ;\& 19191a78840Stomafter 19291a78840Stom.Dq Loading ) , 19391a78840Stomthen a CHS boot may succeed. 19491a78840StomTo do this, you should reboot, then hold down either Shift key 19591a78840Stombefore 19691a78840Stom.Nm 19791a78840Stomstarts. 19891a78840StomYou should see a 19991a78840Stom.Sq !\& 20091a78840Stombefore 20191a78840Stom.Dq Loading 20291a78840Stomas confirmation that your 20391a78840Stomoverride was accepted. 20491a78840Stom.It Er ERR X 20591a78840StomCan't boot. 20691a78840StomIssued when trying to read sectors in CHS mode, 20791a78840Stombut the BIOS call 20891a78840Stom.Em get\ drive\ parameters 20991a78840Stomfailed or gave a value of 0 for the number of sectors per track. 21091a78840StomIn either case, it is not possible for 21191a78840Stom.Nm 21291a78840Stomto calculate the (cylinder, head, sector) values required to 21391a78840Stomread any sectors. 214dcb23958Sjmc.El 21597ce4b56Sweingart.Sh NOTES 21691a78840StomUsing 21797ce4b56Sweingart.Nm 21891a78840Stomas the MBR, 21991a78840Stomas has been done in the past, 22091a78840Stomis not recommended, and is not supported. 22191a78840StomInstead, create a single 22291a78840Stom.Xr fdisk 8 22391a78840Stompartition that spans the entire disk. 22491a78840Stom.Pp 22591a78840StomDespite the support for 22691a78840Stom.Xr boot 8 22791a78840Stomover the 8 GB boundary, 22891a78840Stomgood 22991a78840Stom.Xr disklabel 8 23091a78840Stompartitioning practices should still be followed. 231df1f5d3aSweingart.Sh FILES 232897f5cfcSmickey.Bl -tag -width /usr/mdec/biosbootxx -compact 233897f5cfcSmickey.It Pa /usr/mdec/mbr 234897f5cfcSmickeyMaster Boot Record block 235897f5cfcSmickey.It Pa /usr/mdec/biosboot 236897f5cfcSmickeyprimary bootstrap 237df1f5d3aSweingart.It Pa /boot 23897ce4b56Sweingartsecondary bootstrap 239*6a103917Sjmc.It Pa /usr/mdec/pxeboot 240*6a103917SjmcPXE bootstrap 241df1f5d3aSweingart.It Pa /bsd 24291a78840Stom.Ox 24391a78840Stomkernel 244df1f5d3aSweingart.El 245df1f5d3aSweingart.Sh SEE ALSO 246350bb3b8Salex.Xr boot 8 , 247897f5cfcSmickey.Xr boot_i386 8 , 24891a78840Stom.Xr disklabel 8 , 249897f5cfcSmickey.Xr fdisk 8 , 250*6a103917Sjmc.Xr installboot 8 , 251*6a103917Sjmc.Xr pxeboot 8 252371254b6Sjmc.Sh HISTORY 25391a78840Stom.Nm 25491a78840Stomwas originally written by Michael Shalayeff for 255371254b6Sjmc.Ox 2.1 . 25691a78840StomHowever it was based on bootstrap code from older versions of this 257371254b6Sjmcoperating system, other operating systems, other programs, and 258371254b6Sjmcother people's work. 25991a78840Stom.Pp 26091a78840StomIt was significantly revised in December 2003 by Tom Cosgrove, 26191a78840Stomin order to support LBA disk access (via the Phoenix Enhanced Disk 26291a78840StomDrive Specification API). 26391a78840StomAt that time the internal table of disk blocks was removed, and 26491a78840Stom.Nm 26591a78840Stommodified to read filesystem block numbers from the inode. 266df1f5d3aSweingart.Sh BUGS 26791a78840Stom.Nm 26891a78840Stomshould perform and verify a checksum across the entire loaded 26991a78840Stom.Xr boot 8 27091a78840Stomimage, 27191a78840Stomrather than just checking the magic number in the first block. 272897f5cfcSmickey.Pp 27397ce4b56SweingartThere is no BIOS error number reported nor is the location of the error 27497ce4b56Sweingartreported. 275897f5cfcSmickey.Pp 276897f5cfcSmickeyYou can pick your motherboard, and you can pick your BIOS, 277897f5cfcSmickeybut you can't pick your motherboard's BIOS. 278