Difference between revisions of "PXE"

From ArchWiki
Jump to: navigation, search
(DHCP + TFTP)
(Preparation)
Line 4: Line 4:
 
== Preparation ==
 
== Preparation ==
  
[[Archiso]] makes it fairly trivial to use the official install media directly to set up PXE booting.
+
[[Archiso]] makes it fairly trivial to use the official install media directly to set up PXE booting and, unlike earlier methods (archboot), does not require any modification and can be used as-is.
  
 
Download the latest official install media from your [[Mirrors|favorite mirror]].
 
Download the latest official install media from your [[Mirrors|favorite mirror]].

Revision as of 04:33, 22 September 2012

Preparation

Archiso makes it fairly trivial to use the official install media directly to set up PXE booting and, unlike earlier methods (archboot), does not require any modification and can be used as-is.

Download the latest official install media from your favorite mirror.

$ wget http://hive.ist.unomaha.edu/archlinux/iso/latest/archlinux-2012.09.07-dual.iso
--2012-09-21 22:06:37--  http://hive.ist.unomaha.edu/archlinux/iso/latest/archlinux-2012.09.07-dual.iso
Resolving hive.ist.unomaha.edu... 2620:d5:0:22bb::dead:beef, 137.48.187.208
Connecting to hive.ist.unomaha.edu|2620:d5:0:22bb::dead:beef|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 411041792 (392M) [application/x-iso9660-image]
Saving to: ‘archlinux-2012.09.07-dual.iso’

100%[====================================================================================>] 411,041,792  109MB/s   in 3.6s   

2012-09-21 22:06:41 (109 MB/s) - ‘archlinux-2012.09.07-dual.iso’ saved [411041792/411041792]

Next mount the image:

# mkdir -p /mnt/archiso
# mount -o loop,ro archlinux-2012.09.07-dual.iso /mnt/archiso

Server setup

Network

Bring up your wired NIC, and assign it an address appropriately.

# ip l s dev eth0 up
# ip a a 192.168.0.1/24 dev eth0

DHCP + TFTP

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.

Configure dnsmasq:

# vim /etc/dnsmasq.conf
dhcp-range=192.168.0.50,192.168.0.150,12h
dhcp-boot=/arch/boot/syslinux/pxelinux.0
enable-tftp
tftp-root=/mnt/archiso
dhcp-option-force=209,boot/syslinux/archiso.cfg
dhcp-option-force=210,/arch/

Start dnsmasq:

# systemctl start dnsmasq.service

For those still using sysvinit:

# rc.d start dnsmasq

HTTP

Due recent changes in 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).

First, install darkhttpd:

# pacman -S darkhttpd
resolving dependencies...
looking for inter-conflicts...

Targets (1): darkhttpd-1.8-2

Total Download Size:    0.01 MiB
Total Installed Size:   0.04 MiB
Net Upgrade Size:       0.00 MiB

Proceed with installation? [Y/n] 
:: Retrieving packages from community...
 darkhttpd-1.8-2-x86_64    14.8 KiB  82.4M/s 00:00 [#####################] 100%
(1/1) checking package integrity                   [#####################] 100%
(1/1) loading package files                        [#####################] 100%
(1/1) checking for file conflicts                  [#####################] 100%
(1/1) checking available disk space                [#####################] 100%
(1/1) installing darkhttpd                         [#####################] 100%

Then start darkhttpd using our /mnt/archiso as the document root:

# darkhttpd /mnt/archiso
darkhttpd/1.8, copyright (c) 2003-2011 Emil Mikulic.
listening on: http://0.0.0.0:80/

Installation

Boot

After you load pxelinux.0 and archiso.cfg via TFTP, you'll (hopefully) be presented with a syslinux boot menu with several options, two of which are of potential usefulness to us.

Select either

Boot Arch Linux (x86_64) (HTTP)

or

Boot Arch Linux (i686) (HTTP)

Depending on your CPU architecture. If all goes well, you should see some activity on the server from darkhttpd, the root filesystem will be downloaded via HTTP, and you'll end up at a root zsh prompt with that fancy grml config.

Post-boot

Unless you want all traffic to be routed through your PXE server, you'll want to kill dnsmasq and (possibly) get a new lease on the install target, as appropriate for your network layout.

# systemctl stop dnsmasq.service

For sysvinit users:

# rc.d stop dnsmasq

You can also kill darkhttpd; the target has already downloaded the root filesystem, so it's no longer needed.

At this point you can follow the official installation guide.