{"id":41,"date":"2011-04-30T07:49:00","date_gmt":"2011-04-29T21:49:00","guid":{"rendered":"https:\/\/www.serenux.com\/?p=41"},"modified":"2021-01-14T07:57:37","modified_gmt":"2021-01-13T21:57:37","slug":"howto-create-a-diskless-workstation-that-boots-from-pxe-using-ubuntu","status":"publish","type":"post","link":"https:\/\/www.serenux.com\/index.php\/2011\/04\/30\/howto-create-a-diskless-workstation-that-boots-from-pxe-using-ubuntu\/","title":{"rendered":"HowTo: Create a Diskless workstation that boots from PXE using Ubuntu"},"content":{"rendered":"\n<p>Diskless&nbsp;booting is where a PC starts up purely from a network connection. It does not have a physical hard-drive in it to start from in the traditional manner.<\/p>\n\n\n\n<p>Why would you want to do this? Well, say for example you have a MythTV&nbsp;Frontend&nbsp;PC. For the most part, most Frontends&nbsp;are dedicated&nbsp;PC\u2019s connected to a TV or projector that are not used for any other purpose, so technically there is really no need to have a hard-drive inside one as nothing new will ever be stored (all the media is streamed from the Backend server). There\u2019s also the added bonus of less noise by not having a hard-drive installed.<\/p>\n\n\n\n<p>Another good example of using a Diskless boot environment is for performing offline virus scans of Windows based PC\u2019s in a safe environment that is not Windows, using tools like ClamAV. In a corporate environment, having a \u201cnormal\u201d installation makes it easier to setup default settings that normally don\u2019t suit booting up from an Ubuntu Live CD, such as corporate Proxy settings. Making a Diskless Boot setup is far easier than creating a&nbsp;customised&nbsp;Live CD in this instance.<\/p>\n\n\n\n<p>So how exactly do you create a&nbsp;diskless&nbsp;booting PC?<\/p>\n\n\n\n<p><strong><em>Pre-requisites:<\/em><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>First up, you need a working PXE server. If you haven\u2019t built one yet, you can refer to my&nbsp;<a href=\"https:\/\/web.archive.org\/web\/20150310045828\/http:\/\/www.serenux.com\/2010\/05\/howto-setup-your-own-pxe-boot-server-using-ubuntu-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">previous tutorial on how to build one<\/a>.<\/li><li>Sufficient space to store a typical Ubuntu Desktop install. I would recommend having at least 10GB free to allow space for both the OS and any additional apps you might install.<\/li><li>A PC that you will&nbsp;using&nbsp;as your&nbsp;diskless&nbsp;machine that has the ability to boot from PXE.<\/li><li>A temporary hard-drive for your&nbsp;diskless&nbsp;machine that we will be using to do our initial build on.<\/li><li>A fast network.&nbsp;Diskless&nbsp;booting is only useful if your network can transfer data quickly. I would recommend that you use a gigabit network.<\/li><li>It is recommended to have at least 2GB RAM on your&nbsp;diskless&nbsp;PC, primarily because we will not be running a swap file or swap partition (swapping over a network connection is just silly).<\/li><li>Ubuntu 10.04.2 LTS&nbsp;was used&nbsp;for this tutorial, but you should be able to use just about any release of Ubuntu. Note: The version of Ubuntu on your PXE server and the version of Ubuntu you are turning into&nbsp;diskless&nbsp;boot does&nbsp;not&nbsp;have to be the same version, but I would recommend using 10.04.2 LTS or later.<\/li><\/ul>\n\n\n\n<p><strong><em>What to do:<\/em><\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>First up, install the temporary hard-disk into your PC that is going to become\u00a0diskless. You can attach it in the traditional way or connect it via USB.<br><\/li><li>Perform a normal installation of Ubuntu Desktop Edition onto the hard-drive of your PC.<br><\/li><li>Once installed, update the system with any outstanding system updates.<br><\/li><li>Install any additional apps you wish to\u00a0utilise\u00a0on this machine, such as MythTV.<br><\/li><li>Once you are satisfied that your installation is setup the way you want it, we need to prepare the installation to be able to boot via PXE. Start by opening up a terminal and type in the following commands:<br><br><code>$ cd ~<br>$ sudo nano \/etc\/initramfs-tools\/initramfs.conf<\/code><br><\/li><li>You will now be looking at a text configuration file in the Nano text editor. This is the configuration file that controls how the boot-time RAM disk image is created. We need to modify it so that we can create a PXE-ready version of the RAM disk image instead of the usual type. Scroll down until you find the configuration line that looks like:<br><br><code>MODULES=most<\/code><br><br>\u2026and modify it so that is now\u00a0looks\u00a0like:<br><br><code>MODULES=netboot<\/code><br><\/li><li>Scroll down a little further until you see the line:<br><br><code>BOOT=local<\/code><br><br>\u2026and change it to read:<br><br><code>BOOT=nfs<\/code><br><\/li><li>Press CTRL+X, then \u201cY\u201d and then \u201cEnter\u201d to save your changes. You will be returned to the Terminal prompt.<br><\/li><li>Now let\u2019s create our custom RAM Disk image using the following command:<br><br><code>$ sudo mkinitramfs -o .\/initrd.img<\/code><br><\/li><li>Once that has finished, we also need an unmodified copy of the current kernel you are running:<br><br><code>$ cp \/boot\/vmlinuz-`uname -r` .\/vmlinuz<\/code><br><\/li><li>Now we need to prep the server. First up, we need to\u00a0setup\u00a0a way to transfer our temporary hard-disk contents to the PXE server, and we also need to\u00a0ready\u00a0how the PXE server will serve the data to the diskless workstation when booting. We will be using the Network\u00a0File System, or NFS for short. On your Ubuntu PXE Server, open a terminal and type in the following:<br><br><code>$ sudo apt-get install nfs-kernel-server<\/code><br><\/li><li>Once the NFS server is installed, we need to\u00a0setup\u00a0the directory that will store and serve the Diskless system\u2019s files. Assuming you have all your PXE related data under \/srv\/tftp, let\u2019s create the following for our Diskless station data:<br><br><code>$ sudo mkdir -p \/srv\/nfs\/disklessboot<\/code><br><\/li><li>Now let\u2019s tell the NFS server about this new directory:<br><br><code>$ sudo nano \/etc\/exports<\/code><br><\/li><li>In the text file that appears in the Nano text editor, scroll to the bottom of the file and add the following line:<br><br><code>\/srv\/nfs\/disklessboot\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 *(rw,no_root_squash,async,no_subtree_check)<\/code><br><br>The above will allow read\/write access to the path \/srv\/nfs\/disklessboot\u00a0on your PXE server from any incoming IP address.<br><\/li><li>Save your changes by pressing CTRL+X, then \u201cY\u201d and then \u201cEnter\u201d.<br><\/li><li>Now activate the new NFS\u00a0shareby\u00a0using the following command:<br><br><code>$ sudo exportfs -a<\/code><br><\/li><li>We\u2019re nearly there! Now we just need to transfer the contents of our temporary workstation hard-drive to the new NFS share. On your soon-to-be-diskless\u00a0PC (not\u00a0the\u00a0server), and assuming that your PXE server\u2019s IP address is 192.168.0.10, type the following in a Terminal:<br><br><code>$ sudo apt-get install nfs-common<br>$ mkdir \/dev\/shm\/nfs<br>$ sudo mount -t nfs -nolock 192.168.0.10:\/srv\/nfs\/disklessboot \/dev\/shm\/nfs<\/code><br><br>The above will create a directory in your RAM disk to mount the PXE server\u2019s NFS share on and the second command will mount the NFS share \/srv\/nfs\/disklessboot\u00a0in the directory you just created\u00a0in\u00a0your RAM disk locally, thus allowing you to now read and write data to that NFS share by using \/dev\/shm\/nfs\u00a0locally.<br><\/li><li>Now let\u2019s copy the OS files from the temporary hard-disk to the PXE server\u2019s NFS share:<br><br><code>$ sudo cp -avx \/. \/dev\/shm\/nfs\/.<br>$ sudo cp -avx \/dev\/. \/dev\/shm\/nfs\/dev\/.<\/code><br><br>The above commands will take a minute or two to finish and will show you a giant list of files being copied.<br><\/li><li>We are now done with the soon-to-be-diskless\u00a0PC, so shut it down and remove your temporary hard-drive.<br><\/li><li>Go back to your server and type in the following at the Terminal prompt:<br><br><code>$ sudo mkdir -p \/srv\/tftp\/disklessboot<br>$ sudo cp \/srv\/nfs\/disklessboot\/home\/USERNAME\/vmlinuz \/srv\/tftp\/disklessboot\/<br>$ sudo cp \/srv\/nfs\/disklessboot\/home\/USERNAME\/initrd.img \/srv\/tftp\/disklessboot\/<\/code><br><br>Note: Replace USERNAME above with whatever your username was on the temporary hard-disk setup,\u00a0eg: \u201c\/home\/jbloggs\/\u201d<img decoding=\"async\" src=\"https:\/\/web.archive.org\/web\/20150310045828im_\/http:\/\/www.serenux.com\/wp-content\/themes\/grey-opaque\/images\/smilies\/icon_wink.gif\" alt=\"Smilie: ;)\"><br><\/li><li>We now need to change the network setup of the\u00a0disklessboot\u00a0install so that it doesn\u2019t try to configure itself with a new IP address on boot (since it\u2019ll already have one when you do the initial PXE boot):<br><br><code>$ sudo nano \/srv\/nfs\/disklessboot\/etc\/network\/interfaces<\/code><br><\/li><li>Look for a reference to \u201ceth0\u2033 which is your first\u00a0ethernetadapter. It will generally be the last line in the file and may look like:<br><br><code>auto eth0<\/code><br>\u2026or:<br><code>iface eth0 inet dhcp<\/code><br><\/li><li>Once you locate it, comment out that line by putting a hash symbol at the front like so:<br><br><code>#auto eth0<\/code><br>\u2026or:<br><code>#iface eth0 inet dhcp<\/code><br><\/li><li>Now add a new line with the following:<br><br><code>iface eth0 inet manual<\/code><br><\/li><li>Save your changes with CTRL+X, then \u201cY\u201d and then \u201cEnter\u201d.<br><\/li><li>Now we need to ensure that the devices mounted by your\u00a0disklessbooting\u00a0PC do not try to mount physical disk devices for things like \/home and the root filesystem. Type in the following command:<br><br><code>$ sudo nano \/srv\/nfs\/disklessboot\/etc\/fstab<\/code><br><\/li><li>Once in the text editor, DELETE EVERYTHING and replace it all with the following:<br><br><code>proc\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/proc\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 proc\u00a0\u00a0\u00a0 defaults\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<br>\/dev\/nfs\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \/\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 nfs\u00a0\u00a0 \u00a0 defaults\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1<br>none\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/tmp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0 defaults\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<br>none\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/var\/run\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0 defaults\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<br>none\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/var\/lock\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0 defaults\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<br>none\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/var\/tmp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 tmpfs\u00a0\u00a0 defaults\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0<\/code><br><\/li><li>Save your changes with CTRL+X, then \u201cY\u201d and then \u201cEnter\u201d.<br><\/li><li>That\u2019s the Diskless setup ready to go. All that we now need to do is configure the PXE boot menu to give you an option to boot Diskless. To do this, edit your PXE boot menu configuration file. Assuming you called it \/srv\/tftp\/mybootmenu.cfg, type in the following:<br><br><code>$ sudo nano \/srv\/tftp\/mybootmenu.cfg<\/code><br><\/li><li>In the text editor, scroll down to the bottom of your configuration file and add the following lines:<br><br><code>label My Diskless Boot PC<br>kernel disklessboot\/vmlinuz<br>append initrd=disklessboot\/initrd.img root=\/dev\/nfs nfsroot=192.168.0.10:\/srv\/nfs\/disklessboot ip=dhcp rw<\/code><br><br>The above menu configuration will tell PXE to load the kernel and custom RAM disk image from the TFTP directory and then transfer control of the boot process to the OS files located in \/srv\/nfs\/disklessboot\u00a0which will be mounted on the\u00a0diskless\u00a0system at \/dev\/nfs\u00a0as the root filesystem.<br><\/li><li>Save your changes by pressing CTRL+X, then \u201cY\u201d and then \u201cEnter\u201d.<br><\/li><li>Finally, make sure that the TFTP daemon can read the new files you added to it with the following command:<br><br><code>$ sudo chmod 777 -R \/srv\/tftp<\/code><br><\/li><li>That\u2019s it! You are now ready to boot! Turn on your now-diskless\u00a0PC and tell it to boot from PXE. When the PXE boot menu appears, choose \u201cMy Diskless Boot PC\u201d and watch in wonder and amazement as Ubuntu boots up without a hard-disk as if by magic!<\/li><\/ol>\n\n\n\n<p>NOTE: Whilst the Diskless PC will boot and operate much like any ordinary PC and in fact you can indeed perform future system updates this way, be aware that the kernel itself will NOT get automatically updated. Newer kernels will get installed to the NFS mount as you would expect, however the kernel actually boots from your TFTP directory, not the NFS share, so if you do update the kernel in&nbsp;future, you must create a new RAM disk image manually as per step 9 and copy both it and the new kernel file into your TFTP\u2019s directory (in this case \/srv\/tftp\/disklessboot\/) otherwise your updated system will not boot anymore. Alternatively, simply allow all updates to be performed&nbsp;except&nbsp;for kernel updates.<\/p>\n\n\n\n<p>Finally, hardware drivers: If you install the&nbsp;NVidia&nbsp;proprietary drivers for your Diskless Boot system, ensure that you don\u2019t try to boot other systems that do not contain&nbsp;NVidia graphics hardware&nbsp;otherwise X will break. The reason for this is that the&nbsp;NVidia&nbsp;driver installation makes a number of changes to&nbsp;system-level libraries to work, effectively binding that system to&nbsp;NVidia&nbsp;graphics-based systems only. If you intend to use your Diskless setup on multiple hardware platforms, such as&nbsp;NVidia, Intel and ATi, do not install the proprietary&nbsp;NVidia&nbsp;(or ATi) driver.<\/p>\n\n\n\n<p>Enjoy!&nbsp;<img decoding=\"async\" src=\"https:\/\/web.archive.org\/web\/20150310045828im_\/http:\/\/www.serenux.com\/wp-content\/themes\/grey-opaque\/images\/smilies\/icon_smile.gif\" alt=\"Smilie: :)\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Diskless&nbsp;booting is where a PC starts up purely from a network connection. It does not have a physical hard-drive in it to start from in the traditional manner. Why would you want to do this? Well, say for example you have a MythTV&nbsp;Frontend&nbsp;PC. For the most part, most Frontends&nbsp;are dedicated&nbsp;PC\u2019s connected to a TV or [&hellip;]<\/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-41","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":1,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":42,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/posts\/41\/revisions\/42"}],"wp:attachment":[{"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.serenux.com\/index.php\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}