Booting fakeraid RAID5 Linux, the less half assed way

This will be the final episode of our ongoing installation of Linux on a nVidia MediaShield fakeraid RAID5 array.

By now, you should have a kernel and an initrd.gz image that allow you to boot onto your RAID5 partition, the only last remaining problem being that you need an external non RAID5 disk to do so. That disk could probably be put to better use, so let's remove it from the equation. And no, we're not gonna use an USB stick, CD-ROM or even a floppy, because what we need is a solution always at our fingertips, that we can rely on 24/7, without having to look for a flimsy little device/disc, that we're sure to lose or scratch anyway. Instead, we're going to use something MUCH better.

Re-introducing, the best invention since sliced bread: the fully hacked WRT54G, with supporting cast: PXE!

If by now you don't have a hacked WRT54G in your house, you're an idiot, and if you didn't get a motherboard + ethernet controller that supports PXE, you also need to rethink your life.

You'll find plenty of (seriously confusing) guides on how to use PXE, so I'll just cut down to the chase. What we need here is a PXE executable that can boot our vmlinuz + initrd.gz, as well as relinquish the boot operation to the default disk device, so that we can chose between Vista and Linux.
If you do the groundwork, you'll probably find out that GRUB can be compiled to be run from PXE. The only issue we have here is that the nForce forcedeth network driver is not embedded with GRUB 0.97, and while you can pick one up from gPXE (which is where all the network drivers from GRUB come from anyway), if you want to do things clean, you'll have to recreate the configure/Makefile settings to add the forcedeth, which is a major pain in the ass (or you can simply hijack one of the existing drivers files, and replace it with the forcedeth.c code, but this lazyman's option of choice is not really gratifying).

Instead, we're going to use PXELINUX, a spinoff of the Syslinux project.
Since our WRT router is using DNSMasq, we'll practically follow the instructions from the link above, so if you need more than what I am to present below, feel free to refer to the official documentation.
  1. Create a tftpboot directory on your multipurpose router. For convenience, I am creating mine in /share/tftpboot as the /share directory is already shared using Samba, and this of course gives us great convenience to setup our PXE server files
  2. Copy your vmlinuz and initrd.gz images in this directory
  3. Download and extract the latest syslinux.zip from kernel.org.
  4. Copy the pxelinux.0 from the syslinux.zip core/ directory into your tftpboot dir
  5. Copy menu.c32 from /com32/menu into your tftpboot dir
  6. It's also a nice feature to be able to boot DOS floppy images using PXE as well (eg: Win98 bootdisk, Memtest86+, etc.). To do that, copy memdisk from the memdisk/ directory to your tftpboot dir. Note that memdisk can also handle gzip compressed images, which can help reduce transfer time
  7. Optional: If you want to confirm that memdisk works, or if you simply want to have the Memtest86+ option, you can also download the compressed Memtest86+ v2.10 image that I am providing here. Note that this is the same memtestp.bin that you can download from http://www.memtest.org/ except padded to reach the standard 1.44 MB floppy size. Despite multiple attempts, I haven't yet found how to get memdisk to auto-pad floppy images...
    Oh, and the reason I use Memtest86+ rather than Memtest86 is that the latter didn't seem to handle my 4 GB RAM properly
  8. Create a pxelinux.cfg/ directory in your tftpboot dir
  9. Create a graphics.conf text file there, with the following content:
    menu color tabmsg 37;40      #80ffffff #00000000
    menu color hotsel 30;47 #40000000 #20ffffff
    menu color sel 30;47 #40000000 #20ffffff
    menu color scrollbar 30;47 #40000000 #20ffffff
    menu master passwd yourpassword
    menu width 80
    menu margin 22
    menu passwordmargin 26
    menu rows 6
    menu tabmsgrow 15
    menu cmdlinerow 15
    menu endrow 24
    menu passwordrow 12
    menu timeoutrow 13
    menu vshift 6
    menu passprompt enter password:
    noescape 1
    allowoptions 1
  10. Create a default text file in the pxelinux.cfg directory, and adapt the following content to your needs (NB: By default, this menu will apply to all PXE devices. If you want to target specific MACs, just change the "default" name to the MAC address of your interface (eg: "01-88-99-aa-bb-cc-dd"):
    default menu.c32
    prompt 0

    menu title PXE Boot Menu
    menu include pxelinux.cfg/graphics.conf
    menu autoboot Starting Local System in # seconds

    label bootlocal
    menu label ^Local System
    menu default
    localboot 0
    timeout 35

    label linux
    menu label Slackware 12.2 (RAID5)
    kernel vmlinuz
    append initrd=initrd.gz vga=791 vt.default_utf8=1

    label dos
    menu label DOS (Win98)
    kernel memdisk
    append floppy initrd=win98.gz

    label memtest
    menu label Memtest86+
    kernel memdisk
    append floppy initrd=memtestp.gz
  11. Now, you need to tell your DHCP server that it should handle PXE, and which files it should provide. If you are using DNSMasq, this is as trivial as adding the following lines:
    # PXE Booting
    # This is the file that will be ftpd's accross
    and then restarting the daemon (/etc/init.d/dnsmaq restart)

  12. Finally, you can enable PXE in your PC BIOS, and watch in awe as you can now conveniently boot whatever you want from the network. If it doesn't work, I'd suggest you run a test with memdisk and a bootdisk (eg: memtest), as it shouldn't require much of any configuration to run properly.

No comments:

Post a Comment