PXE boot: Difference between revisions
No edit summary |
(Add guide to boot options) |
||
Line 1: | Line 1: | ||
'''This functionality is still largely prototypal. Some things are still broken (e.g. modloop).''' | '''This functionality is still largely prototypal. Some things are still broken (e.g. modloop).''' | ||
=Guide to options= | |||
; ip | |||
: '''Required for PXE.''' | |||
: Set <code>ip=dhcp</code> to get an IP via DHCP. (Requires af_packet.ko in the initrd, in addition to the modules needed for your NIC.) | |||
: Set <code>ip=<em>client-ip</em>::<em>gateway-ip</em>:<em>netmask</em>::[<em>device</em>]:</code> to specify an IP manually. <code><em>device</em></code> is a device name (e.g. <code>eth0</code>). If one is not specified, one is chosen automatically. | |||
; apkovl | |||
: Valid forms include: | |||
:* An HTTP, HTTPS or FTP URL to an apkovl.tar.gz file which will be retrieved and applied. | |||
:* <code><em>device_name</em>[:<em>fs_type</em>]:<em>path</em></code>, where <code>device_name</code> does not include <code>/dev</code> (e.g., <code>sda</code>). <code>fs_type</code> is optional (e.g. <code>ext4</code>). <code>path</code> expresses the path on the device to the apkovl.tar.gz file. | |||
:* A relative path, interpreted relative to the root of the <code>alpine_dev</code>. | |||
:* If not specified, a file matching <code>*.apkovl.tar.gz</code> is searched for in the root of the <code>ovl_dev</code>. (If more than one exists in the root of a device, all are ignored.) | |||
; alpine_dev | |||
: '''Required.''' | |||
: The <code>alpine_dev</code> specifies a device used for reference data which must reside on a filesystem; currently, this is only the case for kernel modules. | |||
: This is also used to obtain APKs if a repository is not explicitly specified; see below. | |||
: Valid forms include: | |||
:* A device name, not including <code>/dev/</code>. | |||
:* <code>UUID=<em>filesystem-uuid</em></code> | |||
:* <code>LABEL=<em>filesystem-label</em></code> | |||
:* <code>nfs:<em>ip-address</em>:<em>path</em></code>, specifying an NFS export to use as the device. You may need to add modules to the initrd. | |||
; ovl_dev | |||
: Valid forms include: | |||
:* <code><em>device_name</em>[:<em>fs_type</em>]</code> | |||
:* If not specified, various devices are searched for a file matching <code>*.apkovl.tar.gz</code> in the root directory. | |||
: This argument can contain the fields <code>{MAC}</code> and <code>{UUID}</code>, which will be substituted with the MAC address of the NIC used by Alpine and the system's DMI "Product UUID" respectively. If these substitutions are used, the value passed to ovl_dev must be enclosed in quotes. e.g. <code>ovl_dev="<nowiki>http://.../</nowiki>{MAC}.apkovl.tar.gz"</code>. | |||
; alpine_repo | |||
: If set, <code>/etc/apk/repositories</code> will be filled with this. May be an URL. Otherwise, try and find a directory containing the marker file <code>.boot_repository</code> on the <code>alpine_dev</code>. | |||
; modloop | |||
: TODO | |||
=HOWTO= | |||
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 18:24, 19 November 2013
This functionality is still largely prototypal. Some things are still broken (e.g. modloop).
Guide to options
- ip
- Required for PXE.
- Set
ip=dhcp
to get an IP via DHCP. (Requires af_packet.ko in the initrd, in addition to the modules needed for your NIC.) - Set
ip=client-ip::gateway-ip:netmask::[device]:
to specify an IP manually.device
is a device name (e.g.eth0
). If one is not specified, one is chosen automatically.
- apkovl
- Valid forms include:
- An HTTP, HTTPS or FTP URL to an apkovl.tar.gz file which will be retrieved and applied.
device_name[:fs_type]:path
, wheredevice_name
does not include/dev
(e.g.,sda
).fs_type
is optional (e.g.ext4
).path
expresses the path on the device to the apkovl.tar.gz file.- A relative path, interpreted relative to the root of the
alpine_dev
. - If not specified, a file matching
*.apkovl.tar.gz
is searched for in the root of theovl_dev
. (If more than one exists in the root of a device, all are ignored.)
- alpine_dev
- Required.
- The
alpine_dev
specifies a device used for reference data which must reside on a filesystem; currently, this is only the case for kernel modules. - This is also used to obtain APKs if a repository is not explicitly specified; see below.
- Valid forms include:
- A device name, not including
/dev/
. UUID=filesystem-uuid
LABEL=filesystem-label
nfs:ip-address:path
, specifying an NFS export to use as the device. You may need to add modules to the initrd.
- A device name, not including
- ovl_dev
- Valid forms include:
device_name[:fs_type]
- If not specified, various devices are searched for a file matching
*.apkovl.tar.gz
in the root directory.
- This argument can contain the fields
{MAC}
and{UUID}
, which will be substituted with the MAC address of the NIC used by Alpine and the system's DMI "Product UUID" respectively. If these substitutions are used, the value passed to ovl_dev must be enclosed in quotes. e.g.ovl_dev="http://.../{MAC}.apkovl.tar.gz"
. - alpine_repo
- If set,
/etc/apk/repositories
will be filled with this. May be an URL. Otherwise, try and find a directory containing the marker file.boot_repository
on thealpine_dev
.
- modloop
- TODO
HOWTO
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.