Serving a live Arch Linux environment with PXE

Posted: November 20, 2012    Author:     Category:  Linux

If you find yourself booting from live CD’s on a regular basis, a PXE server can be very useful and avoid the need for burning ISO’s so you can install a new operating system or recover your system. This post will describe the process of configuring a PXE boot server to serve a live Arch Linux environment over the network. There are plenty of articles on setting up PXE boot servers so I’m going to presume that you already have a PXE boot server set up.

The PXE boot process is relatively simple; the client sends a DHCP request and the DHCP server reponds with an IP for the client and the name of a file to retreive from the TFTP server. This file is retreived by the client and is used to start the boot process. In this case, the file that’s received by the client contains the Arch Linux boot kernel with instructions on where to obtain the root file system.

Arch Linux release a new ISO every month containing the latest updates and changes so I would recommend getting the latest image here: http://www.archlinux.org/download/

Mount the downloaded ISO image with the following command:

mount -o loop archiso.iso /mnt/

In your TFTP boot directory (the directory that contains the pxelinux.0 file) on the PXE boot server, make a new directory called archlinuxlive:

mkdir /srv/tftp/archlinuxlive

Run the following command to create the nescessary directory structure:

mkdir -p /srv/tftp/archlinuxlive/arch/boot/x86_64/

And then copy the boot files from the mounted ISO to this directory:

cp /mnt/arch/boot/x86_64/{archiso.img,vmlinux} /srv/tftp/archlinuxlive/arch/boot/x86_64/

These files contain the Arch Linux boot kernel and the initial ramdisk.

The next step is to make the root filesystem accessible on the network using NFS. The NFS server can be run on any machine on the network as long as the root filesystem is on that machine. On the NFS server, create a directory and copy the contents of the ISO to that directory:

mkdir -p /home/pxeboot/archlinuxlive/
cp -r /mnt/* /home/pxeboot/archlinuxlive/

You can unmount the ISO image now:

umount /mnt/

Now, add the directory to the exports file of the NFS server. Make sure to replace the IP address with the IP address range that matches your network:

echo "/home/pxeroot/archlinuxlive 192.168.1.0/24(ro,no_root_squash,no_subtree_check)" >> /etc/exports

And reload the exports:

exportfs -a

Make sure the NFS server is running and try mounting the NFS share from another machine on the network. If it doesn’t mount the NFS share in the /mnt directory then recheck your NFS servers configuration:

mount NFS_SERVER_IP:/home/pxeroot/archlinuxlive /mnt/

The final part of this guide is to add the Arch Linux PXE boot as an option to your TFTP boot server. Add the following lines to your TFTP configuration file, in my case: /srv/tftp/pxelinux.cfg/default. Make sure you replace the IP address for the NFS server and modify the path if it’s different.

LABEL archlinuxlive
menu label Arch Linux Live 64bit
kernel archlinuxlive/arch/boot/x86_64/vmlinuz
append initrd=archlinuxlive/arch/boot/x86_64/archiso.img archisobasedir=arch archiso_nfs_srv=NFS_SERVER_IP:/home/pxeroot/archlinuxlive ip=:::::eth0:dhcp -

Save the file and restart the TFTP server.

You should now be able to PXE boot a client into a live Arch Linux environment equivalent to booting a system from an Arch Linux ISO.

If you had any problems, please post a comment below and I’ll try to provide some assistance.

 

3 Responses

  1. Having some problems, the arch won’t boot.

    Pxe config:

    LABEL arch
    KERNEL pxemounts/arch/arch/boot/x86_64/vmlinuz
    APPEND initrd=pxemounts/arch/arch/boot/x86_64/archiso.img archisobasedir=arch archiso_nfs_srv=192.168.29.99:/srv/tftp/pxemounts/arch ip=:::::eth0:dhcp –

    Exports:

    /srv/tftp/pxemounts/arch *(ro,sync,no_wdelay,insecure_locks,no_root_squash,insecure)

    Now, kernel and image are loaded ok, but then something happens:
    device did not show up after 30 seconds…

    Do you have an idea what might be wrong?

  2. Hopefully this works out. The archwiki PXE setup with DNSMasq and TFTP and DarkHttp wouldn’t work at all for some reason.

    Also your typos are screwing me up… Please fix

    cp /mnt/arch/boot/x86_64/{archiso.img,vmlinux} /srv/tftp/archlinuxlive/arch/boot/x86_64/
    should be

    cp /mnt/arch/boot/x86_64/{archiso.img,vmlinuz} /srv/tftp/archlinuxlive/arch/boot/x86_64/

    and

    echo “/home/pxeroot/archlinuxlive 192.168.1.0/24(ro,no_root_squash,no_subtree_check)” >> /etc/exports
    should be
    echo “/home/pxeboot/archlinuxlive 192.168.1.0/24(ro,no_root_squash,no_subtree_check)” >> /etc/exports

    for consistency

    Thanks in advance ::crosses fingers this works out::

  3. Thanks for this tutorial! One typo though, on the section that reads

    “cp /mnt/arch/boot/x86_64/{archiso.img,vmlinux}”

    It should be vmlinuz not vmlinux.

    Otherwise it was a great help! Thanks again.

Leave a Reply

Home Linux Serving a live Arch Linux environment with PXE