{"id":88,"date":"2025-01-14T16:38:23","date_gmt":"2025-01-14T22:38:23","guid":{"rendered":"https:\/\/www.eeinc.us\/homelab\/?p=88"},"modified":"2025-01-14T16:43:31","modified_gmt":"2025-01-14T22:43:31","slug":"deploying-rocky-linux-9-5-via-pxe","status":"publish","type":"post","link":"https:\/\/homelab.eeinc.us\/index.php\/2025\/01\/14\/deploying-rocky-linux-9-5-via-pxe\/","title":{"rendered":"Deploying Rocky Linux 9.5 via PXE"},"content":{"rendered":"\n<p>In my home lab, I&#8217;m constantly [re]installing VMs for the various testing I am doing.  It gets annoying having to mount the OS ISO in the VM to perform the install.  Therefore, I created a PXE server so I could perform a network install of Rocky Linux 9.5.  This document lists the configuration I performed to make it successful.<\/p>\n\n\n\n<p>In my environment, I am using OpnSense as a router. My management interface is <code>[Mgmt]<\/code> and has an IP address of 172.16.103.1. My management server, also running Rocky Linux 9.5, is named <code>mgmtsrv.mydomain.com<\/code> and has an IP address of 172.16.103.11.  My OS firewall zone is named <code>mgmt<\/code>.  In this scenario I will use OpnSense as my DHCP server and my management server as my TFTP server and HTTP server for sharing files.  All of the commands executed below are from a root login.<\/p>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;I know, I know, you really should login in as a user account and use sudo for running most of these commands. However, since this is a lab, I prefer to take a shortcut. You do you.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Configure the management server<\/h4>\n\n\n\n<p>(1) Install the TFTP and HTTP services:<\/p>\n\n\n\n<p><code>dnf -y install tftpd-server httpd<\/code><\/p>\n\n\n\n<p>(2) Open the necessary ports for TFTP and HTTP:<\/p>\n\n\n\n<p><code>firewall-cmd --permanent --zone mgmt --add-service tftp<\/code><br><code>firewall-cmd --permanent --zone mgmt --add-service http<\/code><\/p>\n\n\n\n<p>(3) Mount Rocky Linux 9.5 DVD and copy the files to the TFTP directory:<\/p>\n\n\n\n<p><code>mount -o loop \/tmp\/Rocky-9.5-x86_64-dvd.iso \/media<br>cp -ra \/media\/EFI \/var\/lib\/tftpboot<br>cp -ra \/media\/images \/var\/lib\/tftpboot<\/code><\/p>\n\n\n\n<p>(4) I needed to change some access and update SELinux to get it to work, so lets go ahead and do that now:<\/p>\n\n\n\n<p><code>chmod -R 755 \/var\/lib\/tftpboot<br>ausearch -c 'in.tftpd' --raw | audit2allow -M my-intftpd<br>semodule -X 300 -i my-intftpd.pp<\/code><\/p>\n\n\n\n<p>(5) Next, lets update the <code>grub.cfg<\/code> file to point to the files on the HTTP server:<\/p>\n\n\n\n<p><code>vim \/var\/lib\/tftpboot\/EFI\/BOOT\/grub.cfg<\/code><\/p>\n\n\n\n<p>(6) Add the new menu item at the top (under ### BEGIN ###) in case you just want to boot normally:<\/p>\n\n\n\n<p><code>menuentry \"Boot Local\" {<br>exit<br>}<\/code><\/p>\n\n\n\n<p>(7) For each of the existing menu entries, add <code>inst.repo=http:\/\/172.16.103.11\/Rocky-9.5-x86_64<\/code> on the <code>vmlinuz<\/code> line. Also, change <code>inst.stage2<\/code> to <code>http:\/\/172.16.103.11\/Rocky-9.5-x86_64<\/code>.<\/p>\n\n\n\n<p>Save these changes.  You can also create system-specific boot loaders by copying the <code>grub.cfg<\/code> file to <code>grub.cfg-01-<em>mac_address<\/em><\/code>.  For example:<\/p>\n\n\n\n<p><code>cp grub.cfg grub.cfg-01-00-0c-29-a8-cc-33<\/code><\/p>\n\n\n\n<p>(8) Now, copy the contents of the Rocky Linux DVD into the HTML base directory:<\/p>\n\n\n\n<p><code>mkdir \/var\/www\/html\/Rocky-9.5-x86_64<br>cp -ra \/media\/* \/var\/www\/html\/Rocky-9.5-x86_64<\/code><\/p>\n\n\n\n<p><strong>Note:<\/strong> make sure the files <code>.discinfo<\/code> and <code>.treeinfo<\/code> are copied<\/p>\n\n\n\n<p>(9) Enable both the TFTP and HTTP services:<\/p>\n\n\n\n<p><code>systemctl enable --now tftp.socket<br>systemctl enable --now httpd<\/code><\/p>\n\n\n\n<p><strong>Note:<\/strong> a lot of references I found said to rename <code>tftp.socket<\/code> and <code>tftp.service<\/code> to <code>tftp-server.socket<\/code> and <code>tftp-server.service<\/code>.  However, the Red Hat documentation didn&#8217;t mention that, and it worked following Red Hat&#8217;s documentation, so I stuck with that.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Configure the OpnSense Server<\/h4>\n\n\n\n<p>(1) On the OpnSense server, navigate to Services &#8211;&gt; ISC DHCPv4 &#8211;&gt; [Mgmt] &#8211;&gt; Network booting and click <strong>Advanced<\/strong>.<\/p>\n\n\n\n<p>(2) Mark the checkbox beside <strong>Enable network booting<\/strong>.<\/p>\n\n\n\n<p>(3) <strong>Set next-server IP<\/strong> to <code>172.16.103.11<\/code><\/p>\n\n\n\n<p>(4) <strong>Set x64 UEFI\/EBC (64-bit) filename<\/strong> to <code>\/EFI\/BOOT\/grubx64.efi<\/code><\/p>\n\n\n\n<p>(5) Click <strong>Save<\/strong><\/p>\n\n\n\n<p>(6) In the upper right-hand of the UI, restart the service.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Test the install<\/h4>\n\n\n\n<p>Power on the VM and you should see the system start to load the Rocky Linux installation.  You can watch the TFTP messages (e.g. <code>tail -f \/var\/log\/messages<\/code>) and the HTTP messages (e.g. <code>tail -f \/var\/log\/messages\/http\/access<\/code>) to see the files being copied.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my home lab, I&#8217;m constantly [re]installing VMs for the various testing I am doing. It gets annoying having to mount the OS ISO in the VM to perform the install. Therefore, I created a PXE server so I could perform a network install of Rocky Linux 9.5. This document lists the configuration I performed<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":7,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":95,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions\/95"}],"wp:attachment":[{"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}