12 Apr

Boot Arch Linux from PXE whilst directly connected via ethernet cable

I was following the PXE tutorial from ArchWiki (PXE) however I was directly connecting (via ethernet cable) to my target. This added a few complications that I’ve tackled below. I’ve repeated the instructions and made a note where (and WHY!) I have differed from the ArchWiki article.

First off we need to download the latest ISO image from the downloads page.

Mount the image in your current directory:

sudo mkdir -pv /mnt/archiso
sudo mount -o loop,ro archlinux-2017.02.01-dual.iso /mnt/archiso

Go ahead and connect your ethernet cable between you and the target. Remember you will need to use a crossover ethernet cable otherwise the host computer will be unable to communicate with the target.

Note: I didn’t have a cross over cable to hand so I used a Raspberry Pi as the host. The Raspberry Pi’s ethernet port is auto-sensing (auto MDI-X) so a normal cable or cross over cable can be used.

The ArchWiki article recommends you set a static IP address manually like so:

sudo ip link set eth0 up
sudo ip addr add 192.168.0.1/24 dev eth0

However I experienced the target dropping and resetting the ethernet connection when transitioning from the boot menu to the PXE boot option. When the ethernet connection came back up, the interface had lost it’s manually set static IP address.

For this reason I created a systemd-networkd configuration file to set a static IP address on the network interface. (Make sure you disable dhcp and/or set up a static IP address for what ever network manager you are using).

My systemd-networkd configuration file I created was stored in /etc/systemd/network/25-wired.network:

[Match]
Name=eth0

[Network]
Address=192.168.0.1/24

Next as per the ArchWiki article we need to setup a DHCP server and a TFTP server.

We install and configure dnsmasq as per the ArchWiki article’s instructions.

Install dnsmasq:

sudo pacman -S dnsmasq

Configure dnsmasq:

# /etc/dnsmasq.conf
port=0
interface=eth0
bind-interfaces
dhcp-range=192.168.0.50,192.168.0.150,12h
dhcp-boot=/arch/boot/syslinux/lpxelinux.0
dhcp-option-force=209,boot/syslinux/archiso.cfg
dhcp-option-force=210,/arch/
dhcp-option-force=66,192.168.0.1
enable-tftp
tftp-root=/mnt/archiso

Start dnsmasq:

sudo systemctl start dnsmasq.service

Next install darkhttpd as this will be used to serve the root filesystem as in the ArchWiki article:

sudo pacman -S darkttpd

Start darkttpd:

sudo darkhttpd /mnt/archiso

You are now ready to boot the target. Either modify the BIOS options or enter the boot menu so that you can choose a network boot. This is target specific so you will have to find the instructions for your particular target.

If all goes to plan, you will be presented with an Arch Linux branded syslinux menu, asking how you wish to boot. Select the HTTP option. Once the root filesystem has been copied you should end up at a terminal which has been auto logged in as root.

You have now successfully booted into Arch Linux from a PXE image.

Leave a Reply

Your email address will not be published. Required fields are marked *