{"id":22,"date":"2020-08-10T13:00:00","date_gmt":"2020-08-10T13:00:00","guid":{"rendered":"http:\/\/10.171.10.16:10000\/?p=22"},"modified":"2022-01-16T17:15:08","modified_gmt":"2022-01-16T17:15:08","slug":"efweftrertert","status":"publish","type":"post","link":"https:\/\/dannypayne.me\/?p=22","title":{"rendered":"Adding entries to PXE boot menu"},"content":{"rendered":"\n<p>This post is the second in a series on building\/setting up\/improving a PXE boot server with CentOS.<br>By the end of this post, we&#8217;ll have added a handful of useful tools to our PXE menu, including Clonezilla and GParted. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">To get things started<\/h3>\n\n\n\n<p>First of all, we&#8217;re going to need to make sure we have the <code>unzip<\/code> package installed, if it&#8217;s not installed, simply run <code>yum install -y unzip<\/code> and then we can proceed. <br>We&#8217;re going to need to find the correct download links for the tools we&#8217;re going to add:<br>&#8211; Ntpasswd &#8211; <a rel=\"noreferrer noopener\" href=\"https:\/\/pogostick.net\/~pnh\/ntpasswd\/\" target=\"_blank\">LINK<\/a><br>&#8211; GParted &#8211; <a rel=\"noreferrer noopener\" href=\"https:\/\/gparted.org\/download.php\" target=\"_blank\">LINK<\/a><br>&#8211; CloneZilla &#8211; <a rel=\"noreferrer noopener\" href=\"https:\/\/clonezilla.org\/downloads\/download.php?branch=stable\" target=\"_blank\">LINK<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Downloading and moving files<\/h3>\n\n\n\n<p>At the time of writing this post, the below links are the latest to each file. We can quickly download them by running the following commands. Note that our working directory is <code>\/root<\/code> or <code>~<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">wget http:\/\/pogostick.net\/~pnh\/ntpasswd\/usb140201.zip\nwget https:\/\/kumisystems.dl.sourceforge.net\/project\/gparted\/gparted-live-stable\/1.1.0-5\/gparted-live-1.1.0-5-amd64.zip\nwget https:\/\/osdn.net\/dl\/clonezilla\/clonezilla-live-2.6.6-9-amd64.zip<\/code><\/pre>\n\n\n\n<p>Once you&#8217;ve downloaded the files, extract them into their own folders as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">unzip usb140201.zip -d ntpasswd\nunzip gparted-live-1.1.0-5-amd64.zip -d gparted\nunzip clonezilla-live-2.6.6-9-amd64.zip -d clonezilla<\/code><\/pre>\n\n\n\n<p>Next, we&#8217;re going to create some directories for the files we just extracted. The best way I&#8217;ve found to deal with storing the files it to put them in separate folders as each bootable OS has files with the same names;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">mkdir \/var\/lib\/tftpboot\/ntpasswd\nmkdir \/var\/lib\/tftpboot\/gparted\nmkdir \/var\/lib\/tftpboot\/clonezilla\n\nmkdir \/var\/ftp\/gparted\nmkdir \/var\/ftp\/clonezilla<\/code><\/pre>\n\n\n\n<p>For Clonezilla and Gparted we&#8217;ll want to do the following:<br>Inside the extracted ISO&#8217;s folder, find the <code>live<\/code> folder. Inside you&#8217;ll need to copy the <code>initrd.img<\/code> and <code>vmlinuz<\/code> files out to their respective directories<br>For ntpasswd we need to copy the following files: <code>initrd.cgz<\/code>,<code>scsi.cgz<\/code> and <code>vmlinuz<\/code>.<br><br>We&#8217;re basically copying the boot files into the tftp location so they can be referenced in the PXE boot menu, and copying the <code>filesystem.squashfs<\/code> files to a location where they can be pulled via FTP once the OS has started booting. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">cp clonezilla\/live\/{initrd.img,vmlinuz} \/var\/lib\/tftpboot\/clonezilla\/\ncp clonezilla\/live\/filesystem.squashfs \/var\/ftp\/clonezilla\/\n\ncp gparted\/live\/{initrd.img,vmlinuz} \/var\/lib\/tftpboot\/gparted\/\ncp gparted\/live\/filesystem.squashfs \/var\/ftp\/gparted\/\n\ncp ntpasswd\/{initrd.cgz,scsi.cgz,vmlinuz} \/var\/lib\/tftpboot\/ntpasswd\/<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Edit\/update PXE boot menu<\/h3>\n\n\n\n<p>To make our PXE menu a bit tidier, we&#8217;re going to create another menu file and reference that in our <em>original <\/em>file. <br>First, we&#8217;re going to edit the original menu located at <code>\/var\/lib\/tftpboot\/pxelinux.cfg\/default<\/code> and add the following to the bottom:<\/p>\n\n\n\n<pre title=\"\/var\/lib\/tftpboot\/pxelinux.cfg\/default\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">LABEL Tools\nMENU LABEL Tools\nKERNEL menu.c32\nAPPEND pxelinux.cfg\/tools<\/code><\/pre>\n\n\n\n<p>This allows us to select the Tools sub-menu and enter it <br>Next, we need to create the tools file and enter the following:<\/p>\n\n\n\n<pre title=\"\/var\/lib\/tftpboot\/pxelinux.cfg\/tools\" class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">MENU TITLE ########## PXE Tools Menu ##########\n\nLABEL Back to Main Menu\nMENU LABEL Main Menu\nKERNEL menu.c32\nAPPEND pxelinux.cfg\/default\n\nLABEL ntpasswd\nMENU LABEL ^1. NT Password and Registry Editor\nkernel ntpasswd\/vmlinuz\nappend rw vga=1 initrd=ntpasswd\/initrd.cgz,ntpasswd\/scsi.cgz\n\nlabel GParted Live\nMENU LABEL ^2. GParted Live\nkernel gparted\/vmlinuz\nappend initrd=gparted\/initrd.img boot=live config components union=overlay username=user noswap noeject ip= vga=788 locales=en_US keyboard-layouts=en_US.UTF-8 fetch=ftp:\/\/10.176.40.10\/gparted\/filesystem.squashfs\n\nlabel Clonezilla Live\nMENU LABEL ^3. Clonezilla Live\nKERNEL clonezilla\/vmlinuz\nAPPEND initrd=clonezilla\/initrd.img boot=live username=user union=overlay config components quiet noswap edd=on nomodeset nodmraid keyboard-layouts=en locales=en_US.UTF-8 ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\" ocs_live_batch=no net.ifnames=0 nosplash noprompt fetch=ftp:\/\/10.176.40.10\/clonezilla\/filesystem.squashfs\n<\/code><\/pre>\n\n\n\n<p>If you want to use this file, you&#8217;ll need to replace the IP address (<code>10.176.40.10<\/code>) with the IP of your own PXE boot server. <br>Essentially what&#8217;s happening here, is that we&#8217;ve got 4 menu items. The top one takes us back to the original <code>default<\/code> PXE menu, and the rest are for launching the items. <br><br>Each menu item points to the corresponding kernel that we copied earlier, and we&#8217;re appending each item with some extra options to help the live OS boot correctly and also set some options like the keyboard layout and OS language. Sources <a rel=\"noreferrer noopener\" href=\"https:\/\/gparted.org\/livepxe.php\" target=\"_blank\">HERE<\/a> and <a rel=\"noreferrer noopener\" href=\"https:\/\/clonezilla.org\/livepxe.php\" target=\"_blank\">HERE<\/a>.<\/p>\n\n\n\n<p>If we now fire up a test machine and PXE boot, we should have the additional <strong>tools<\/strong> menu item, and when we select it, we&#8217;ll be presented with our new bootable tools.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"400\" src=\"http:\/\/10.171.10.16:10000\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-48-54.png\" alt=\"\" class=\"wp-image-125\" srcset=\"https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-48-54.png 720w, https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-48-54-300x167.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><figcaption><br><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"400\" src=\"http:\/\/10.171.10.16:10000\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-49-02.png\" alt=\"\" class=\"wp-image-126\" srcset=\"https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-49-02.png 720w, https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-49-02-300x167.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/figure>\n\n\n\n<p>If I was to now select <strong>GParted Live<\/strong> and boot to it, after a few moments we should be presented with the live OS<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"http:\/\/10.171.10.16:10000\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-51-05.png\" alt=\"\" class=\"wp-image-127\" srcset=\"https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-51-05.png 800w, https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-51-05-300x225.png 300w, https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-51-05-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<p>Similarly, if we boot Clonezilla, after a few moments we&#8217;ll land at the Clonezilla welcome screen<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"720\" height=\"400\" src=\"http:\/\/10.171.10.16:10000\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-56-41.png\" alt=\"\" class=\"wp-image-130\" srcset=\"https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-56-41.png 720w, https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/08\/B-PXEBOOT-2020-08-11-21-56-41-300x167.png 300w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Wrapping up<\/h3>\n\n\n\n<p>In this post we&#8217;ve covered modifying our existing PXE boot menu config and creating a new menu file to include useful tools like GParted and Clonezilla, and we&#8217;re now able to boot and use these tools without needing to copy their ISO&#8217;s to our ESXi hosts datastore or making a bootable USB drive in the case of a physical machine. <br><br>In the next post, I&#8217;m going to cover modifying our kickstart file some more to allow random generation of our root password and to automate the setup of services like <code>ssmtp<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is the second in a series on building\/setting up\/improving a PXE boot server with CentOS.<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/dannypayne.me\/?p=22\">Read more<span class=\"screen-reader-text\">Adding entries to PXE boot menu<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":139,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[12,6],"tags":[],"class_list":["post-22","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-archive","category-homelab","excerpt","zoom","full-without-featured","even","excerpt-0"],"jetpack_featured_media_url":"https:\/\/dannypayne.me\/wp-content\/uploads\/2020\/07\/B-PXEBOOT-2020-08-11-21-49-02-e1597247814179.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/dannypayne.me\/index.php?rest_route=\/wp\/v2\/posts\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dannypayne.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dannypayne.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dannypayne.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dannypayne.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22"}],"version-history":[{"count":12,"href":"https:\/\/dannypayne.me\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":182,"href":"https:\/\/dannypayne.me\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions\/182"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dannypayne.me\/index.php?rest_route=\/wp\/v2\/media\/139"}],"wp:attachment":[{"href":"https:\/\/dannypayne.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dannypayne.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dannypayne.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}