PXE boot

Kjetil Thuen Kjetil.Thuen at broadpark.no
Mon Dec 4 18:58:39 UTC 2006


man, 04,.12.2006 kl. 12.23 +0100, skrev Bjørn Ingmar Berg:

> Thanks for the input regarding the DHCP part of this!
> Unfortunately the core of the matter stands untouched...
> 
> How do I convert a bootable CD (or bootable floppy for that matter)
> into a bootable image that can be used with PXE?

Having run a pxe  booted, ubuntu based mp3 jukebox for a while, I
thought I could provide some input on this.

There are four components involved:

* The DHCP server
* pxe boot-image
* The tftp server
* The NFS server

The DHCP servers task is to tell any asking clients that a boot image is
offered. I use the dhcp server from ubuntus dhcp package, and the
relevant configuration lines in /etc/dhcpd.conf are these:


allow booting;
allow bootp;
option root-path                "10.0.0.2:/opt/wmusroot";
        host wmus {
                hardware ethernet       00:40:63:c0:d1:ac;
                filename                "pxelinux.0";
        }

wmus is the name of my mp3jukebox. 10.0.0.2:/opt/wmusroot is the NFS
path to the exported root filesystem. More on this later. pxelinux.0 is
the filename of the pxe boot image we offer. I installed the syslinux
package and copied the included /usr/lib/syslinux/pxelinux.0
to /tftpboot/

Next I installed the atftpd package. This provides a tftpserver that can
serve the needed files for the boot process. I cannot remember know if
this happened automatically at boot, but my /etc/inetd.conf contains the
following line:

tftp            dgram   udp     wait
nobody /usr/sbin/tcpd /usr/sbin/in.tftpd --tftpd-timeout 300
--retry-timeout 5     --mcast-port 1758 --mcast-addr 239.239.239.0-255
--mcast-ttl 1 --maxthread 100 --verbose=5  /tftpboot

At this point I had a system that fetched and ran the pxelinux boot
image. The next step is to tell it about where to get a kernel and
initrd image. To do this I made a file /tftboot/pxelinux.cfg/default
that looks like this:

prompt 0
  label linux
        kernel vmlinuz
  append root=/dev/nfs initrd=/initrd.img nfsroot=10.0.0.2:/opt/wmusroot
ip=dhcp panic=10 acpi=off quiet splash

This is equivalent to the grub config. pxelinux will try to fetch the
kernel and initrd image from the tftp server. The nfsroot argument to
the kernel again points to the nfs root directory that we saw in the
dhcpd config.

The files /tftpboot/vmlinuz and /tftboot/initrd.img are both symlinks to
the nfsroot. That way I can install new kernels on the jukebox and have
the tftp server automatically serve the right one. If you prefer, you
can just copy a kernel and initrd.img into the /tftpboot dir.

Now, I have a box that will get a pxe image, run it, then load the
initrd image and then the kernel. At this point it will stop, since I
have no NFS share yet.

The NFS share is set up by adding the line
/opt/wmusroot
10.0.0.0/255.255.255.0(rw,no_root_squash,sync)
to /etc/exports and making sure the NFS server is running.

This is where our situations start to differ. I do not boot a livecd
image, but a minimal ubuntu installation that I got from thoughtpolice's
ubuntu server vmware image(http://www.thoughtpolice.co.uk/vmware/). I
just downloaded the image, booted it in vmware, made a tarball from the
entire filesystem and scp'ed it out to the host os. I then untared the
tarball into /opt/wmusroot, and I had a working minimal ubuntu that I
could install my needed software into.

However, I did try to boot a livecd image for the sake of this mail.
What I found after moving away my existing /opt/wmusroot and then
mounting the cd to /opt/wmusroot (and fixing the symlinks mentioned
above), was that it will indeed boot, but it will not get far since the
configuration on the cd wants to use stuff from the cd, and the cd is
not present. To make this work I guess you would need to tweak either
the initramfs image or the casper config on the cd. Both are possible if
you copy the files from the cd into the NFS root dir instead of just
mounting the cd there. TIP: The initrd file is just a gzipped cpio
archive. 

This is what I had to do to make the vmware image pxe friendly. First i
edited /etc/fstab to read

10.0.0.2:/opt/wmusroot/                  /              nfs
rw              0       0
proc                                     /proc          proc
defaults        0       0

And then I changed the BOOT parameter in initramfs-tools/initramfs.conf
to read BOOT=nfs. I then did a sudo dpkg-reconfigure
linux-image-2.6.17-10-generic to generate a new initrd image that was
configured to use NFS. If my memory serves me that was all I had to do
(apart from struggling with the framebuffer for a couple of days, but
that is another story).

If what you need is a basic Ubuntu desktop and not the install
possibilities that the livecd gives you, I would be happy to send you a
tarball of my NFS root (sans passwords and such :)). 

If you need to use the actual livecd, I hope that this information will
help you get there. 


-- 
Kjetil Thuen <Kjetil.Thuen at broadpark.no>






More information about the ubuntu-users mailing list