Difference between revisions of "Application note - UEFI PXE boot to Linux Mint"

From fit-PC wiki
Jump to: navigation, search
(Overview)   (change visibility)
 
(4 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
* The diskless computer (or diskless node) you want to boot will be called the Client
 
* The diskless computer (or diskless node) you want to boot will be called the Client
 
* The computer that holds the ISO images and provides DHCP, TFTP and NFS services will be called the Server.
 
* The computer that holds the ISO images and provides DHCP, TFTP and NFS services will be called the Server.
** Server is running Linux Mint 19
+
** Server is running recent Linux Mint or Ubuntu distributions
 
** Server has 2 Ethernet ports: eth0 connects to the internet, eth1 will be connected to the separate network with diskless nodes
 
** Server has 2 Ethernet ports: eth0 connects to the internet, eth1 will be connected to the separate network with diskless nodes
 +
 +
* As example we will boot the client from the linuxmint-19.1-cinnamon-64bit.iso stored on the Server
  
 
== TFTP server ==
 
== TFTP server ==
Line 184: Line 186:
  
 
== Prepare the client ==
 
== Prepare the client ==
* Enter the BIOS Settings by pressing [Delete] number of times after power-on
+
* Power-on the client
 +
* Enter the BIOS Settings by pressing [Delete] number of times
 
* Set Advanced -> Network Stack Configuration -> Ipv4 PXE Support to [Enabled]
 
* Set Advanced -> Network Stack Configuration -> Ipv4 PXE Support to [Enabled]
 
* Save & Exit
 
* Save & Exit
 +
* Thats all, after 1-2 minutes you should see the Linux Mint 19 desktop on your client's display
  
 
== Enable debug (optional) ==
 
== Enable debug (optional) ==
Line 223: Line 227:
 
</pre>
 
</pre>
  
== A ==
+
[[category: Application note]]
 +
[[category: Linux]]

Latest revision as of 15:37, 23 January 2019

Overview

  • In this tutorial you will be able to create PXE server on your PC that allows you to boot multiple distributions directly from ISO image using Ethernet connection only.
  • The diskless computer (or diskless node) you want to boot will be called the Client
  • The computer that holds the ISO images and provides DHCP, TFTP and NFS services will be called the Server.
    • Server is running recent Linux Mint or Ubuntu distributions
    • Server has 2 Ethernet ports: eth0 connects to the internet, eth1 will be connected to the separate network with diskless nodes
  • As example we will boot the client from the linuxmint-19.1-cinnamon-64bit.iso stored on the Server

TFTP server

$ sudo apt install tftpd-hpa
  • Edit configuration file: /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure --ipv4 --verbose"
  • Reload tftpd-hpa service and verify it's running:
$ sudo service tftpd-hpa restart
$ service tftpd-hpa status
● tftpd-hpa.service - LSB: HPA's tftp server
   Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
   Active: active (running) since Wed 2019-01-23 08:15:20 EST; 7s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2002 ExecStop=/etc/init.d/tftpd-hpa stop (code=exited, status=0/SUCCESS)
  Process: 2007 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/tftpd-hpa.service
           └─2015 /usr/sbin/in.tftpd --listen --user tftp --address :69 --secure --ipv4 --verbose /var/lib/tftpboot

Jan 23 08:15:20 denis-linux systemd[1]: Starting LSB: HPA's tftp server...
Jan 23 08:15:20 denis-linux tftpd-hpa[2007]:  * Starting HPA's tftpd in.tftpd
Jan 23 08:15:20 denis-linux tftpd-hpa[2007]:    ...done.
Jan 23 08:15:20 denis-linux systemd[1]: Started LSB: HPA's tftp server.

DHCP server

$ sudo apt install isc-dhcp-server
  • Edit configuration file: /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
    address 10.0.0.1
    netmask 255.255.255.0
    network 10.0.0.0
    broadcast 10.0.0.255
  • Reload networking service and verify it's running:
$ sudo service networking restart
$ service networking status
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2019-01-23 08:16:45 EST; 9s ago
     Docs: man:interfaces(5)
  Process: 3376 ExecStop=/sbin/ifdown -a --read-environment --exclude=lo (code=exited, status=0/SUCCESS)
  Process: 3395 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=0/SUCCESS)
  Process: 3392 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] && udevadm settle (code=exited, status=0/SUCCESS)
 Main PID: 3395 (code=exited, status=0/SUCCESS)

Jan 23 08:16:45 denis-linux systemd[1]: Starting Raise network interfaces...
Jan 23 08:16:45 denis-linux systemd[1]: Started Raise network interfaces.
  • Edit configuration file: /etc/default/isc-dhcp-server
INTERFACESv4="eth1"
  • Edit configuration file: /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;

allow booting;
allow bootp;

