Page 1 of 2

Best Way To Boot

Posted: Fri Dec 19, 2008 1:49 pm
by Dhaann
Hello everybody,
I'm making an OS and searched the internet for tuts etc. Many pages are about the bootloader and at each site they do it different. Now, my question is wich bootloader is the fastest?
Some sites I found:
http://www.osdever.net/
http://www.mohanraj.info/josh3.jsp
en.wikipedia.org/wiki/Booting

And maybe some people just know the best way to boot..

Re: Best Way To Boot

Posted: Fri Dec 19, 2008 2:03 pm
by Pasha
Do you really need a bootloader? couldn't that just be built into the kernel? just wondering. I am in about the same situation.

Re: Best Way To Boot

Posted: Fri Dec 19, 2008 3:05 pm
by 01000101
you need a bootloader.

Most people use GRUB as their bootloader (as it is quite advanced and widely used/tested), and other code their own.

If you have no specific needs that GRUB doesn't satisfy, then code your own, or if you just want the challenge and knowledge gained from coding the raw boot-up code, then make your own.

Re: Best Way To Boot

Posted: Fri Dec 19, 2008 3:16 pm
by Dhaann
Pasha wrote:Do you really need a bootloader? couldn't that just be built into the kernel? just wondering. I am in about the same situation.
No, I've already try that, but it doesn't work. You have to write the bootloader (exactly 512 bytes) to the first section of a floppy (for example).

When I boot boot from my floppy, the kernel will be load but I just wonder what the fastest way to boot is?

Re: Best Way To Boot

Posted: Fri Dec 19, 2008 3:29 pm
by JackScott
The fastest way, by far, is to not use a floppy at all. Loading off pretty much any other medium (inc. PXE network booting) will be faster.

<$0.02>
I'm of the opinion that the best thing to do would be to just use GRUB to load your kernel. You can set it to boot off pretty much any boot medium, and use any widely-supported filesystem. In addition, your kernel can be a simple ELF-formatted binary, which makes the compile step a bit simpler. GRUB does add a lot of overhead (almost 300kb of code you'll only be using for a few seconds), but in my opinion the flexibility it gives you is worth it. That is, unless you're writing an operating system simply as a learning exercise. Then sticking to writing your own and using a floppy would be the go.
</$0.02>

Re: Best Way To Boot

Posted: Sat Dec 20, 2008 12:20 am
by Steve the Pirate
I'd say that GRUB is the best option - For normal testing, I run my OS off a CD image running Grub (using the El Torito method, which is far better than floppy emulation, and dead easy with mkisofs), and then for real world testing, I just have an entry in my hard drive's GRUB menu so I can restart and run my OS.

Re: Best Way To Boot

Posted: Sat Dec 20, 2008 10:34 am
by Dhaann
I've in my kernel the shell included and my question about that: if I make an apart file (shell.bin) for the shell and (if needed) load it from my kernel, will the kernel load faster? And I've downloaded GRUB and search for some tutorials, but I don't really get it...

Re: Best Way To Boot

Posted: Sat Dec 20, 2008 11:05 am
by Troy Martin
Not really, since the shell needs access to the kernel functions and will probably be a bit larger as a separate binary than it would if it were in the kernel. And you'd have to have both a floppy or HD and a filesystem driver.

Re: Best Way To Boot

Posted: Sat Dec 20, 2008 11:45 am
by neon
will the kernel load faster?
Are you asking about speeding up the kernels own initialization/loading routines or the loading of the kernel itself? If the former, it would slow it down. If the latter, maybe as the kernel binary would be smaller (It depends on how the kernel boots).

Also, you should not look for the "best" way to do things as there are not any. Every "best" solution has trade offs of their own that may be beneficial for some design goals. Thus, there is no such thing as the "best way to boot".
Dhaann wrote:
Pasha wrote:Do you really need a bootloader? couldn't that just be built into the kernel? just wondering. I am in about the same situation.
No, I've already try that, but it doesn't work. You have to write the bootloader (exactly 512 bytes) to the first section of a floppy (for example).
You *can* if the kernel binary is copied to sector 0 on disk and can properly load the rest of itself depending on how it is booted. This is quite hackish though imho and not recommended. (It would basically be a bootloader and kernel in one image).

Re: Best Way To Boot

Posted: Sat Dec 20, 2008 2:12 pm
by Troy Martin
neon wrote:This is quite hackish though imho and not recommended.
But that always makes it fun!

Re: Best Way To Boot

Posted: Sat Dec 20, 2008 3:37 pm
by neon
Troy Martin wrote:But that always makes it fun!
True ;) I guess if you are just developing your system for fun then it doesn't really matter.

Re: Best Way To Boot

Posted: Sat Dec 20, 2008 10:21 pm
by Brendan
Hi,

Some random notes...

If you use GRUB for your boot code, then your boot code will never be better (or worse) than any other OS that uses GRUB.

IMHO building the boot loader into the same binary as the kernel is a bad idea - the OS should be at least a little bit modular (so that the same kernel can be used with any boot loader, without recompiling the kernel).

The fastest way to boot is to boot from ROM (but it's extremely complex and motherboard specific). The second fastest way to boot is probably to boot from hard drive. Booting from PXE/network is probably the second slowest way to boot, because it typically takes a few extra seconds to for the ROM code to find DHCP settings, etc. Booting from floppy is the slowest way (but it's also the easiest way, with the most examples/tutorials).

For an OS developer, the time taken to install and then boot is much more important than the time taken for booting alone. For installing the OS and then booting, booting from PXE/network is the fastest way because you can "install" the OS for hundreds of computers just by changing some files in the server's TFTP directory. If you had to go around with a floppy or CD-ROM and install the OS on every computer's hard drive before you boot each computer from hard drive, then booting from hard drive would be slower than booting from CD-ROM or floppy...
Dhaann wrote:I've in my kernel the shell included and my question about that: if I make an apart file (shell.bin) for the shell and (if needed) load it from my kernel, will the kernel load faster? And I've downloaded GRUB and search for some tutorials, but I don't really get it...
If your boot loader loads "shell.bin" then the time it takes to load will be added to the time it takes to boot. If the kernel loads "shell.bin", then maybe the kernel can do other things while "shell.bin" is being loaded (e.g. initializing other devices, getting network/DHCP settings, mounting other file systems, etc) and maybe the time it takes to load "shell.bin" won't effect the time it takes to boot at all. This depends on your kernel/OS design though - some well known OSs aren't very good at doing anything in parallel during boot...


Cheers,

Brendan

Re: Best Way To Boot

Posted: Mon Dec 22, 2008 7:02 am
by Dhaann
I will use grub and look for some tutorials.

@Brendan: If the user starts the OS, he/she not always use the shell. So IF NEEDED the shell will be loaded and not every time you start up.

Re: Best Way To Boot

Posted: Mon Dec 22, 2008 2:50 pm
by Love4Boobies
Pasha wrote:Do you really need a bootloader? couldn't that just be built into the kernel? just wondering. I am in about the same situation.
Well it depends on the complexity of your OS. Just for kicks, check out AtomicOS.

Re: Best Way To Boot

Posted: Tue Dec 23, 2008 1:53 pm
by Troy Martin
Love4: Bad idea (TM). No good docs, the "file system" described is just loading sectors, hard to use, etc. AtomicOS sucks.