Difference between revisions of "Archiso as pxe server"

From ArchWiki
Jump to: navigation, search
(HTTP and NFS (from testbuilds 2011.12.01 and newer))
(Inside an installation)
Line 22: Line 22:
=== Inside an installation ===
=== Inside an installation ===
# '' pacman -Sy dnsmasq nbd --needed
# '' pacman -S dnsmasq nbd --needed
# '' wget http://aur.archlinux.org/packages/archiso-pxe-server/archiso-pxe-server.tar.gz
# '' wget http://aur.archlinux.org/packages/archiso-pxe-server/archiso-pxe-server.tar.gz
# '' bsdtar xf archiso-pxe-server.tar.gz
# '' bsdtar xf archiso-pxe-server.tar.gz

Revision as of 17:41, 5 February 2012

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Tango-document-new.pngThis article is a stub.Tango-document-new.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Archiso as pxe server#)

Merge-arrows-2.pngThis article or section is a candidate for merging with Install_Arch_from_network_(via_PXE).Merge-arrows-2.png

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:Archiso as pxe server#)

This small HOWTO will show you how to setup a live environment that can act as server for Arch Linux live media. Once you have done all these steps, Arch Linux live media is able to boot via PXE on your network.

Preparing your environment

There are two kinds of environment that let you host a PXE server for Arch Linux live media: An Arch Linux live environment running from a USB or CD and an already installed Arch Linux environment (though this will potentially work on any Linux distro).

Inside a live environment

  1. boot an Arch Linux live medium generated by archiso via USB or CD
  2. login as root
  3. ip addr add dev eth0
  4. ip route add default via
  5. echo nameserver >> /etc/resolv.conf
  6. wget http://aur.archlinux.org/packages/archiso-pxe-server/archiso-pxe-server.tar.gz
  7. bsdtar xf archiso-pxe-server.tar.gz
  8. cd archiso-pxe-server
  9. chmod +x archiso-pxe-server
  10. ./archiso-pxe-server (by default will get ip from eth0 and use the bootdevice)

Inside an installation

  1. pacman -S dnsmasq nbd --needed
  2. wget http://aur.archlinux.org/packages/archiso-pxe-server/archiso-pxe-server.tar.gz
  3. bsdtar xf archiso-pxe-server.tar.gz
  4. cd archiso-pxe-server
  5. chmod +x archiso-pxe-server
  6. ./archiso-pxe-server -s archlinux-2011.08.19-core-i686.iso
Note: Please report any trouble in the discussion page!

What is doing in the script?

archiso-pxe-server script setups a directory structure from iso image that looks like this:

└── syslinux
    ├── arch
    │   └── boot
    │       ├── i686
    │       │   ├── archiso.img
    │       │   └── vmlinuz
    │       ├── memtest
    │       └── memtest.COPYING
    ├── hdt
    │   ├── modalias.gz
    │   └── pciids.gz
    ├── pxelinux.cfg
    │   └── default
    ├── memdisk
    ├── splash.png
    ├── syslinux.cfg
    ├── *.0
    ├── *.com
    └── *.c32

Uncomments all "IPAPPEND 3" option in syslinux/*.cfg then copy syslinux.cfg as pxelinux.cfg/default

So pxelinux.cfg/default looks like this (only relevant section)

LABEL arch
Boot the Arch Linux live medium. It allows you to install Arch Linux or
perform system maintenance.
MENU LABEL Boot Arch Linux
LINUX /arch/boot/i686/vmlinuz
INITRD /arch/boot/i686/archiso.img
APPEND archisobasedir=arch archisolabel=ARCH_201108
# Next line should be uncommented when prepare enviroment to boot from PXE.

Setup a file for nbd-server ( /tmp/archiso-pxe-server/nbd-server.conf )

    readonly = true
    exportname = /home/archlinux/iso/archlinux-2011.08.19-netinstall-i686.iso

Run a NBD server.

nbd-server -C /tmp/archiso-pxe-server/nbd-server.conf

Run a TFTP and DHCD servers

dnsmasq --port=0 --enable-tftp --tftp-root=/tmp/archiso-pxe-server --dhcp-boot=syslinux/pxelinux.0, --dhcp-range=,,86400

HTTP and NFS (from testbuilds 2011.12.01 and newer)

Due recent changes in archiso, is now posible to boot from HTTP (archiso_pxe_http initcpio hook) or NFS (archiso_pxe_nfs initcpio hook). Also some changes was made in syslinux configs files from configs/releng, that enable mounted media acts directly as "pxeroot", nothing change is needed, only if you want to customize for particular purpose.

First mount .iso in some place.

Note: Inside live-enviroment skip this step, .iso in mounted on /run/archiso/bootmnt when copytoram is not used.
# mkdir -p /run/archiso/bootmnt
# mount -o ro archlinux-2011.12.02-netinstall-dual.iso /run/archiso/bootmnt
  • Setup DHCP and TFTP servers
Note: Last slash is important
# dnsmasq --port=0 \
          --enable-tftp \
          --tftp-root=/run/archiso/bootmnt \
          --dhcp-range=,,86400 \
          --dhcp-boot=/arch/boot/syslinux/gpxelinux.0 \
          --dhcp-option-force=209,boot/syslinux/archiso.cfg \
  • Setup a DHCP server only for HTTP
Note: This can be used only from PXE roms that undertands HTTP and DNS (if domain-name is used instead of IP address). Alternativelly you can use gPXE (it just takes fews KiBs): ROM-o-matic.net dynamically generates gPXE images. Should considere that gPXE is not activelly maintained, iPXE is the active fork, but there is no online generator
Note: Last slash is important
# dnsmasq --port=0 \
          --dhcp-range=,,86400 \
          --dhcp-boot= \
          --dhcp-option-force=209,boot/syslinux/archiso.cfg \
  • Setup gPXE/iPXE only
Note: For example if you are currently using a DHCP from your internet router

Go to ROM-o-matic.net dynamically generates gPXE images, select customize, and write this script as "Embedded Script"

set 209:string boot/syslinux/archiso.cfg
set 210:string
chain ${210:string}boot/syslinux/gpxelinux.0

Must download iPXE

set 209:string boot/syslinux/archiso.cfg
set 210:string
chain ${210:string}boot/syslinux/gpxelinux.0

  • Setup HTTP server

Setup any HTTP server that you want, just point the root to /mnt/iso. For example using darkhttpd:

# darkhttpd /run/archiso/bootmnt
  • Setup NFS server

Add an entry like this to /etc/exports

/run/archiso/bootmnt 192.168.0.*(ro,no_subtree_check,no_root_squash)

Then start NFS server

rc.d start rpcbind nfs-common nfs-server
  • Setup NBD server

Create a file /tmp/nbd-server.conf

    readonly = true
    exportname = /dev/disk/by-label/ARCH_201112

Then start NBD server

nbd-server -C /tmp/nbd-server.conf

See also