Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:services:tftp.pxe-server [2018/10/17 06:16] – [3. Enable TFTP and NFS Service] add info about dhcp option 209 chkdskdocs:guide-user:services:tftp.pxe-server [2023/12/24 12:46] – [PXE-Boot network boot server] add a reference to USB drives quickstart akostadinov
Line 1: Line 1:
-===== PXE-Boot network boot server ===== +The word NetBoot can be applied to multiple concepts, see [[inbox:howto:netboot_pointers]].  This manual outlines how to use an external USB storage media on the OpenWRT router to serve boot images and a NFS root partition for a (presumably) diskless client.  There is a simplified instruction on how to fix the OpenWRT router to serve a boot image on [[inbox:howto:Setting up OpenWRT to serve Archlinux NetBoot]] 
-You can use your OpenWRT device as a PXE-Server to store network boot images for booting other devices over then network. + 
 +====== PXE-Boot network boot server ====== 
 +Note: you can also check [[:docs:guide-user:storage:usb-drives-quickstart]] 
 + 
 +You can use your OpenWrt device as a PXE-Server to store network boot images for booting other devices over then network. 
 Possibilities: Possibilities:
   * Boot Ubuntu / Debian / CentOS Live Systems   * Boot Ubuntu / Debian / CentOS Live Systems
Line 7: Line 11:
   * boot a Windows image prepared for network boot (not described in this tutorial)   * boot a Windows image prepared for network boot (not described in this tutorial)
  
-The following example shows how to provide PXE-Booting for Ubuntu Live System on an OpenWRT Router.+The following example shows how to provide PXE-Booting for Ubuntu Live System on an OpenWrt Router.
  
 Basic idea: Basic idea:
Line 16: Line 20:
 Booting other Linux based distributions is not very different, only the boot parameters differ and can be found everywhere on the internet. Booting other Linux based distributions is not very different, only the boot parameters differ and can be found everywhere on the internet.
  
-The following instructions have been done step-by-step on an OpenWRT Attitude Adjustment 12.09 on a [[toh/tp-link/tl-wdr3600]]on 6th of December 2013+The following instructions have been done step-by-step on an OpenWrt Attitude Adjustment 12.09 on a [[toh:tp-link:tl-wdr3600_v1]]on 6th of December 2013
  
-==== 1. Install Mass Storage====+===== 1. Install Mass Storage =====
  
 Install USB-Support Install USB-Support
-<code>root@OpenWRT:~# opkg install usbutils kmod-usb-storage  block-mount</code>+<code>root@OpenWrt:~# opkg install usbutils kmod-usb-storage  block-mount</code>
 Show connected USB-Devices Show connected USB-Devices
 <code> <code>
-root@OpenWRT:~# lsusb+root@OpenWrt:~# lsusb
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
 Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB
Line 36: Line 40:
 For more information on NTFS see [[docs:guide-user:storage:writable_ntfs]] For more information on NTFS see [[docs:guide-user:storage:writable_ntfs]]
 <code> <code>
-root@OpenWRT:~# ls -l /dev/sd*+root@OpenWrt:~# ls -l /dev/sd*
 brw-r--r--    1 root    root        8,   0 Jan  1  1970 /dev/sda brw-r--r--    1 root    root        8,   0 Jan  1  1970 /dev/sda
 brw-r--r--    1 root    root        8,   1 Dec  6 17:52 /dev/sda1 brw-r--r--    1 root    root        8,   1 Dec  6 17:52 /dev/sda1
Line 42: Line 46:
 Create mountpoint for usbdevice Create mountpoint for usbdevice
 <code> <code>
-root@OpenWRT:~# mkdir /mnt/extstorage+root@OpenWrt:~# mkdir /mnt/extstorage
 </code> </code>
 Enable automatic mounting of external USB Storage. For additional Information see [[docs:guide-user:storage:fstab]] Enable automatic mounting of external USB Storage. For additional Information see [[docs:guide-user:storage:fstab]]
 <code> <code>
