Monday, June 8, 2009

Thinking About Network Driver for Grub, Part I

GRUB, a bootloader for Linux, doesn't come with network configuration installed. If you want it, you have to compile your own. And when you compile, you have to choose a driver for your hardware. Sounds easy enough, right? Wrong. You have to figure out which hardware you have and find the driver which may not even exist.

How do I know which driver I have? Well, there's probably some easy Linux way to figure it out, but I decided to boot into Windows and use the Control Panel to bring up the Device Manager.

I have 3 Network Adapters. One is wireless and the other two are a "1394 Net Adapter" and "Intel (R) PRO/1000 PL Network Connection". A little googling and I found that 1394 is for Firewire. The Intel connection has a PCI location, so it seems like a physical piece of hardware on my motherboard. So I'm guessing that's it. The computer I want to boot is "Intel (R) PRO/100 VE Network Connection".

Well, there is one, Intel Etherexpress Pro/100 which requires sending "--enable-eepro100" to the makefiles. I'm going to guess that's the one I need. Even if it's old, I'm just doing simple stuff, so it should work.

So back to Ubuntu...

I figured out that I can use .configure with my necessary --enable-xxx options and it will setup my makefiles for me so I can just type 'make'. Or at least that seems to be what it does. I ran make and, of course, it failed. There are 2 variables that are declared as extern in etherboot.h but defined as static (file scope) in main.c. Hmmm.....

I suppose I can just make the static variables unstatic...? Well, it seems I'm not first with this problem. These guys had the same problem and that's their solution: http://www.dietpc.org/build.htm

For a little context, they claimed it was because of gcc 4.x. I guess the compiler considers that an error from 4.0 on. I'm not sure I'd really consider it an error, but I can see the rationale.

Anyway, once that's done, it compiles. It creates a whole pile of images. I'm hoping that the stage2 is the one I want. So, I took an old USB key I have laying around, used gparted to format it as FAT16 and set the lba flag. Then I dd'ed stage1 to lba 0, and stage 2 to lba1+.

Now to shut down my system and see if I can boot from it....

Back. GRUB loaded as evidenced by the fact that the word GRUB appeared in a solid wall of the word GRUB. About 16 GRUBs per line and scrolling fast. So, I'd say, I had moderate success. The BIOS obviously found GRUB and GRUB is obviously doing something--just not what I want it to do. But I'm on a journey of discovery, so this is progress.

A little stumbling block here. I screwed up my USB key. http://marklearnslinux.blogspot.com/2009/06/using-testdisk-and-gparted-to-fix-my.html

I think I got it working now. I used grub-install /dev/sdc instead of dd'ing the stage1 and stage2. I'll reboot and see what happens...

OK, it booted up and said GRUB, but then didn't do anything. I was hoping for the menu or the prompt or something asking for more configuration information. But no.

Then another disaster--it seems I got installed that GRUB to my sda boot sector as well so my Ubuntu boot goes to "GRUB _". Argh! Now I have to boot into the Live CD and try to restore the normal bootloader. Sigh....

Well, I guess I'll post this and continue on a future post.

Nice links:

http://www2.informatik.hu-berlin.de/~draheim/boot/grub-netboot.print.html

http://www.linuxhq.com/ldp/howto/Network-boot-HOWTO/index.html

http://www.sfr-fresh.com/linux/misc/grub-0.97.tar.gz/

http://linuxgazette.net/issue64/kohli.html

No comments:

Post a Comment