Multi-stage bootloader in non-FAT filesystems?
- alethiophile
- Member
- Posts: 90
- Joined: Sat May 30, 2009 10:28 am
Multi-stage bootloader in non-FAT filesystems?
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?
If I had an OS, there would be a link here.
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: Multi-stage bootloader in non-FAT filesystems?
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.
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.
- CmpXchg
- Member
- Posts: 61
- Joined: Mon Apr 28, 2008 12:14 pm
- Location: Petrozavodsk, Russia during school months, Vänersborg Sweden in the summertime
Re: Multi-stage bootloader in non-FAT filesystems?
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.
And then have the Setup program choose one depending on the partition the user selects.
Every Man Must Learn David DeAngelo's Stuff, Period.
http://www.doubleyourdating.com/Catalog
http://www.doubleyourdating.com/Catalog