-root@OpenWRT:~# vim /etc/config/fstab+root@OpenWrt:~# vim /etc/config/fstab
 config global automount config global automount
         option from_fstab 1         option from_fstab 1
Line 61: Line 65:
         option enabled_fsck 0         option enabled_fsck 0
 </code> </code>
-Now enable start of fstab-service on boot of OpenWRT+Now enable start of fstab-service on boot of OpenWrt
 <code> <code>
-root@OpenWRT:~# /etc/init.d/fstab enable+root@OpenWrt:~# /etc/init.d/fstab enable
 </code> </code>
 Start fstab this time manually Start fstab this time manually
 <code> <code>
-root@OpenWRT:~# /etc/init.d/fstab start+root@OpenWrt:~# /etc/init.d/fstab start
 </code> </code>
 Verify that the USB Mass Storage /dev/sda1 is mounted to /mnt/extstorage Verify that the USB Mass Storage /dev/sda1 is mounted to /mnt/extstorage
 <code> <code>
-root@OpenWRT:~# mount | grep extstorage+root@OpenWrt:~# mount | grep extstorage
 /dev/sda1 on /mnt/extstorage type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096) /dev/sda1 on /mnt/extstorage type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
 </code> </code>
 For testing purposes, touch a file on the usb-stick and reboot OpenWrt router: For testing purposes, touch a file on the usb-stick and reboot OpenWrt router:
 <code> <code>
-root@OpenWRT:~# touch /mnt/extstorage/test.txt +root@OpenWrt:~# touch /mnt/extstorage/test.txt 
-root@OpenWRT:~# reboot+root@OpenWrt:~# reboot
 </code> </code>
 After the reboot you should be able to verify again that the USB Mass Storage is mounted to /mnt/extstorage and that the test.txt exists. After the reboot you should be able to verify again that the USB Mass Storage is mounted to /mnt/extstorage and that the test.txt exists.
  
-==== 2. Prepare files for PXE-Booting ====+===== 2. Prepare files for PXE-Booting =====
 Generate TFTP-Boot folder structure and files: Generate TFTP-Boot folder structure and files:
 <code> <code>
-root@OpenWRT:~# cd /mnt/extstorage +root@OpenWrt:~# cd /mnt/extstorage 
-root@OpenWRT:~# mkdir tftp tftp/pxelinux.cfg tftp/disks tftp/disks/ubuntu1604-64+root@OpenWrt:~# mkdir tftp tftp/pxelinux.cfg tftp/disks tftp/disks/ubuntu1604-64
 </code> </code>
  
Line 92: Line 96:
 Direct-Link to 13-Oct-2013 [[https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz|Syslinux v6.03]] Direct-Link to 13-Oct-2013 [[https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz|Syslinux v6.03]]
  
-The basic wget from OpenWRT does NOT support wget from https://. The following steps could be done by downloading the syslinux to your pc and transfer the required files manually to your usb-stick. +The basic wget from OpenWrt does NOT support wget from https://. The following steps could be done by downloading the syslinux to your pc and transfer the required files manually to your usb-stick. 
  
-Because the basic OpenWRT wget does not support https, we have to install the package wget (thanks to theoradicus for giving this important hint) and the extended tar command to extract the compressed archive afterwards:+Because the basic OpenWrt wget does not support https, we have to install the package wget (thanks to theoradicus for giving this important hint) and the extended tar command to extract the compressed archive afterwards:
 <code> <code>
-root@OpenWRT:~# opkg update +root@OpenWrt:~# opkg update 
-root@OpenWRT:~# opkg install wget tar+root@OpenWrt:~# opkg install wget tar
 </code> </code>
  
-Now we can download the syslinux archive and extract it. We do not have the public SSL-CAs on our OpenWRT so we have to NOT check the server-certificate:+Now we can download the syslinux archive and extract it. We do not have the public SSL-CAs on our OpenWrt so we have to NOT check the server-certificate:
 <code> <code>
