From Gentoo Wiki
Jump to: navigation, search

This page is about using Gentoo as a PXE server to boot just about any operating system or bootable tool. Please extend it with your own experience. The primary focus is to boot live images and the page can get renamed once we have a better name for it.


The article about Diskless nodes contains plenty of useful information on how to setup a PXE environment.


For client configuration, see for example: Setup PXE boot with EFI Using Grub2 from openSUSE kiwi



TFTP servers

So far I have best experience with net-ftp/tftp-hpa.

root #emerge --ask net-ftp/tftp-hpa

To run it temporarily, you can use the following command line.

root #in.tftpd -L --secure /tftproot

Bootable images

Gentoo installation


Fedora installation

The following script creates a TFTP directory tree, downloads kernel and initrd images from a Fedora mirror and configures a netbootable instance of GRUB.

FILE ~/bin/fedora-pxe-install
#!/bin/bash -xe

# Mirror URL
# Releases
[ $# -eq 0 ] && releases="22 21/Server 21-Alpha/Workstation 20/Fedora" || releases="$*"
# Architecture: x86 | x86_64 | ...
architectures="x86_64 i386"
# TFTP directory path

test -n "$prefix"

menuentry() { cat << EOF
menuentry "Install Fedora $release $arch ($state)" {
    linux /boot/$kernel repo=$repo
    initrd /boot/$initrd

check() {

    curl --silent --fail --head "$repo/" >/dev/null

download() {
    test -e "$1" && { echo "Skipping: $1" >&2; return 0; }
    echo "Downloading: $1 from $2" >&2
    curl --silent --fail --output "$1" "$2"

grub2-mknetdir --net-directory "$prefix"
for release in $releases; do
    for arch in $architectures; do
        check releases || check development || check releases/test || { echo "# Check failed for $release $arch"; break; }

        kernel="fedora-$(echo "$release" | tr / -)-$arch-kernel"
        initrd="fedora-$(echo "$release" | tr / -)-$arch-initrd"

        download "$prefix/boot/$kernel" "$pxerepo/vmlinuz" || { echo "# Couldn't download kernel for $release $arch"; break; }
        download "$prefix/boot/$initrd" "$pxerepo/initrd.img" || { echo "# Couldn't download initrd for $release $arch"; break; }
done | tee "$prefix/boot/grub/grub.cfg"

Adjust it to your needs and then run it without parameters.

root #fedora-pxe-install

Now you just need to configure TFTP and DHCP so that /tftproot is available to the netbooted machine and it that it requests /boot/grub/i386-pc/core.0 via TFTP.

Ubuntu installation

To install Ubuntu to a device via PXE, simply download an Ubuntu netboot image for the appropriate architecture. Note that most of the files in the release and architecture-specific directory are unnecessary, you simply need netboot.tar.gz (about 40MB).

Extract that file to an appropriate TFTP-served directory and configure your DHCP server with the filename directive to point at pxelinux.0 for the machine or subnet in question.

Note that you will also need to give the host(s) internet access as the netboot images are configured to pull packages down from the internet.