PXE-netboot-install

Differences between revisions 6 and 7
Revision 6 as of 2013-01-08 21:58:37
Size: 7333
Editor: ua-178
Comment: Some fleshing out based on our experience getting this to work.
Revision 7 as of 2014-04-24 09:00:05
Size: 5922
Editor: mail
Comment: Overhaul of instructions
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
''Experimental method developed by Kamal Mostafa <kamal@canonical.com>'' ''Method developed by Will Tinsdeall <will.tinsdeall+opensource@mercianlabels.com>''

''Original article
by Kamal Mostafa <kamal@canonical.com>''
Line 6: Line 8:
== Using this method ==
Line 7: Line 10:
== Interesting features of this method == This method is an experimental method, which serves a UEFI signed grub image, loads the configuration in grub.cfg and boots the Linux kernel.
Line 9: Line 12:
 * Serves a UEFI-compliant "bootx64.efi" grub image to PXE clients via TFTP (as opposed to the legacy BIOS "pxelinux.0" method).
 * Does not need NFS (as is commonly used in conjunction with the pxelinux.0 method), because...
 * This method constructs a custom bootx64.efi image with the entire install iso embedded inside.
The original method on this Wiki page used an all-in-one image, which was good for the simple install on diskless PCs, but made preseeding impossible without modifying the mini.iso
Line 14: Line 15:
=== Step 1: Get the files ===
Line 15: Line 17:
== Install and configure the Server system == 1. Download the UEFI signed grub image into /srv/tftp/: [[http://archive.ubuntu.com/ubuntu/dists/trusty/main/uefi/grub2-amd64/current/grubnetx64.efi.signed]]

2. Download the correct netboot.tar.gz archive (navigate to the correct one!): [[http://cdimage.ubuntu.com/netboot/]]

3. Extract netboot.tar.gz into /srv/tftp/

=== Step 2: Get the files ===

1. Create the file /srv/tftp/grub/grub.cfg with the following content. Add other entries as needed:

For standard install (Not Preseeded):

{{{
menuentry "Install Ubuntu" {
set gfxpayload=keep
linux /ubuntu-installer/amd64/linux gfxpayload=800x600x16,800x600 -- quiet
initrd /ubuntu-installer/amd64/initrd.gz
}
}}}

For Preseeding (automatic hands-off install - you will need an HTTP server to serve the config):

{{{
menuentry "Install Ubuntu" {
set gfxpayload=keep
linux /ubuntu-installer/amd64/linux gfxpayload=800x600x16,800x600 -- auto=true url=http://YOUR_PRESEED_SERVER/preseed.cfg quiet
initrd /ubuntu-installer/amd64/initrd.gz
}
}}}

=== Step 3: Install TFTP and DHCP server (for simplicity, dnsmasq is used here) ===
1. Install dnsmasq:

{{{
sudo apt-get install dnsmasq
}}}

2. Set your computer to use a static IP

3. Configure dnsmasq add these lines to /etc/dnsmasq.conf

{{{
interface=eth0
bind-interfaces
dhcp-range=192.168.99.10,192.168.99.254
dhcp-boot=grubnetx64.efi.signed
enable-tftp
tftp-root=/srv/tftp/
}}}

4. Reload dnsmasq

{{{
sudo service dnsmasq restart
}}}

== Alternative method to create a boot image (all-in-one file) ==

Exchange this for Step 1 and Step 2. These instructions are from the original wiki
Line 19: Line 79:
 * On the Server system, fetch a netboot "mini.iso" image and save it with a distinct filename (or substitute a different Ubuntu distro for "precise"; see Notes below about Debian):  2. On the Server system, fetch a netboot "mini.iso" image and save it with a distinct filename (or substitute a different Ubuntu distro for "trusty"; see Notes below about Debian):
Line 21: Line 81:
wget http://ftp.ubuntu.com/ubuntu/dists/precise/main/installer-amd64/current/images/netboot/mini.iso \
  -O /tmp/mini-precise.iso
wget http://ftp.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/mini.iso \
  -O /tmp/mini-trusty.iso
Line 25: Line 85:
 * Generate a custom "bootx64-distro.efi" image with the mini-distro.iso embedded inside, and (Important!) with all available x86_64-efi grub modules enabled. You will move the generated .efi image file from /tmp to the tftpboot directory in a moment:  3. Generate a custom "grubnetx64.efi.signed" image with the mini-distro.iso embedded inside, and (Important!) with all available x86_64-efi grub modules enabled. You will move the generated .efi image file from /tmp to the tftpboot directory in a moment:
Line 32: Line 92:
  --output=/tmp/bootx64-precise.efi \
  --memdisk=/tmp/mini-precise.iso \
  --output=/tmp/grubnetx64.efi.signed \
  --memdisk=/tmp/mini-trusty.iso \
Line 38: Line 98:
 * Configure a static IP address (e.g. 192.168.99.1) on the wired NIC (eth0):
 {{{
sudo vi /etc/network/interfaces
}}}
 Add these lines to /etc/network/interfaces:
         ''
         {{{
auto eth0
iface eth0 inet static
 address 192.168.99.1
 broadcast 192.168.99.255
 netmask 255.255.255.0
}}}
''
 {{{
sudo restart network-manager
Line 55: Line 99:
sudo /etc/init.d/networking restart
}}}
Notes:
 * This method seems like it should work with Debian wheezy's netboot/mini.iso also, but it doesn't quite; the Clients just boot to a grub> prompt instead of a grub installer menu. Perhaps wheezy's iso contains a grub.cfg someplace other than the /boot/grub dir that Ubuntu's grub expects?
Line 58: Line 102:
 * Install apt-cacher-ng to provide http proxy service to the Clients:
  * alternately, configuring the server as a network gateway should work, but see Notes below.
  * apt-cacher-ng's proxy service will start automatically and listen on port 3142.
 {{{
 * If you see a "error: variable `prefix' isn't set" message, it can be safely ignored. Really, it doesn't mean anything. If your installation is stalling and this is visible on-screen, you should look at the "next" error, that's the one actually stopping it form working. If it ''really'' bothers you, play around with the '-p' parameter to ''grub-mkimage'' and see you can make it go away.

== Optional Extras ==


=== Install a package cacher ===

This will ensure that your internet is not hammered by hundreds of PCs, by caching the downloads required for the install on a local server. If you are using preseed, add this to your HTTP Proxy settings in your preseed config (HTTP Proxy: http://[The IP Address]:3142/).

1. Install apt-cacher-ng to provide http proxy service to the Clients (proxy listens on port 3142):

{{{
Line 65: Line 117:
 * Configure a way to hand IP addresses and TFP files to the clients. You can use a dhcpd/tftp combo, or dnsmasq as both the DHCP and TFTP server, to serve PXE clients your custom bootx64-distro.efi image. Dnsmasq is simpler and easier to set up than dhcpd and tftpd, here's how to set up dnsmasq :
 {{{
sudo apt-get install dnsmasq
Notes:

* The installed Client system will remember the proxy server setting in /etc/apt/apt.conf -- remove that file from the installed Client if you don't plan to keep it attached to the server's network.

* If you use apt-cacher-ng as described above, subsequent client installs using this Server will be much faster than the first client install.

== Debugging Options ==

A. Watch syslog on the Server with "tail -f /var/log/syslog"

B. Run tcpdump on the server, to check which files are being requested (tcpdump must be installed):
{{{
tcpdump -i eth0 port 69
Line 69: Line 131:
 {{{
sudo vi /etc/dnsmasq.conf
}}}
 Add these lines to /etc/dnsmasq.conf:
        ''
        {{{
interface=eth0
bind-interfaces
dhcp-range=192.168.99.10,192.168.99.254
dhcp-boot=bootx64-precise.efi
enable-tftp
tftp-root=/var/lib/tftpboot
}}}
''
 {{{
sudo mkdir /var/lib/tftpboot

sudo mv /tmp/bootx64-precise.efi /var/lib/tftpboot/

sudo /etc/init.d/dnsmasq restart
}}}
 * If you already have a working dhcpd/tftpd setup, just configure it to serve the .efi image to target Clients, by setting it as a host's "filename" parameter in dhcpd.conf. More details on this are out of scope for this document.

 * The Server system is now prepared to serve bootx64-precise.efi to target Clients.


== PXE-install a target Client system ==

 0. Watch syslog on the Server with "tail -f /var/log/syslog"

 * Power-on the target UEFI Client machine and get into its BIOS / boot manager menu, select the UEFI network boot option (perhaps called "EFI Network"; if more than one such choice is listed, select the IPv4 variant).
  * Server syslog should show Client acquiring an IP address and then loading your bootx64-distro.efi.

 * Client will display a grub installer menu. Select the primary "Install" choice.

 * When Client prompts for "HTTP proxy information", enter the following, which corresponds to the apt-cacher-ng proxy running on the Server (alternately, if you configured the server as a gateway instead of installing apt-cacher-ng, leave it blank):
        {{{
http:/192.168.99.1:3142/
}}}

 * Answer the remaining installer prompts, including (optionally) selecting additional software components to install above and beyond just the base OS.
Line 115: Line 135:
 * If you don't select any additional software components when installing the Client (just the base OS), then after it boots you will be left at just a blinking cursor when the Ubuntu splash screen quits (a bug?)... Use Ctrl-Alt-F1 to get to a login prompt.

 * The installed Client system will remember the proxy server setting in /etc/apt/apt.conf -- remove that file from the installed Client if you don't plan to keep it attached to the server's network.

 * If you use apt-cacher-ng as described above, subsequent client installs using this Server will be much faster than the first client install.

 * My Intel SDP system with UEFI BIOS version TM_B8 or TM_B9:
  * ... hangs before loading grub on the soft reboot after the PXE-install completes, but after a ctrl-alt-del it then boots to grub fine.
  * --(... exhibits a 60-second stall with a black screen after the grub menu (before it starts loading the kernel) when booting an Ubuntu UEFI filesystem from HDD or from USB stick.)-- This was due to [[https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/944347|bug 944347 "linux and initrd load very slowly on UEFI system"]], now resolved.
Line 126: Line 137:

 * This method seems like it should work with Debian wheezy's netboot/mini.iso also, but it doesn't quite; the Clients just boot to a grub> prompt instead of a grub installer menu. Perhaps wheezy's iso contains a grub.cfg someplace other than the /boot/grub dir that Ubuntu's grub expects?

 * If you see a "error: variable `prefix' isn't set" message, it can be safely ignored. Really, it doesn't mean anything. If your installation is stalling and this is visible on-screen, you should look at the "next" error, that's the one actually stopping it form working. If it ''really'' bothers you, play around with the '-p' parameter to ''grub-mkimage'' and see you can make it go away.

 * TBD: How can we pre-seed the install?

 * TBD: This method always feeds the client a single, pre-selected distro (e.g. "bootx64-precise.efi"). Is it possible to somehow allow the client to select which distro they want via a menu system (like with the pxelinux.0 install menu system?)

UEFI PXE netboot / install procedure

Method developed by Will Tinsdeall <will.tinsdeall+opensource@mercianlabels.com>

Original article by Kamal Mostafa <kamal@canonical.com>

Using this method

This method is an experimental method, which serves a UEFI signed grub image, loads the configuration in grub.cfg and boots the Linux kernel.

The original method on this Wiki page used an all-in-one image, which was good for the simple install on diskless PCs, but made preseeding impossible without modifying the mini.iso

Step 1: Get the files

1. Download the UEFI signed grub image into /srv/tftp/: http://archive.ubuntu.com/ubuntu/dists/trusty/main/uefi/grub2-amd64/current/grubnetx64.efi.signed

2. Download the correct netboot.tar.gz archive (navigate to the correct one!): http://cdimage.ubuntu.com/netboot/

3. Extract netboot.tar.gz into /srv/tftp/

Step 2: Get the files

1. Create the file /srv/tftp/grub/grub.cfg with the following content. Add other entries as needed:

For standard install (Not Preseeded):

menuentry "Install Ubuntu" {
set gfxpayload=keep
linux /ubuntu-installer/amd64/linux gfxpayload=800x600x16,800x600 -- quiet
initrd /ubuntu-installer/amd64/initrd.gz
}

For Preseeding (automatic hands-off install - you will need an HTTP server to serve the config):

menuentry "Install Ubuntu" {
set gfxpayload=keep
linux /ubuntu-installer/amd64/linux gfxpayload=800x600x16,800x600 -- auto=true url=http://YOUR_PRESEED_SERVER/preseed.cfg quiet
initrd /ubuntu-installer/amd64/initrd.gz
}

Step 3: Install TFTP and DHCP server (for simplicity, dnsmasq is used here)

1. Install dnsmasq:

sudo apt-get install dnsmasq

2. Set your computer to use a static IP

3. Configure dnsmasq add these lines to /etc/dnsmasq.conf

interface=eth0
bind-interfaces
dhcp-range=192.168.99.10,192.168.99.254
dhcp-boot=grubnetx64.efi.signed
enable-tftp
tftp-root=/srv/tftp/

4. Reload dnsmasq

sudo service dnsmasq restart

Alternative method to create a boot image (all-in-one file)

Exchange this for Step 1 and Step 2. These instructions are from the original wiki

  1. Install a regular Ubuntu system + updates, or use an existing Ubuntu system as the Server. The Server can be any computer with a wired NIC; the Server itself does not need to be UEFI-capable. (I installed ubuntu-11.10-desktop-amd64.iso from a USB stick on to an x220 laptop, but any Ubuntu installation should work).
  2. On the Server system, fetch a netboot "mini.iso" image and save it with a distinct filename (or substitute a different Ubuntu distro for "trusty"; see Notes below about Debian):
    wget http://ftp.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/mini.iso  \
                    -O /tmp/mini-trusty.iso
  3. Generate a custom "grubnetx64.efi.signed" image with the mini-distro.iso embedded inside, and (Important!) with all available x86_64-efi grub modules enabled. You will move the generated .efi image file from /tmp to the tftpboot directory in a moment:
    • the ls|sed sequence generates the list of all modules.

    • many of the modules are actually required, but surely not all; I don't know which are or aren't required.
    sudo apt-get install grub-efi-amd64-bin
    
    grub-mkimage --format=x86_64-efi  \
                    --output=/tmp/grubnetx64.efi.signed   \
                    --memdisk=/tmp/mini-trusty.iso  \
                    `ls /usr/lib/grub/x86_64-efi  | sed -n 's/\.mod//gp'`
    • Note that some modules may cause the installation to stall with a error: no device connected message, in this case you will need to remove the drivers giving the error. For instance, to remove the pata module, change the module listing part to ls /usr/lib/grub/x86_64-efi  | sed -n 's/\.mod//gp' | grep -v pata

Notes:

  • This method seems like it should work with Debian wheezy's netboot/mini.iso also, but it doesn't quite; the Clients just boot to a grub> prompt instead of a grub installer menu. Perhaps wheezy's iso contains a grub.cfg someplace other than the /boot/grub dir that Ubuntu's grub expects?

  • If you see a "error: variable `prefix' isn't set" message, it can be safely ignored. Really, it doesn't mean anything. If your installation is stalling and this is visible on-screen, you should look at the "next" error, that's the one actually stopping it form working. If it really bothers you, play around with the '-p' parameter to grub-mkimage and see you can make it go away.

Optional Extras

Install a package cacher

This will ensure that your internet is not hammered by hundreds of PCs, by caching the downloads required for the install on a local server. If you are using preseed, add this to your HTTP Proxy settings in your preseed config (HTTP Proxy: http://[The IP Address]:3142/).

1. Install apt-cacher-ng to provide http proxy service to the Clients (proxy listens on port 3142):

sudo apt-get install apt-cacher-ng

Notes:

* The installed Client system will remember the proxy server setting in /etc/apt/apt.conf -- remove that file from the installed Client if you don't plan to keep it attached to the server's network.

* If you use apt-cacher-ng as described above, subsequent client installs using this Server will be much faster than the first client install.

Debugging Options

A. Watch syslog on the Server with "tail -f /var/log/syslog"

B. Run tcpdump on the server, to check which files are being requested (tcpdump must be installed):

tcpdump -i eth0 port 69

Notes

  • It is possible to configure dhcp to offer different images to different clients based on MAC address and some other variables, which could be used to offer UEFI (bootx64.efi) and legacy BIOS (pxelinux.0) images, but this is not covered here.

UEFI/PXE-netboot-install (last edited 2016-09-23 20:55:07 by cyphermox)