-root@OpenWRT:~# mkdir /mnt/extstorage/syslinux-download +root@OpenWrt:~# mkdir /mnt/extstorage/syslinux-download 
-root@OpenWRT:~# cd /mnt/extstorage/syslinux-download +root@OpenWrt:~# cd /mnt/extstorage/syslinux-download 
-root@OpenWRT:/mnt/extstorage/syslinux-download# wget --no-check-certificate https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz +root@OpenWrt:/mnt/extstorage/syslinux-download# wget --no-check-certificate https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz 
-root@OpenWRT:/mnt/extstorage/syslinux-download# tar -xf syslinux-6.03.tar.gz+root@OpenWrt:/mnt/extstorage/syslinux-download# tar -xf syslinux-6.03.tar.gz
 </code> </code>
    
Line 117: Line 121:
 As one single long copy-command: As one single long copy-command:
 <code> <code>
-root@OpenWRT:~# cd /mnt/extstorage/syslinux-download/syslinux-6.03/bios +root@OpenWrt:~# cd /mnt/extstorage/syslinux-download/syslinux-6.03/bios 
-root@OpenWRT:/mnt/extstorage/syslinux-download/syslinux-6.03/bios# cp core/pxelinux.0 com32/elflink/ldlinux/ldlinux.c32 com32/menu/vesamenu.c32 com32/lib/libcom32.c32 com32/libutil/libutil.c32 /mnt/extstorage/tftp+root@OpenWrt:/mnt/extstorage/syslinux-download/syslinux-6.03/bios# cp core/pxelinux.0 com32/elflink/ldlinux/ldlinux.c32 com32/menu/vesamenu.c32 com32/lib/libcom32.c32 com32/libutil/libutil.c32 /mnt/extstorage/tftp
 </code> </code>
  
Line 125: Line 129:
 Now we create our default menu-file: Now we create our default menu-file:
 <code> <code>
-root@OpenWRT:~# vim /mnt/extstorage/tftp/pxelinux.cfg/default+root@OpenWrt:~# vim /mnt/extstorage/tftp/pxelinux.cfg/default
 DEFAULT vesamenu.c32 DEFAULT vesamenu.c32
 PROMPT 0 PROMPT 0
-MENU TITLE OpenWRT PXE-Boot Menu+MENU TITLE OpenWrt PXE-Boot Menu
  
 label Ubuntu label Ubuntu
Line 143: Line 147:
 We now have to download and extract the Ubuntu 16.04 to the USB-Drive.  We now have to download and extract the Ubuntu 16.04 to the USB-Drive. 
  
-One Option is to do this directly on the OpenWRT itself, but I downloaded the Ubuntu ISO on my computer and plugged in the USB-Drive from OpenWRT and put only the extracted files onto the USB-Drive+One Option is to do this directly on the OpenWrt itself, but I downloaded the Ubuntu ISO on my computer and plugged in the USB-Drive from OpenWrt and put only the extracted files onto the USB-Drive
  
 Finally, you should have something like the following folder structure: Finally, you should have something like the following folder structure:
 <code> <code>
-root@OpenWRT:~#  cd .. +root@OpenWrt:~#  cd .. 
-root@OpenWRT:~# # find /mnt/extstorage/tftp/+root@OpenWrt:~# # find /mnt/extstorage/tftp/
 /mnt/extstorage/tftp/ /mnt/extstorage/tftp/
 /mnt/extstorage/tftp/disks /mnt/extstorage/tftp/disks
Line 187: Line 191:
 </code> </code>
  
-==== 3. Enable TFTP and NFS Service====+===== 3. Enable TFTP and NFS Service =====
  
  
 Configure dnsmasq service to enable read-only tftp-service Configure dnsmasq service to enable read-only tftp-service
 <code> <code>
-root@OpenWRT:~# vim /etc/config/dhcp+root@OpenWrt:~# vim /etc/config/dhcp
 config dnsmasq config dnsmasq
          ... a lot of config done before...          ... a lot of config done before...
