Gentoo PXE network install (HOWTO)

This document will show you how to install Gentoo over PXE.
It's an easy way of installing Linux on a server that only has network access.

Index

1. About this document

If you do not have a floppy or cdrom, this HOWTO will help you install Gentoo over your LAN.
We used a MAXTOR NAS 4300 for the experiment.
For the booting itself we used the Gentoo kernel and the initrd on the Gentoo Install CD.
The PXE was done using PXELINUX. We did not use GRUB, although it can be done too.

Authors: Filip Van Damme & Bram De Smet

2. Workflow

Setting up the TFTP server

We used a Gentoo Linux box to set up the TFTP server.

Emerge a tftp server.

Gentoo offers serveral TFTP servers/clients:

  • tftp-hpa
  • atftp
  • netkit-tftp

You can only use tftp-hpa and atftp because they support TSIZE while netkit-tftp does not.
We went for atftp.

# emerge atftp
# mkdir /tftpboot

The tftp server is only to be launched if another server is calling for it, so we are going to add it to our inetd.conf file.
(it could be that you still have to create that file)

inetd.conf:

tftp	dgram	udp	wait	nobody	/usr/sbin/in.tftpd

All we need to do is to (re)start the inetd process.

# /etc/init.d/inetd restart

Prepping for boot

First of all, mount your Gentoo Install CD or the latest ISO image:

# mount /dev/hdc /mnt/cdrom
or
# mount -o loop /path/to/gentoo-ix86.iso /mnt/cdrom

Copy 'kernel' and 'rescue.gz' from /mnt/cdrom/isolinux to the created /tftpboot directory.

As we said, we used PXELINUX to do the boot. The latest tarball can be found here (syslinux-x.xx.tar.gz):

http://www.kernel.org/pub/linux/utils/boot/syslinux

Save and unpack the file in a temporary directory and copy pxelinux.0 to /tftpboot

# cd /tmp
# tar zxvf syslinux-x.xx.tar.gz
# cp syslinux-x.xx/pxelinux.0 /tftpboot

Now we will need to create a PXELINUX config file.

# cd /tftpboot
# mkdir pxelinux.cfg
# cd pxelinux.cfg

Create the file 'default' with following configuration:

LABEL linux

KERNEL kernel

APPEND devfs=nomount vga=normal load_ramdisk=1
prompt_ramdisk=0 ramdisk_size=22000 initrd=rescue.gz
root=/dev/ram0 rw


PROMPT 1


Testing the TFTP server

We will test the TFTP server local.
Ifconfig gave us the ip address of our TFTP server: 10.12.0.10

# cd /tmp
# tftp 10.12.0.10
> get kernel

> quit

If you do a directory listing, you should find the file 'kernel'. You can now delete the file again.

# ls kernel
kernel
# rm kernel

We now have a working TFTP server.

MAC address

First of all we set the BIOS of the machine we want to install to boot from the ethernet card as first device.
When we boot the machine, it will search for a DHCP server.
Don't worry, we only need the displayed MAC address of the card.

DHCP server config

On your DHCP server, make a reservation for the MAC address you just got
We need to do so to allow to PXE boot the server.

Extract from pxelinux.doc:

allow booting;
allow bootp;
option domain-name "<domain name>";
option subnet-mask <subnet mask>;
option broadcast-address <broadcast address>;
option domain-name-servers <dns servers>;
option routers <default router>;
# Group the PXE bootable hosts together
group {
# PXE-specific configuration directives...
next-server <TFTP server address>;
filename "/tftpboot/pxelinux.0";
# You need an entry like this for every host
# unless you're using dynamic addresses
host <hostname> {
hardware ethernet <ethernet address>;
fixed-address <hostname>;
}

Now replace the '<ethernet address>' with the MAC address you got from the server.
Once the DHCP server is configured, we can move on to the big test.

Booting with PXE

We are now going to boot the server.
You will see the server asking an IP address.
Once it has the IP address it will prompt you for boot as shown in the picture.

PXE Boot screen
PXE Boot screen

Enter 'linux' and press return.
Linux will now boot as if it was directly from the Gentoo Install CD.

Gentoo prompt
Gentoo prompt

Now you can just follow the Gentoo Install Manual:

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml

3. More information on SYSLINUX:

SYSLINUX: http://syslinux.zytor.com/


Bookmark this page using following QR code: