Hi,
I want to boot a self-compiled Linux kernel (nothing changed yet, still the original downloaded source code). It's not as simple as it seems, I'm quite desperate after days spent on figuring out how.
First of all, following your tutorial on Grub (http://wiki.osdev.org/GRUB), I successfully installed Grub (Legacy, 0.97) on a floppy disc. So I compiled the latest Linux kernel (3.3.5) and copied the generated bzImage to a FAT USB flash drive.
(1st try) It booted, until a certain point where the kernel said that it wants a ext2 file system. Okay, understandable that it doesn't run on FAT.
(2nd try) So I made the flash drive have an ext2 filesystem, copied the bzImage to it and triet to boot. However, Grub was not able to find the file (using "find /bzImage"). When typing "root (hd0,0)" etc. it says "Filesystem type unknown, partition type 0x7". Could be something wrong with the USB flash drive? I tried it with another one and even when I run "grub" in Ubuntu and try to "find" the file, it doesn't find anything.
(3rd try) I thought it might be something wrong with Grub, being unable to read ext2, so I downloaded Grub 1.99, built it and installed it on the USB flash drive successfully. This version finds the file (using the "search" command), but when typing "linux /bzImage root=..." it prints "error: cannot read the Linux header." Is something wrong with the bzImage? Would be very unlikely because it booted on FAT...
Does anyone know a solution to this problem?
Thanks in advance!
Boot Custom Linux Kernel Using Grub
- Griwes
- Member
- Posts: 374
- Joined: Sat Jul 30, 2011 10:07 am
- Libera.chat IRC: Griwes
- Location: Wrocław/Racibórz, Poland
- Contact:
Re: Boot Custom Linux Kernel Using Grub
It's by no means an answer to this question, but have you looked at http://www.linuxfromscratch.org/? It may contain some tips about your problem... or at least serve as a guide.
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
Re: Boot Custom Linux Kernel Using Grub
GRUB2 is an evil evil thing (IMO). As for legacy grub, it needs to have the ext2 stage 1.5 embedded to be able to read ext2 filesystems. I believe thats on the wiki page. If linux can't deal with FAT, are you sure you've enabled the FAT driver in the kernel configuration at compile time? Because it needs the driver for it to be able to read it.
-JL
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
- Lionel
- Member
- Posts: 117
- Joined: Fri Jul 16, 2010 2:16 pm
- Libera.chat IRC: ryanel
- Location: California
Re: Boot Custom Linux Kernel Using Grub
root (hd0,0)?
That doesn't seem right, as that should probably be a internal hd, make sure this is correct.
That doesn't seem right, as that should probably be a internal hd, make sure this is correct.
Re: Boot Custom Linux Kernel Using Grub
@Griwes: Actually I heard about it but never really read it. I will take a look at the specific chapters tomorrow, hoping to find a solution to my problem, otherwise I will have follow the whole guide. But thank you for your recommendation!
@prianha: How should I embed the ext2 stage 1.5 into Grub? Unfortunatetly I was not able to install Grub on the USB flash drive, though following the guide in the wiki. It says "File not found" when trying to find the drive number using "find /boot/grub/stage1" (at the command prompt in Ubuntu) and when I simply type "setup (hd1)" it prints "Cannot mount selected partition".
I also stored the files on the floppy disc and tried to write them to the flash drive that way, there were no errors during the installation but when booting from the flash drive it says "Grub read error" (I used "install (fd0)/boot/stage1 (hd0) d (fd0)/boot/e2fs_stage1_5" and some other things like setup, but none of them worked).
It would be too bad if it was just because I forgot to check FAT at the kernel... I will check that tomorrow. However, it's still strange why it does not work the other ways...
But anyways, thank you as well for your help!
@Lionel: Yes, it should be (hdX,Y) as the BIOS handles it like a hard drive, I think. Please correct me if I'm wrong!
By the way: I'm developing and testing on two different computers, that's why it's sometimes (hd0) and sometimes (hd1).
@prianha: How should I embed the ext2 stage 1.5 into Grub? Unfortunatetly I was not able to install Grub on the USB flash drive, though following the guide in the wiki. It says "File not found" when trying to find the drive number using "find /boot/grub/stage1" (at the command prompt in Ubuntu) and when I simply type "setup (hd1)" it prints "Cannot mount selected partition".
I also stored the files on the floppy disc and tried to write them to the flash drive that way, there were no errors during the installation but when booting from the flash drive it says "Grub read error" (I used "install (fd0)/boot/stage1 (hd0) d (fd0)/boot/e2fs_stage1_5" and some other things like setup, but none of them worked).
It would be too bad if it was just because I forgot to check FAT at the kernel... I will check that tomorrow. However, it's still strange why it does not work the other ways...
But anyways, thank you as well for your help!
@Lionel: Yes, it should be (hdX,Y) as the BIOS handles it like a hard drive, I think. Please correct me if I'm wrong!
By the way: I'm developing and testing on two different computers, that's why it's sometimes (hd0) and sometimes (hd1).
Re: Boot Custom Linux Kernel Using Grub
Uh... please stop trial & error before you hit something vital.
I assume you already have GRUB installed on your system - if you are compiling custom kernels, I assume you are doing so on an existing Linux platform, and virtually every Linux today uses GRUB.
In that case, don't play around with manually installing GRUB stages, especially if you are unsure about the details. It is much easier (and less hazardous) to modify the existing GRUB menu of your main system to include an entry for your custom kernel.
Use that to do the proof-of-concept (is my USB stick formatted correctly, does my custom kernel actually boot?). Delay the installing of GRUB on the stick until after you have read the GRUB manual. In full.
You don't fiddle with MBR's and boot managers if you aren't even sure which drive you're currently operating on...
I assume you already have GRUB installed on your system - if you are compiling custom kernels, I assume you are doing so on an existing Linux platform, and virtually every Linux today uses GRUB.
In that case, don't play around with manually installing GRUB stages, especially if you are unsure about the details. It is much easier (and less hazardous) to modify the existing GRUB menu of your main system to include an entry for your custom kernel.
Use that to do the proof-of-concept (is my USB stick formatted correctly, does my custom kernel actually boot?). Delay the installing of GRUB on the stick until after you have read the GRUB manual. In full.
You don't fiddle with MBR's and boot managers if you aren't even sure which drive you're currently operating on...
Every good solution is obvious once you've found it.
Re: Boot Custom Linux Kernel Using Grub
As I said, I develop on another machine than I test the kernel on. And even the development machine is just a virtual machine just for this purpose, so nothing can break. But that also means that I don't have a Grub installation on the test machine that I could modify. The only thing that I could do is install Linux to it just for Grub, but I just can't figure out why all the other ways don't work...
Re: Boot Custom Linux Kernel Using Grub
They work, alright. If done correctly.
The first thing to do would be to read the GRUB manual. Not our single-purpose how-to, but the actual GRUB documentation by the GRUB project.
The first thing to do would be to read the GRUB manual. Not our single-purpose how-to, but the actual GRUB documentation by the GRUB project.
Every good solution is obvious once you've found it.