subnet 10.0.0.0 netmask 255.255.255.0 {
    range 10.0.0.2 10.0.0.254;
    option subnet-mask 255.255.255.0;
    option domain-name-servers 10.0.0.1;
    option routers 10.0.0.1;
    option broadcast-address 10.0.0.255;
    filename "grubx64.efi";
}
  • Reload isc-dhcp-server service and verify it's running:
$ sudo service isc-dhcp-server restart
$ service isc-dhcp-server status
● isc-dhcp-server.service - ISC DHCP IPv4 server
   Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-01-23 08:18:40 EST; 7s ago
     Docs: man:dhcpd(8)
 Main PID: 3604 (dhcpd)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/isc-dhcp-server.service
           └─3604 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf

Jan 23 08:18:40 denis-linux dhcpd[3604]: Sending on   LPF/eth1/00:01:c0:1c:a8:11/10.0.0.0/24
Jan 23 08:18:40 denis-linux dhcpd[3604]: 
Jan 23 08:18:40 denis-linux dhcpd[3604]: No subnet declaration for eth0 (192.168.84.51).
Jan 23 08:18:40 denis-linux dhcpd[3604]: ** Ignoring requests on eth0.  If this is not what
Jan 23 08:18:40 denis-linux dhcpd[3604]:    you want, please write a subnet declaration
Jan 23 08:18:40 denis-linux dhcpd[3604]:    in your dhcpd.conf file for the network segment
Jan 23 08:18:40 denis-linux dhcpd[3604]:    to which interface eth0 is attached. **
Jan 23 08:18:40 denis-linux dhcpd[3604]: 
Jan 23 08:18:40 denis-linux dhcpd[3604]: Sending on   Socket/fallback/fallback-net
Jan 23 08:18:40 denis-linux dhcpd[3604]: Server starting service.

ISO images

  • Download desired ISO image, for example:
$ mkdir -p ~/iso/linuxmint/
$ wget http://mirrors.seas.harvard.edu/linuxmint/stable/19.1/linuxmint-19.1-cinnamon-64bit.iso -P ~/iso/linuxmint/
  • Copy downloaded ISO image content to the TFTP directory
$ sudo mkdir -p /mnt/loop
$ sudo mkdir -p /var/lib/tftpboot/iso/linuxmint-19.1-cinnamon-64bit.iso
$ sudo mount -o loop ~/iso/linuxmint/linuxmint-19.1-cinnamon-64bit.iso /mnt/loop

