{"id":273,"date":"2023-08-26T09:13:02","date_gmt":"2023-08-26T07:13:02","guid":{"rendered":"https:\/\/it4home.dk\/?p=273"},"modified":"2023-08-26T09:17:43","modified_gmt":"2023-08-26T07:17:43","slug":"booting-raspberry-pi-via-pxe-a-guide-to-network-booting","status":"publish","type":"post","link":"https:\/\/it4home.dk\/index.php\/2023\/08\/26\/booting-raspberry-pi-via-pxe-a-guide-to-network-booting\/","title":{"rendered":"Booting Raspberry Pi via PXE: A Guide to Network Booting"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-post pdfprnt-top-right\"><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/273?print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\" ><\/a><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/273?print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\" ><img decoding=\"async\" src=\"https:\/\/it4home.dk\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div>\n<p class=\"wp-block-paragraph\"><strong>Title: Booting Raspberry Pi via PXE: A Guide to Network Booting<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Introduction<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Raspberry Pi, with its versatility and affordability, has become a favorite among tech enthusiasts for various projects. One of the most intriguing applications is using PXE (Preboot Execution Environment) to boot Raspberry Pi devices over the network, eliminating the need for local storage. This method can simplify management and deployment in various scenarios. In this guide, we&#8217;ll walk you through the steps to set up PXE boot for your Raspberry Pi.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Prerequisites<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before diving into the PXE boot setup, ensure you have the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Raspberry Pi board(s)<\/li>\n\n\n\n<li>Network access<\/li>\n\n\n\n<li>A NAS (Network-Attached Storage) or server for storing boot and root images<\/li>\n\n\n\n<li>Basic knowledge of Linux commands<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Setting Up PXE Boot for Raspberry Pi<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Find Serial Number for PXE Boot<\/strong> Begin by finding the serial number of your Raspberry Pi. Open a terminal and enter the following command:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   vcgencmd otp_dump | grep 28: | sed s\/.*:\/\/g<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>Install Necessary Software<\/strong> Install the <code>nfs-common<\/code> package on your Raspberry Pi by running:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo apt install nfs-common<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>Configure Network Booting<\/strong> Use <code>raspi-config<\/code> to enable network booting:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo raspi-config<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the advanced boot options, enable network booting and set the boot order to boot from the network if the SD card boot fails.<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li><strong>Create Directories<\/strong> On your Raspberry Pi, create a directory in <code>\/rpi-tftpboot<\/code> using the serial number obtained earlier. On your PXE server, create a directory with the hostname of your Raspberry Pi.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   mkdir \/nfs\/boot \/nfs\/root<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li><strong>Mount NAS<\/strong> Mount your NAS or server to the created directories:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo mount -t nfs -o proto=tcp,port=2049 192.168.0.11:\/volume1\/rpi-tftpboot\/8eb2f324 \/nfs\/boot\n   sudo mount -t nfs -o proto=tcp,port=2049 192.168.0.11:\/volume1\/rpi-pxe\/RPI4GB \/nfs\/root<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\">\n<li><strong>Copy Boot and Root Images<\/strong> Copy the boot image to the <code>\/nfs\/boot<\/code> directory and the root image to the <code>\/nfs\/root<\/code> directory:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo rsync -av \/boot\/* \/nfs\/boot\n   sudo rsync -av --exclude '\/nfs' \/ \/nfs\/root<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"7\">\n<li><strong>Modify Command Line<\/strong> Edit the <code>cmdline.txt<\/code> file in the <code>\/nfs\/boot<\/code> directory to adjust the mount point and other parameters:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo nano \/nfs\/boot\/cmdline.txt<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Modify the <code>console<\/code>, <code>root<\/code>, and <code>nfsroot<\/code> parameters to match your setup:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   console=serial0,115200 console=tty1 root=\/dev\/nfs nfsroot=192.168.0.11:\/volume1\/rpi-pxe\/RPI4GB rw ip=dhcp elevator=deadline rootwait<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"8\">\n<li><strong>Update <code>\/etc\/fstab<\/code><\/strong> Edit the <code>\/etc\/fstab<\/code> file on the Raspberry Pi to update the mount points for the boot and root directories:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo nano \/nfs\/root\/etc\/fstab<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Update the entries with the appropriate paths:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   192.168.0.11:\/volume1\/rpi-tftpboot\/8eb2f324  \/boot           nfs    defaults          0       2\n   192.168.0.11:\/volume1\/rpi-pxe\/RPI4GB  \/               nfs    defaults,noatime  0       1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Conclusion<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By following these steps, you&#8217;ve successfully set up PXE boot for your Raspberry Pi devices. Network booting offers flexibility, scalability, and centralized management for your projects. This method can be particularly valuable for large-scale deployments or when you want to minimize the reliance on physical storage. Enjoy the benefits of network booting and explore new possibilities for your Raspberry Pi projects!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Title: Booting Raspberry Pi via PXE: A Guide to Network Booting Introduction Raspberry Pi, with its versatility and affordability, has become a favorite among tech enthusiasts for various projects. One of the most intriguing&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":275,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[33,9,7],"tags":[],"class_list":["post-273","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-nas","category-network","category-raspberry"],"_links":{"self":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/comments?post=273"}],"version-history":[{"count":1,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/273\/revisions"}],"predecessor-version":[{"id":274,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/273\/revisions\/274"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media\/275"}],"wp:attachment":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media?parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/categories?post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/tags?post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}