Page 1 of 1
booting kernel from bootsector
Posted: Sun Sep 19, 2004 12:50 am
by bradd
Hey guys.. For my floppy boot, I have a bootsector that loads the next stage from my own floppy filesystem.. thats all fine and good.. What I need to know is how to do this with a hard drive.. I mean, I have 512bytes at the start of the HD, but how would I load the next stage?? would I mark the blocks as used and store the starting block in the bootsector? Or would I have to implement my filesystem in the 512bytes??
Re:booting kernel from bootsector
Posted: Mon Sep 20, 2004 12:41 am
by bubach
Thats up to you.
bradd wrote:Or would I have to implement my filesystem in the 512bytes??
No, but enought of it to load a file..
Re:booting kernel from bootsector
Posted: Mon Sep 20, 2004 1:20 am
by Solar
Examples might help.
LILO - the Linux Loader - determines the sector number of the kernel image, and stores that in the boot sector. That way, LILO doesn't have to understand the file system, it just tells the hard drive to load from sector X. This is "one-stage bootloading". The downside is that, whenever you recompile your kernel, you have to re-run LILO (reinstall the MBR) because the sector number of the kernel image changed.
GRUB - the Grand Unified Bootloader - does a similar thing (sector number hardcoded into the MBR), but it doesn't load the kernel but a second GRUB stage, which in turn is "smart" enough to read the file system, load the configuration file, and find any kernel image by actually interpreting the file system. That's "two-stage bootloading", with the advantage that you don't hae to do anything after a kernel recompile.
Re:booting kernel from bootsector
Posted: Mon Sep 20, 2004 11:35 am
by Dreamsmith
DOS provides another example. Like GRUB, it interprets the filesystem and loads the file regardless of it's physical location, but like LILO, it does this in one stage. It can get away with this since the filesystem it reads is simple enough to be interpretted from a 512-byte snatch of code. Some other operating systems have a "boot filesystem" designed to be easy to interpret for that very reason...
Re:booting kernel from bootsector
Posted: Tue Sep 21, 2004 5:01 am
by Pype.Clicker
Dreamsmith wrote:
DOS provides another example.
are you sure of this ? afaik, DOS had some hidden system (thus unmoveable) files like MSDOS.SYS that were implied in the BOOT process ... They were damn looking like a second stage ...
Re:booting kernel from bootsector
Posted: Tue Sep 21, 2004 9:46 am
by Dreamsmith
Sort of/not really. There are actually three files involved in the normal DOS boot process: IO.SYS, MSDOS.SYS, and COMMAND.COM. IO.SYS is the one that is loaded first, and is the one that processes your CONFIG.SYS. Whether MSDOS.SYS is then loaded or not depends on the system (under DOS 7.0+, MSDOS.SYS is just a text file). But in any case, this isn't really a multistage boot process in the same sense as we were discussing above WRT GRUB and LILO. (If it was, then LILO would also have to be considered a multistage booter -- after all, loading the Linux kernel is just the first step, booting proceeds by loading /sbin/init).
Re:booting kernel from bootsector
Posted: Wed Sep 22, 2004 8:48 am
by Pype.Clicker
what i actually meant is that i'm not sure at all that MS-DOS were using the FAT lookup to locate MSDOS.SYS (when it wasn't a text file) but that it instead hard-code its position and length and made it system-file so that it doesn't move.
afaik, in DOS7+ (e.g. win9x), the actual 'MSDOS.SYS' content has been moved to some system location after the boot sector ...
Re:booting kernel from bootsector
Posted: Wed Sep 22, 2004 9:10 am
by aladdin
I think MS-dos uses interpret fat file system since version 3.0 (Kro$oft announced that system file can now be any where in the root dir, and they where very happy), but before that, system files was in contigous region, just after fat, and was stored on a "hidden zone", this zone was protected by medos itself so you can't move them.