https://wiki.archlinux.org/api.php?action=feedcontributions&user=Train+wreck&feedformat=atomArchWiki - User contributions [en]2024-03-29T05:48:52ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Preboot_Execution_Environment&diff=287427Preboot Execution Environment2013-12-09T15:36:06Z<p>Train wreck: Added last sentence about the copytoram option not working with http as per this forum post https://bbs.archlinux.org/viewtopic.php?id=173422</p>
<hr />
<div>[[Category:Getting and installing Arch]]<br />
[[Category:Networking]]<br />
[[Category:Boot process]]<br />
[[es:PXE]]<br />
[[fr:Install PXE]]<br />
[[ru:Install Arch from network via PXE (Русский)]]<br />
{{Article summary start}}<br />
{{Article summary text|Detailed guide to booting official installation media via PXE.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Network Installation Guide}}<br />
{{Article summary end}}<br />
From [[Wikipedia:Preboot Execution Environment]]:<br />
:''The Preboot eXecution Environment (PXE, also known as Pre-Execution Environment; sometimes pronounced "pixie") is an environment to boot computers using a network interface independently of data storage devices (like hard disks) or installed operating systems.''<br />
<br />
In this guide, PXE is used to boot the installation media with an appropriate option-rom that supports PXE on the target.<br />
<br />
== Preparation ==<br />
<br />
Download the latest official install media from [https://www.archlinux.org/download/ here].<br />
<br />
Next mount the image:<br />
<br />
{{bc|1=<br />
# mkdir -p /mnt/archiso<br />
# mount -o loop,ro archlinux-2013.11.01-dual.iso /mnt/archiso}}<br />
<br />
== Server setup ==<br />
<br />
You'll need to setup a DHCP, TFTP, and HTTP server to configure networking, load pxelinux/kernel/initramfs, and finally load the root filesystem (respectively).<br />
<br />
=== Network ===<br />
<br />
Bring up your wired NIC, and assign it an address appropriately.<br />
<br />
{{bc|1=<br />
# ip link set eth0 up<br />
# ip addr add 192.168.0.1/24 dev eth0}}<br />
<br />
=== DHCP + TFTP ===<br />
<br />
You'll need both a DHCP and TFTP server to configure networking on the install target and to facilitate the transfer of files between the PXE server and client; dnsmasq does both, and is extremely easy to set up.<br />
<br />
Install {{pkg|dnsmasq}}:<br />
<br />
{{bc|# pacman -S dnsmasq}}<br />
<br />
Configure {{pkg|dnsmasq}}:<br />
<br />
{{hc|# vim /etc/dnsmasq.conf|2=<br />
port=0<br />
interface=eth0<br />
bind-interfaces<br />
dhcp-range=192.168.0.50,192.168.0.150,12h<br />
dhcp-boot=/arch/boot/syslinux/lpxelinux.0<br />
dhcp-option-force=209,boot/syslinux/archiso.cfg<br />
dhcp-option-force=210,/arch/<br />
enable-tftp<br />
tftp-root=/mnt/archiso}}<br />
<br />
Start {{pkg|dnsmasq}}:<br />
<br />
{{bc|# systemctl start dnsmasq.service}}<br />
<br />
=== HTTP ===<br />
<br />
Thanks to recent changes in [[Archiso|archiso]], it is now possible to boot from HTTP (archiso_pxe_http initcpio hook) or NFS (archiso_pxe_nfs initcpio hook); among all alternatives, darkhttpd is by far the most trivial to setup (and the lightest-weight).<br />
<br />
First, install {{pkg|darkhttpd}}:<br />
<br />
{{bc|# pacman -S darkhttpd}}<br />
<br />
Then start {{pkg|darkhttpd}} using our /mnt/archiso as the document root:<br />
<br />
{{hc|# darkhttpd /mnt/archiso|2=<br />
darkhttpd/1.8, copyright (c) 2003-2011 Emil Mikulic.<br />
listening on: http://0.0.0.0:80/}}<br />
<br />
== Installation ==<br />
<br />
For this portion you'll need to figure out how to tell the client to attempt a PXE boot; in the corner of the screen along with the normal post messages, usually there will be some hint on which key to press to try PXE booting first. On an IBM x3650 ''F12'' brings up a boot menu, the first option of which is ''Network''; on a Dell PE 1950/2950 pressing ''F12'' initiates PXE booting directly.<br />
<br />
=== Boot ===<br />
<br />
Looking at [[Systemd#Journal|journald]] on the PXE server will provide some additional insight to what exactly is going on during the early stages of the PXE boot process:<br />
{{hc|<nowiki># journalctl -u dnsmasq -f</nowiki>|2=<br />
<nowiki><br />
dnsmasq-dhcp[2544]: DHCPDISCOVER(eth1) 00:1a:64:6a:a2:4d <br />
dnsmasq-dhcp[2544]: DHCPOFFER(eth1) 192.168.0.110 00:1a:64:6a:a2:4d <br />
dnsmasq-dhcp[2544]: DHCPREQUEST(eth1) 192.168.0.110 00:1a:64:6a:a2:4d <br />
dnsmasq-dhcp[2544]: DHCPACK(eth1) 192.168.0.110 00:1a:64:6a:a2:4d <br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/pxelinux.0 to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/archiso.cfg to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/whichsys.c32 to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/archiso_pxe_choose.cfg to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/ifcpu64.c32 to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/archiso_pxe_both_inc.cfg to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/archiso_head.cfg to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/archiso_pxe32.cfg to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/archiso_pxe64.cfg to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/archiso_tail.cfg to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/vesamenu.c32 to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/syslinux/splash.png to 192.168.0.110</nowiki>}}<br />
<br />
After you load {{ic|pxelinux.0}} and {{ic|archiso.cfg}} via TFTP, you'll (hopefully) be presented with a [[Syslinux|syslinux]] boot menu with several options, two of which are of potential usefulness to us.<br />
<br />
Select either<br />
<br />
{{bc|Boot Arch Linux (x86_64) (HTTP)}}<br />
<br />
or<br />
<br />
{{bc|Boot Arch Linux (i686) (HTTP)}}<br />
<br />
depending on your CPU architecture. <br />
<br />
Next the kernel and initramfs (appropriate for the architecture you selected) will be transferred, again via TFTP:<br />
<br />
{{bc|1=<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/x86_64/vmlinuz to 192.168.0.110<br />
dnsmasq-tftp[2544]: sent /mnt/archiso/arch/boot/x86_64/archiso.img to 192.168.0.110}}<br />
<br />
If all goes well, you should then see activity on darkhttpd coming from the PXE-target; at this point the kernel would be loaded on the PXE-target, and in init: <br />
<br />
{{bc|1=<br />
1348347586 192.168.0.110 "GET /arch/aitab" 200 678 "" "curl/7.27.0"<br />
1348347587 192.168.0.110 "GET /arch/x86_64/root-image.fs.sfs" 200 107860206 "" "curl/7.27.0"<br />
1348347588 192.168.0.110 "GET /arch/x86_64/usr-lib-modules.fs.sfs" 200 36819181 "" "curl/7.27.0"<br />
1348347588 192.168.0.110 "GET /arch/any/usr-share.fs.sfs" 200 63693037 "" "curl/7.27.0"}}<br />
<br />
After the root filesystem is downloaded via HTTP, you'll eventually end up at a root zsh prompt with that fancy [https://www.archlinux.org/packages/extra/any/grml-zsh-config/ grml config].<br />
<br />
=== Post-boot ===<br />
<br />
Unless you want all traffic to be routed through your PXE server (which won't work anyway unless you [[Simple Stateful Firewall#Setting up a NAT gateway|set it up properly]]), you'll want to kill {{pkg|dnsmasq}} and get a new lease on the install target, as appropriate for your network layout.<br />
<br />
{{bc|# systemctl stop dnsmasq.service}}<br />
<br />
You can also kill {{pkg|darkhttpd}}; the target has already downloaded the root filesystem, so it's no longer needed. While you're at it, you can also unmount the installation image:<br />
<br />
{{bc|# umount /mnt/archiso}}<br />
<br />
At this point you can follow the [[Installation_Guide|official installation guide]].<br />
<br />
== Alternate Methods ==<br />
<br />
As implied in the syslinux menu, there are several other alternatives:<br />
<br />
=== NFS ===<br />
<br />
You will need to set up an [[NFS|NFS server]] with an export at the root of your mounted installation media, which would be {{ic|/mnt/archiso}} if you followed the [[PXE#Preparation|earlier sections]] of this guide. After setting up the server, add the following line to your {{ic|/etc/exports}} file:<br />
<br />
{{hc|/etc/exports|/mnt/archiso 192.168.0.0/24(ro,no_subtree_check)}}<br />
<br />
If the server was already running, re-export the filesystems with {{ic|exportfs -r -a -v}}.<br />
<br />
The default settings in the installer expect to find the NFS at {{ic|/run/archiso/bootmnt}}, so you will need to edit the boot options. To do this, press Tab on the appropriate boot menu choice and edit the {{ic|archiso_nfs_srv}} option accordingly:<br />
<br />
{{bc|1=archiso_nfs_srv=${pxeserver}:/mnt/archiso}}<br />
<br />
Alternatively, you can use {{ic|/run/archiso/bootmnt}} for the entire process.<br />
<br />
After the kernel loads, the Arch bootstrap image will copy the root filesystem via NFS to the booting host. This can take a little while. Once this completes, you should have a running system.<br />
<br />
=== NBD ===<br />
<br />
{{Accuracy|verify}}<br />
{{Expansion}}<br />
<br />
Install {{pkg|nbd}} and configure it:<br />
<br />
{{hc|# vim /etc/nbd-server/config|2=<br />
[generic]<br />
[archiso]<br />
readonly = true<br />
exportname = /srv/archlinux-2013.02.01-dual.iso}}<br />
<br />
=== Low memory ===<br />
<br />
The {{ic|copytoram}} [[mkinitcpio|initramfs]] option can be used to control whether the root filesystem should be copied to ram in its entirety in early-boot.<br />
<br />
It highly recommended to leave this option alone, and should only be disabled if entirely necessary (systems with less than ~256MB physical memory). Append {{ic|<nowiki>copytoram=n</nowiki>}} to your kernel line if you wish to do so. You should be aware that this option currently does not work if using HTTP for the transfer; NFS or NBD must be used.</div>Train wreck