OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 10:39 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Reliable Custom FS Bootloader solution using GrUB.
PostPosted: Tue Nov 03, 2009 1:48 pm 
Offline
Member
Member
User avatar

Joined: Tue Jun 02, 2009 4:35 pm
Posts: 737
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
I discovered, by a small moment of extreme insight, that it is entirely possible to have a kernel loaded off of any custom filesystem by GrUB no less, via a method which completely invalidates the need to write any form of 512 byte partition bootsector code.

The method is simple: For OSs not using EXT, ReiserFS, or any other FS format recognized by GrUB, simply reserve a number of sectors directly following the first sector of your FS's partition on any drive.

Place your ELF kernel image in this space. Have GrUB load the kernel image from the first N secotrs of the partition. In this manner, any kernel image of any size may be loaded by GrUB off any custom Fs format.

Since GrUB loads the kernel directly off a partition, no bootloader is needed. In other words, the partition bootloader stage is completely bypassed. So no matter what partition your kernel exists on, GrUB can load it, and load it into protected mode no less, as long as GrUB is installed into the MBR.

http://wiki.osdev.org/I_use_a_Custom_Fi ... _for_me%3F

Please see the above link for more information. It may also be wise to add this to the Wiki's FAQ, so as to once and for all cut short the stream of constant bootloader questions. If everyone uses this method, then they get jumped directly into the protected mode kernel stage even on real hardware.

--All the best
gravaera

_________________
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.


Last edited by gravaera on Tue Nov 03, 2009 3:31 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Found the ultimate Bootloader solution using GrUB.
PostPosted: Tue Nov 03, 2009 3:11 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
This just reminded me of a beginner mistake (no offence meant):

The reason to have the kernel stored in the filesystem is for convenience - you don't have static sizes, you don't have to special case to store a kernel, and it's user friendly. And once it works, you can just forget about it. While yes, GRUB can well operate in an unformatted environment but the key feature of GRUB over other bootloaders is that it can also operate in hosted environments.

Why would you think we were all no longer using LILO? :wink:


Nice article, but I would seriously considering labeling it something other than "ultimate solution" 8)

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Found the ultimate Bootloader solution using GrUB.
PostPosted: Tue Nov 03, 2009 3:30 pm 
Offline
Member
Member
User avatar

Joined: Tue Jun 02, 2009 4:35 pm
Posts: 737
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Heh. Point taken. :)

I'll just label it: Flexible GrUB based solution, or something to that effect.

--All the best
gravaera

_________________
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.


Top
 Profile  
 
 Post subject: Re: Reliable Custom FS Bootloader solution using GrUB.
PostPosted: Wed Nov 04, 2009 3:48 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
No offense intended, but of all the ways to boot your kernel using GRUB, this is the least flexible... it expects a kernel of a given size at a given position on the disk (as Combuster said). That's what LILO did, which is why GRUB was so successful getting rid of these limitations...

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
 Post subject: Re: Reliable Custom FS Bootloader solution using GrUB.
PostPosted: Wed Nov 04, 2009 11:10 am 
Offline
Member
Member

Joined: Mon Jan 14, 2008 5:53 am
Posts: 188
Location: Helsinki
s/GrU/GRU/g. Purely aesthetic correction.


Top
 Profile  
 
 Post subject: Re: Reliable Custom FS Bootloader solution using GrUB.
PostPosted: Sat Nov 21, 2009 1:37 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 28, 2009 7:32 pm
Posts: 30
I made some miscellaneous capitalization fixes (mostly s/GrUB/GRUB/g).

My opinion is that this seems like an exceptionally hacky and temporary way to do it.
Better temporary solution: put the kernel and GRUB on a floppy/CD image; load kernel from there but have the kernel load anything else it needs from the correct partition.
Better permanent solution: implement your filesystem in GRUB.

This isn't a good enough solution to justify potentially changing the filesystem spec to allow for reserved sectors at the beginning.

_________________
(Resonance)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group