PXE boot: Difference between revisions

From Alpine Linux
(Created page with "Alpine can be PXE booted starting with Alpine 2.6-rc2. In order to accomplish this you must complete the following steps: * Set up a DHCP server and configure it to support P...")
 
No edit summary
Line 1: Line 1:
'''This functionality is still largely prototypal. Some things are still broken (e.g. modloop).'''
Alpine can be PXE booted starting with Alpine 2.6-rc2. In order to accomplish this you must complete the following steps:
Alpine can be PXE booted starting with Alpine 2.6-rc2. In order to accomplish this you must complete the following steps:



Revision as of 03:38, 3 May 2013

This functionality is still largely prototypal. Some things are still broken (e.g. modloop).

Alpine can be PXE booted starting with Alpine 2.6-rc2. In order to accomplish this you must complete the following steps:

  • Set up a DHCP server and configure it to support PXE boot.
  • Set up a TFTP server to serve the PXE bootloader.
  • Set up an HTTP server to serve the rest of the boot files.
  • Set up an NFS server from which Alpine can load kernel modules.
  • Configure mkinitfs to generate a PXE-bootable initrd.

This article describes a setup using gpxe as a PXE bootloader, but you could also use PXELINUX.

Standard setup of all involved services is not covered here; advice on setting up basic DHCP/TFTP/HTTP/NFS/etc. is widely available.

Set up a DHCP server and configure it to support PXE boot

If you use the ISC DHCP server (package "dhcp"), amend your subnet block like so:

 next-server 10.0.0.1;
 filename "gpxe.kpxe";

Set up a TFTP server to serve the PXE bootloader

Install a TFTP server (package "tftp-hpa"). You will need to place a gPXE image at /var/tftproot/gpxe.kpxe. You can generate an image online at ROM-o-matic.net. Select the ".kpxe" output format and the "undionly" driver. You will need to specify a custom boot script. Select "Customize". The following boot script works well:

 dhcp net0
 chain http://${net0/next-server}/gpxe-script

You can include ${net0/mac} and ${uuid} in the URL for the interface MAC address and machine UUID respectively.

Note that as of writing, ROM-o-matic appears to produce a buggy image unless it is used with the "undionly" driver. If you require a different driver, consider building gPXE yourself, especially if you experience inexplicable connectivity issues. Common symptoms are a seemingly correctly configured, randomly functional network connection which appears to suffer from extreme packet loss.

Set up an HTTP server to serve the rest of the PXE boot files

Suppose you have an HTTP server configured to serve from /srv/http. Place an appropriate gPXE script, such as the following, at /srv/http/prov/gpxe-script:

 #!gpxe
 kernel http://${net0/next-server}/prov/grsec ip=dhcp alpine_dev=nfs:${net0/next-server}:/srv/nfs/depot alpine_repo=http://nl.alpinelinux.org/alpine/v2.5/main/x86_64/
 initrd http://${net0/next-server}/prov/pxerd
 boot

ip=dhcp instructs the initrd to obtain an IP via DHCP. The NFS share specified by alpine_dev will be mounted. alpine_repo specifies an apk repository to use.

Set up an NFS server from which Alpine can load kernel modules

Set up an NFS share at /srv/nfs/depot and export it via /etc/exports:

 /srv/nfs/depot  *(ro,no_root_squash,no_subtree_check)

This export does not currently need to contain anything, unless you wish to use it to serve apks, in which case ensure that a file ".boot_repository" is created in the directory containing architecture subdirectories and remove alpine_repo from the kernel arguments. The repository will be autodetected by searching for ".boot_repository". Eventually Alpine will be able to load kernel modules from this export.

Configure mkinitfs to generate a PXE-bootable initrd

You need to add drivers for any Ethernet cards with which you might PXE boot to your initrd. To do this, create /etc/mkinitfs/modules.d/ethernet. List any kernel drivers you require for your Ethernet card. If you are using an Intel E1000 card (this is used by VMware and VirtualBox, and so is good for testing), add

 kernel/drivers/net/ethernet/intel/e1000/*.ko

You also must create the following files so that the modules and scripts necessary for DHCP and NFS are inserted into the initrd.

 /etc/mkinitfs/files.d/dhcp, containing:
   /usr/share/udhcpc/default.script
 /etc/mkinitfs/modules.d/dhcp, containing:
   kernel/net/packet/af_packet.ko
 /etc/mkinitfs/modules.d/nfs, containing:
   kernel/fs/nfs/*

Finally edit /etc/mkinitfs/mkinitfs.conf and add features ethernet, dhcp and nfs.

Generate a PXE-capable initrd by running

 mkinitfs -o /srv/http/prov/pxerd

You should now be able to PXE-boot Alpine Linux. This feature is still in development and non-fatal post-initrd boot errors (regarding modloop, etc.) are to be expected.

Specifying an apkovl

If you wish to specify an apkovl, simply add

 apkovl=http://..../file.apkovl.tar.gz

to the kernel arguments. {MAC} and {UUID} in this parameter will be substituted with the MAC address of the boot interface and the machine UUID respectively. If you use these parameters, ensure you place the URL in quotes.

You can also use ovl_dev= if you want to obtain an apkovl from a device. Use either apkovl or ovl_dev, not both.