From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NMV7U-00033Z-Oo for mharc-grub-devel@gnu.org; Sun, 20 Dec 2009 18:23:24 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NMV7R-00032c-5G for grub-devel@gnu.org; Sun, 20 Dec 2009 18:23:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NMV7L-00032A-BU for grub-devel@gnu.org; Sun, 20 Dec 2009 18:23:19 -0500 Received: from [199.232.76.173] (port=43579 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NMV7L-000324-6i for grub-devel@gnu.org; Sun, 20 Dec 2009 18:23:15 -0500 Received: from fg-out-1718.google.com ([72.14.220.154]:8027) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NMV7K-0000jD-H8 for grub-devel@gnu.org; Sun, 20 Dec 2009 18:23:14 -0500 Received: by fg-out-1718.google.com with SMTP id 19so3046797fgg.12 for ; Sun, 20 Dec 2009 15:23:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type; bh=wLxYA1ffTiK/+l4UlsREKWHlgYzVmt5YFTA7yKxXvhg=; b=iBIRoKFO0pFUf5aOVqG+BjCi9X37AvLLjpTWv2qxEWkDUMNRA0i+yHK+oaPfKCAz/A j5MXaLkyZtP4g3Y8nAllGXYtTG4z2nzWajcei8AicB1HkwZcqFw8rPpmYHVitBl3Fiis UA9X64LTP/EG9jFktuJ880jXiNRMXekc04tsw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=eF4xToFehyTW5gMUBeXNrqLomPlH/dfb20+A/gA4p7JnWkBtU7dEMOXVZ/mlJO3x1X xIHjc0ErQyWuTohB5UhOjJ09unrt7ByRuem/VrMOnzi/LCf8Lo/8JAyWVWsRqOnLUon4 WNAm/t3Pd6nYrdYNYX6r8XUoFakmgfoJVR3dI= Received: by 10.86.6.2 with SMTP id 2mr734715fgf.22.1261351393377; Sun, 20 Dec 2009 15:23:13 -0800 (PST) Received: from debian.bg45.phnet ([81.62.161.118]) by mx.google.com with ESMTPS id l12sm11648992fgb.5.2009.12.20.15.23.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 20 Dec 2009 15:23:12 -0800 (PST) Message-ID: <4B2EB1D7.4060306@gmail.com> Date: Mon, 21 Dec 2009 00:23:03 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20091109) MIME-Version: 1.0 To: The development of GNU GRUB References: <4B26CA20.9090005@gmail.com> In-Reply-To: <4B26CA20.9090005@gmail.com> X-Enigmail-Version: 0.95.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig36EBA2718B4B79D94E1773CA" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: Understanding GRUB details X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Dec 2009 23:23:21 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig36EBA2718B4B79D94E1773CA Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Bruce Dubbs wrote: > In order to properly document GRUB, I have been reviewing some of the > code at a rather detailed level. My efforts are directed at > developing an intimate level of understanding as a prerequisite for > the documentation effort. I fully understand that many of the details > below are not appropriate for grub.texi, but they may be appropriate > for other venues such as a wiki. > > The GRUB code is fairly complex. Below is a summary of the GRUB boot > process as I understand it from the code. I would appreciate any > corrections or problems you may observe in the description below. > > Thanks. > > -- Bruce > > My analysis so far assumes a i386 pc platform booting from a generic > disk drive and booting linux. > > > Booting the MBR: boot.img (architecture specific) > > The PC BIOS determines the boot device and loads the first physical > sector of that device, commonly known as the Master Boot Record (MBR) > into memory. The memory location is an absolute physical address of > 0x07C000, which is one 512-byte sector below the 1st 32K memory > boundary. I think, but cannot confirm, that this memory location is > for historical reasons only. 0:0x7c00 (one zero too much and you have to prefix it with segment in real mode) > > The BIOS passes the disk drive being booted via the DL register. > This value would normally be 0x80 for the first hard drive and is > equivalent to GRUB's (hd0), but grub-setup may over-ride it and set it > to 0x80. Some buggy BIOSes pass wrong %dl > > The MBR code is generated from GRUB's /boot/i386/pc/boot.S source > code. This is installed by grub-setup (grub-setup.c), but copies any > BIOS Parameter Block (BPB) and Partition Table from the existing MBR > code before overwriting the sector. > Correct > The MBR functions by reading exactly one sector using the BIOS INT > 13h, function 042h, from the second physical disk sector (address 1) > on the boot disk to memory location 0x70000. Then the memory at > 0x70000 is copied to 0x80000 and the code at 0x80000 is then executed. > 42h =3D LBA. boot sector usually uses LBA but can fallback to CHS. Addresses are wrong. > ---------------------- > > Second stage: core.img > > For historical reasons, disk partitions on the pc are considered to > be aligned on track boundaries where the number of sectors per track > is 63. The first partition is at track 1 reserving track 0 for the > boot process. The MBR is sector 0 and sectors 1 to 62 can then be > used for other boot code like core.img. Therefore the maximum size of > core.img is 31744 bytes (31K). The core.img is binary code partially > compressed with the LZMA algorithm. Correct > > core.img is created by grub-mkimage (usually via grub-install) from > kernel.img and other system specific parameters. Modules, not parameters > The default i386 built-in modules and dependencies are: > biosdisk.mod > ata.mod (pci.mod, scsi.mod) Either of them, never 2 together > file system : determined by grub-probe (e.g. ext2.mod, fshelp.mod)= > partition type: determined by grub-probe( e.g. part_msdos.mod) > Sometimes also lvm and/or raid. > core.img is installed into the first logical track (sectors 1 to 63) > of the disk drive by grub-setup. > Or on BIOS Boot Paratition on GPT. Or *sigh* blocklists for backward-compatibility (blocklists are unreliable) > The first sector of pc core.img is generated from the > boot/i386/pc/diskboot.S file. Note: There appears to be a comment > error in this file. It says it starts at location 0x02000, but boot.S > and conf/i386-pc.rmk indicates it is at 0x80000. > It's on 0:0x8200 > After the first sector of core.image is loaded by the MBR, it loads > the rest of itself into memory using BIOS INT 13h calls. At a > relatively early point, the code transitions from the CPU's real mode > to protected mode to effectively remove memory limits,=20 Enables gate A20 too > loads default modules from the boot drive,=20 First it loads embeded modules, and only then proceeds to load normal.mod and its dependencies > reads the GRUB configuration file and proceeds according to the > instructions there or from the command line. > > The final task then is to load the kernel image or the next > chainloader disk sector and transfer execution to that code. At that > point GRUB considers the boot process complete. > > > > > > > > > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel > --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------enig36EBA2718B4B79D94E1773CA Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iF4EAREKAAYFAksusd4ACgkQNak7dOguQglo7AD9HSP0IMw8o1V6f54TQDQJnlGz NbJjXSGsmEjbDtQIAMwA/Reigf+P4bAWtFNJwsMP8iU9p8yKR2IzQ9TnV47Y37CX =9OXm -----END PGP SIGNATURE----- --------------enig36EBA2718B4B79D94E1773CA--