User Tools

Site Tools


ding:netboot

Diskless System

Ding does not contain a harddisk for two reasons: a) The one I had broke and b) it is much more silent without one. So how does it work then? The machine is booted entirely from the net with all data stored at my fileserver which is located in another room (You don't want to have something with three harddisks running 24/7 in your living room, don't you?

I try to explain how everything is setup here. First thing you need is a seperate server somewere (running linux of course) and the second thing is a good network card which is able to netboot. I use a 3Com 3C905C-TX-M 10/100Mbit NIC.

Before we start

The client is the diskless machine named ding.my.home using the IP 192.168.1.30 assigned via DHCP. The server serves NFS,TFTP,DHCP and much more (which is irrelevant for now), is called xerxes.my.home and runs at IP 192.168.1.10. Both names are resolvable through the local DNS Server.

When I say boot I mean boot the client - I assume the server is running fine ;-)

Client-Setup

The 3COM 905C-TX Network Interface Card (NIC) comes with a boot-ROM which allows to boot a remote bootimage. It will configure the NICs IP via DHCP and then get the bootimage via TFTP. To enable this press Ctrl-Alt-B when the NIC is initialized - You'll get a setup screen where you have to set the following values:

Boot Method: PXE
Default Boot: Network

For the curious: PXE is short for Pre eXecution Environment. Thats all for the client. Everything from now on will be done on the server (xerxes).

Rootfilesystem

The whole rootfilesystem of the client will be served as a NFS share by the server. Remember: a real rootfilesystem has to contain everything including /usr, /etc,device files, the /proc mountpoint and so on.

I created mine from a backup of the broken harddisk but you can copy any existing rootfilesystem e.g. extract one from a Rescue CD image or even copy the one from the file server. I created it in /tftpboot/192.168.1.30/ - this seems to be a general convention for netboot but you can adjust it to your ideas.

Now you need an NFS server running (#> apt-get install nfs-kernel-server portmap) add an entry in /etc/exports to share it:

/tftpboot/192.168.1.30  ding.my.home(sync,rw,no_root_squash)

The no_root_squash option is important or your client will have no root privileges on it's own filesystem! Now restart NFS. Step one done :-)

TFTP

TFTP is a authenticationless file transfer protocol used to get the bootimage. For PXE we need a slightly enhanced TFP server. Install it with apt-get install tftpd-hpa. It will be started from inetd so adjust /etc/inetd.conf:

tftp    dgram   udp     wait    root    /usr/sbin/in.tftpd in.tftpd -s /tftpboot

The last parameter is the rootdirectory of the TFTP server and by giving the -s option the server will chroot into it. tfpd will use /etc/hosts.[allow|deny] and serves only files which are worldreadable! We will remember that later. Restart inetd after changing the configfile.

#> /etc/init.d/inetd restart

DHCP

To autoconfigure the NIC you need a running DHCP server. Install it with

#> apt-get install dhcp3-server

Now change your /etc/dhcp3/dhcpd.conf:

# option definitions common to all supported networks...
option domain-name "my.home";
option domain-name-servers 192.168.1.10;

option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.10;

default-lease-time 600;
max-lease-time 7200;

#For GRUB net-booting
option grub-config code 150 = text;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

host ding {
  hardware ethernet 00:50:da:09:36:79;
  fixed-address 192.168.1.30;
  filename "/192.168.1.30/boot/pxegrub";
  option grub-config "(nd)/192.168.1.30/boot/menu.lst";
  next-server 192.168.1.10;
}

Most things are for setting up IP, DNS and gateway. Have a look at the host entry for ding. Interesting is the 'filename' option which tells the client which bootimage to load - this is the grub bootloader which will be discussed in the next section, the next-server directive tells the boot client at which server the file is. Another important option is in the global section at the top: the grub-config option is a selfdefined DHCP-Option with the ID 150 to tell grub where to get it's config file - more later.

Be sure to restart DHCP after changing the config:

#> /etc/init.d/dhcpd restart

GRUB

Usually the NIC should fetch a kernel-image and boot it. But the image has to fit into the low memory which is only 640kb. I wasn't able to compile a 2.4.x kernel with less than ~750kb so another solution had to be found. The solution is GRUB - a great bootloader with network support.

Debian comes with a precompiled version but this one has no network support so we compile our own. Get the sources from the GRUB page, untar it and change into the new directory.

GRUB configures itself in two stages: First it executes a compiledin “preset” and then loads the main configfile which is normally located at /boot/grub/menu.lst on the primary partition. But our diskless client don't have a primary partition. The solution is to say GRUB to get the config from the network. This is done by inserting GRUBs “dhcp” command in the preset - so lets create a presetfile:

$> echo "dhcp" >mypreset

Now we can build GRUB with network support by selecting the correct driver and the just created preset. For a list of available network driver see the included netboot/README.netboot file. For my 905C-TX it is the 3c90x driver:

$> ./configure --enable-3c90x --enable-diskless --enable-preset-menu=mypreset
$> make

The build process creates a file named stage2/pxegrub which is the bootimage for the NIC - copy it to the location you configured with the filename option in your DHCP setup and make it worldreadable (remember what I said about TFTP?)

$> cp stage2/pxegrub /tftpboot/192.168.1.30/boot
$> chmod 666 /tftpboot/192.168.1.30/boot/pxegrub

It's half time in our config marathon.

You may try to boot the client a first time at this point. Because we have no kernel and no GRUB config it will not boot your system. But it should configure the NICs IP, download and execute the GRUB image and present a GRUB shell. Got it so far? Lets go on…

Kernel

We need a special kernel to boot with a NFS-only rootfilesystem. You have to build the networkdriver into the kernel (not as module), enable DHCP autoconfiguration and rootfilesystem on NFS:

Networking options  --->
   [*]   IP: kernel level autoconfiguration
   [*]     IP: DHCP support
Network device support  --->
   Ethernet (10 or 100Mbit)  --->
     [*] Ethernet (10 or 100Mbit)
     [*]   3COM cards
     <*>     3c590/3c900 series (592/595/597) "Vortex/Boomerang" support
File systems  --->
   Network File Systems  --->
     <*> NFS file system support
     [*]   Provide NFSv3 client support
     [*]   Root file system on NFS

Configure everything else as usual, compile it and copy the kernel to your desired location (accessable by TFTP)

#> cp arch/i386/boot/bzImage /tftpboot/192.168.1.30/boot/kernel-2.4.17a

Some final configs

Create a GRUB config in /tftpboot/192.168.1.30/boot/menu.lst (or whatever you said in your DHCP config) with a kernel entry like this:

title Kernel 2.4.24
root (nd)
kernel /boot/kernel-2.4.24a ip=dhcp root=/dev/nfs nfsroot=192.168.1.30:/tftpboot/192.168.1.30

(nd) tells GRUB to use TFTP to fetch the image and the various kernel parameter will configure the rootfilesystem on NFS.

Be sure to change some settings in your rootfilesystem:

  • Disable all network-configuration (/tftpboot/192.168.1.30/etc/network/interfaces) -this is done automatically on kernel level.
  • Add your rootfilesystem to /tftpboot/192.168.1.30/etc/fstab:
192.168.1.10:/tftpboot/192.168.1.30  /   nfs   defaults  0  0

Thats it - Now boot and pray :-)

ding/netboot.txt · Last modified: 2008/06/04 19:40 by ach