Best Way To Boot

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Dhaann
Posts: 19
Joined: Fri Dec 19, 2008 1:37 pm

Best Way To Boot

Post 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..
Pasha
Posts: 10
Joined: Fri Dec 19, 2008 10:56 am

Re: Best Way To Boot

Post 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.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Re: Best Way To Boot

Post 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.
Dhaann
Posts: 19
Joined: Fri Dec 19, 2008 1:37 pm

Re: Best Way To Boot

Post 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?
User avatar
JackScott
Member
Member
Posts: 1035
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Re: Best Way To Boot

Post 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>
User avatar
Steve the Pirate
Member
Member
Posts: 152
Joined: Fri Dec 15, 2006 7:01 am
Location: Brisbane, Australia
Contact:

Re: Best Way To Boot

Post 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.
My Site | My Blog
Symmetry - My operating system.
Dhaann
Posts: 19
Joined: Fri Dec 19, 2008 1:37 pm

Re: Best Way To Boot

Post 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...
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Best Way To Boot

Post 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.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Best Way To Boot

Post 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).
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Best Way To Boot

Post by Troy Martin »

neon wrote:This is quite hackish though imho and not recommended.
But that always makes it fun!
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Best Way To Boot

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Best Way To Boot

Post 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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Dhaann
Posts: 19
Joined: Fri Dec 19, 2008 1:37 pm

Re: Best Way To Boot

Post 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.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Best Way To Boot

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Best Way To Boot

Post by Troy Martin »

Love4: Bad idea (TM). No good docs, the "file system" described is just loading sectors, hard to use, etc. AtomicOS sucks.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Post Reply