$ sudo cp -r /mnt/loop/* /var/lib/tftpboot/iso/linuxmint-19.1-cinnamon-64bit.iso
$ ls /var/lib/tftpboot/iso/linuxmint-19.1-cinnamon-64bit.iso
boot  casper  dists  EFI  isolinux  MD5SUMS  pool  preseed  README.diskdefines

UEFI grub bootloader

  • Prepare UEFI grub bootloader and configuration file grub.cfg:
$ sudo cp /usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed /var/lib/tftpboot/grubx64.efi
$ sudo mkdir -p /var/lib/tftpboot/grub
  • Edit configuration file: /var/lib/tftpboot/grub/grub.cfg
menuentry "linuxmint-19.1-cinnamon-64bit.iso" {
    linux  iso/linuxmint-19.1-cinnamon-64bit.iso/casper/vmlinuz nfsroot=10.0.0.1:/var/lib/tftpboot/iso/linuxmint-19.1-cinnamon-64bit.iso boot=casper netboot=nfs toram
    initrd iso/linuxmint-19.1-cinnamon-64bit.iso/casper/initrd.lz
}

NFS server

$ sudo apt install nfs-kernel-server
  • Edit configuration file: /etc/exports
/var/lib/tftpboot/iso 10.0.0.0/255.255.0.0(ro,sync,no_subtree_check)
  • Reload nfs-kernel-server service and verify it's running:
$ sudo service nfs-kernel-server restart
$ service nfs-kernel-server status
● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2019-01-23 08:27:05 EST; 6s ago
  Process: 4635 ExecStopPost=/usr/sbin/exportfs -f (code=exited, status=0/SUCCESS)
  Process: 4634 ExecStopPost=/usr/sbin/exportfs -au (code=exited, status=0/SUCCESS)
  Process: 4633 ExecStop=/usr/sbin/rpc.nfsd 0 (code=exited, status=0/SUCCESS)
  Process: 4643 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 4642 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 4643 (code=exited, status=0/SUCCESS)

Jan 23 08:27:05 denis-linux systemd[1]: Starting NFS server and services...
Jan 23 08:27:05 denis-linux systemd[1]: Started NFS server and services.

Prepare the client

  • Power-on the client
  • Enter the BIOS Settings by pressing [Delete] number of times
  • Set Advanced -> Network Stack Configuration -> Ipv4 PXE Support to [Enabled]
  • Save & Exit
  • Thats all, after 1-2 minutes you should see the Linux Mint 19 desktop on your client's display

Enable debug (optional)

  • /var/log/syslog will represent debug info on the server side:
$ tail -f /var/log/syslog
...
Jan 23 08:40:01 denis-linux dhcpd[1244]: DHCPDISCOVER from 00:01:c0:12:34:57 via eth1
Jan 23 08:40:02 denis-linux dhcpd[1244]: DHCPOFFER on 10.0.0.2 to 00:01:c0:12:34:57 via eth1
Jan 23 08:40:05 denis-linux dhcpd[1244]: DHCPREQUEST for 10.0.0.2 (10.0.0.1) from 00:01:c0:12:34:57 via eth1
Jan 23 08:40:05 denis-linux dhcpd[1244]: DHCPACK on 10.0.0.2 to 00:01:c0:12:34:57 via eth1
Jan 23 08:40:05 denis-linux in.tftpd[1633]: RRQ from 10.0.0.2 filename grubx64.efi
Jan 23 08:40:05 denis-linux in.tftpd[1633]: tftp: client does not accept options
Jan 23 08:40:05 denis-linux in.tftpd[1634]: RRQ from 10.0.0.2 filename grubx64.efi
Jan 23 08:40:06 denis-linux in.tftpd[1635]: RRQ from 10.0.0.2 filename /grub/x86_64-efi/command.lst
Jan 23 08:40:06 denis-linux in.tftpd[1636]: RRQ from 10.0.0.2 filename /grub/x86_64-efi/fs.lst
Jan 23 08:40:06 denis-linux in.tftpd[1637]: RRQ from 10.0.0.2 filename /grub/x86_64-efi/crypto.lst
Jan 23 08:40:06 denis-linux in.tftpd[1638]: RRQ from 10.0.0.2 filename /grub/x86_64-efi/terminal.lst
Jan 23 08:40:06 denis-linux in.tftpd[1639]: RRQ from 10.0.0.2 filename /grub/grub.cfg
Jan 23 08:40:15 denis-linux in.tftpd[1640]: RRQ from 10.0.0.2 filename iso/linuxmint-19.1-cinnamon-64bit.iso/casper/vmlinuz
Jan 23 08:40:15 denis-linux in.tftpd[1641]: RRQ from 10.0.0.2 filename iso/linuxmint-19.1-cinnamon-64bit.iso/casper/initrd.lz
Jan 23 08:40:35 denis-linux kernel: [  725.823235] igb 0000:02:00.0 eth1: igb: eth1 NIC Link is Down
Jan 23 08:40:39 denis-linux NetworkManager[674]: <info>  [1548250839.2887] device (eth1): carrier: link connected
Jan 23 08:40:39 denis-linux kernel: [  729.511874] igb 0000:02:00.0 eth1: igb: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX
Jan 23 08:40:40 denis-linux dhcpd[1244]: reuse_lease: lease age 35 (secs) under 25% threshold, reply with unaltered, existing lease for 10.0.0.2
Jan 23 08:40:40 denis-linux dhcpd[1244]: DHCPDISCOVER from 00:01:c0:12:34:57 via eth1
Jan 23 08:40:40 denis-linux dhcpd[1244]: DHCPOFFER on 10.0.0.2 to 00:01:c0:12:34:57 via eth1
Jan 23 08:40:40 denis-linux dhcpd[1244]: reuse_lease: lease age 35 (secs) under 25% threshold, reply with unaltered, existing lease for 10.0.0.2
Jan 23 08:40:40 denis-linux dhcpd[1244]: DHCPREQUEST for 10.0.0.2 (10.0.0.1) from 00:01:c0:12:34:57 via eth1
Jan 23 08:40:40 denis-linux dhcpd[1244]: DHCPACK on 10.0.0.2 to 00:01:c0:12:34:57 via eth1
Jan 23 08:40:40 denis-linux rpc.mountd[850]: authenticated mount request from 10.0.0.2:836 for /var/lib/tftpboot/iso/linuxmint-19.1-cinnamon-64bit.iso (/var/lib/tftpboot/iso)
Jan 23 08:41:06 denis-linux dhcpd[1244]: DHCPDISCOVER from 00:01:c0:12:34:57 via eth1
Jan 23 08:41:06 denis-linux dhcpd[1244]: DHCPOFFER on 10.0.0.2 to 00:01:c0:12:34:57 (mint) via eth1
Jan 23 08:41:06 denis-linux dhcpd[1244]: DHCPREQUEST for 10.0.0.2 (10.0.0.1) from 00:01:c0:12:34:57 (mint) via eth1
Jan 23 08:41:06 denis-linux dhcpd[1244]: DHCPACK on 10.0.0.2 to 00:01:c0:12:34:57 (mint) via eth1