Line 202: Line 206:
         option filename 'pxelinux.0'         option filename 'pxelinux.0'
         option serveraddress '192.168.1.1'         option serveraddress '192.168.1.1'
-        option servername 'OpenWRT'+        option servername 'OpenWrt'
  
-root@OpenWRT:~# /etc/init.d/dnsmasq restart+root@OpenWrt:~# /etc/init.d/dnsmasq restart
 </code> </code>
  
Line 216: Line 220:
 Now we have to install and configure the NFS-Service: Now we have to install and configure the NFS-Service:
 <code> <code>
-root@OpenWRT:~# opkg install nfs-kernel-server+root@OpenWrt:~# opkg install nfs-kernel-server
 </code> </code>
  
 Configure NFS-Share now Configure NFS-Share now
 <code> <code>
-root@OpenWRT:~# vim /etc/exports+root@OpenWrt:~# vim /etc/exports
 /mnt/extstorage/tftp/disks  *(ro,async,no_subtree_check) /mnt/extstorage/tftp/disks  *(ro,async,no_subtree_check)
 </code> </code>
Line 227: Line 231:
 Now enable portmap and nfsd and (re)start them Now enable portmap and nfsd and (re)start them
 <code> <code>
-root@OpenWRT:~# /etc/init.d/portmap enable +root@OpenWrt:~# /etc/init.d/portmap enable 
-root@OpenWRT:~# /etc/init.d/portmap restart +root@OpenWrt:~# /etc/init.d/portmap restart 
-root@OpenWRT:~# /etc/init.d/nfsd enable +root@OpenWrt:~# /etc/init.d/nfsd enable 
-root@OpenWRT:~# /etc/init.d/nfsd restart+root@OpenWrt:~# /etc/init.d/nfsd restart
 </code> </code>
  
-====4. Testing it out====+===== 4. Testing it out =====
  
-And now we are ready to go! Just grab a computer (or Virtual Machine) and PXE Boot - you should be able to fully boot into Ubuntu 16.04 via your OpenWRT Router :-D+And now we are ready to go! Just grab a computer (or Virtual Machine) and PXE Boot - you should be able to fully boot into Ubuntu 16.04 via your OpenWrt Router :-D
 Hint: you often have to enable PXE-Booting in BIOS and press e.g. F12 to get into the Boot-Menu. Hint: you often have to enable PXE-Booting in BIOS and press e.g. F12 to get into the Boot-Menu.
  
Line 271: Line 275:
 </code>   </code>  
  
-{{tag>tftpd}}+===== 5. Trouble shooting ===== 
 + 
 +<code> 
 +>>Checking Media Presence...... 
 +>>Media Present...... 
 +>>Start PXE over IPv4. 
 +  Station IP address is 192.168.1.239 
 +   
 +  Server IP address is 192.168.1.1 
 +  NBP filename is pxelinux.0 
 +  NBP filesize is 0 Bytes 
 +  PXE-E23: Client received TFTP error from... 
 +</code> 
 + 
 +Check that your tftp-server is up and running and serves the file 'pxelinux.0': 
 + 
 +<code> 
 +user@server:~# opkg update 
 +user@server:~# opkg install atftp 
 +user@server:~# atftp 192.168.1.1 
 +tftp> get pxelinux.0 
 +tftp> error received from server <file /mnt/extstorage/tftp/pxelinux.0> not found 
 +tftp> aborting 
 +tftp> 
 +</code> 
 + 
 +If the file pxelinux.0 is at the expected location, try restarting the tftp server: 
 + 
 +<code> 
 +user@server:~# /etc/init.d/dnsmasq restart 
 +udhcpc: started, v1.35.0 
 +udhcpc: broadcasting discover 
 +udhcpc: no lease, failing 
 +user@server:~# 
 +</code>
  • Last modified: 2024/03/12 10:11
  • by mdvthu