Page 1 of 1
Multi-stage bootloader in non-FAT filesystems?
Posted: Mon Jun 01, 2009 11:30 am
by alethiophile
My current bootloader is two-stage and works by having the first stage scan the FAT filesystem for the second stage, load it and jump to it. However, I would like to be able to use non-FAT filesystems in my OS, and I would not like to have to have a FAT partition on whatever disk I boot from. How easy is it to implement a simple filesystem scan for a better filesystem (I'm thinking ext2/3) in a first-stage bootloader? What are my options other than putting the second-stage bootloader in the filesystem?
Re: Multi-stage bootloader in non-FAT filesystems?
Posted: Mon Jun 01, 2009 1:22 pm
by NickJohnson
I'm guessing not that hard - GRUB does it for ext2/3 at least, along with a few other fses, all in one block. It seems that ext2 uses the normal inode ((double | single) indirect) block list for files, and since the stage2 will be relatively small, it probably would only use a direct block list, which would be easy to read. You could even hard-code the position of the stage2 in the filesystem tree into the stage1 when you install it, and then you wouldn't have to do a recursive search.
Edit: and a scan for the correct filesystem would be completely trivial - pretty much all filesystems have some sort of magic number in their first few blocks that identify them.
Re: Multi-stage bootloader in non-FAT filesystems?
Posted: Mon Jun 01, 2009 2:00 pm
by CmpXchg
One way is to write a separate bootloader for every FS you wanna support...
And then have the Setup program choose one depending on the partition the user selects.