HowTo: Create a Diskless workstation that boots from PXE using Ubuntu
Diskless 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 Frontend PC. For the most part, most Frontends are dedicated PC’s 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’s also the added bonus of less noise by not having a hard-drive installed.
Another good example of using a Diskless boot environment is for performing offline virus scans of Windows based PC’s in a safe environment that is not Windows, using tools like ClamAV. In a corporate environment, having a “normal” installation makes it easier to setup default settings that normally don’t suit booting up from an Ubuntu Live CD, such as corporate Proxy settings. Making a Diskless Boot setup is far easier than creating a customised Live CD in this instance.
So how exactly do you create a diskless booting PC?
Pre-requisites:
- First up, you need a working PXE server. If you haven’t built one yet, you can refer to my previous tutorial on how to build one.
- 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.
- A PC that you will using as your diskless machine that has the ability to boot from PXE.
- A temporary hard-drive for your diskless machine that we will be using to do our initial build on.
- A fast network. Diskless booting is only useful if your network can transfer data quickly. I would recommend that you use a gigabit network.
- It is recommended to have at least 2GB RAM on your diskless PC, primarily because we will not be running a swap file or swap partition (swapping over a network connection is just silly).
- Ubuntu 10.04.2 LTS was used 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 diskless boot does not have to be the same version, but I would recommend using 10.04.2 LTS or later.
What to do:
- First up, install the temporary hard-disk into your PC that is going to become diskless. You can attach it in the traditional way or connect it via USB.
. - Perform a normal installation of Ubuntu Desktop Edition onto the hard-drive of your PC.
. - Once installed, update the system with any outstanding system updates.
. - Install any additional apps you wish to utilise on this machine, such as MythTV.
. - 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:
$ cd ~ $ sudo nano /etc/initramfs-tools/initramfs.conf - 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:
MODULES=most…and modify it so that is now looks like:
MODULES=netboot - Scroll down a little further until you see the line:
BOOT=local…and change it to read:
BOOT=nfs - Press CTRL+X, then “Y” and then “Enter” to save your changes. You will be returned to the Terminal prompt.
. - Now let’s create our custom RAM Disk image using the following command:
$ sudo mkinitramfs -o ./initrd.img - Once that has finished, we also need an unmodified copy of the current kernel you are running:
$ cp /boot/vmlinuz-`uname -r` ./vmlinuz - Now we need to prep the server. First up, we need to setup a way to transfer our temporary hard-disk contents to the PXE server, and we also need to ready how the PXE server will serve the data to the diskless workstation when booting. We will be using the Network FileSystem or NFS for short. On your Ubuntu PXE Server, open a terminal and type in the following:
$ sudo apt-get install nfs-kernel-server - Once the NFS server is installed, we need to setup the directory that will store and serve the Diskless system’s files. Assuming you have all your PXE related data under /srv/tftp, let’s create the following for our Diskless station data:
$ sudo mkdir -p /srv/nfs/disklessboot - Now let’s tell the NFS server about this new directory:
$ sudo nano /etc/exports - In the text file that appears in the Nano text editor, scroll to the bottom of the file and add the following line:
/srv/nfs/disklessboot *(rw,no_root_squash,async,no_subtree_check)The above will allow read/write access to the path /srv/nfs/disklessboot on your PXE server from any incoming IP address.
- Save your changes by pressing CTRL+X, then “Y” and then “Enter”.
. - Now activate the new NFS share by using the following command:
$ sudo exportfs -a - We’re 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 PC (notthe server), and assuming that your PXE server’s IP address is 192.168.0.10, type the following in a Terminal:
$ mkdir /dev/shm/nfs $ sudo mount -t nfs -onolock 192.168.0.10:/srv/nfs/disklessboot /dev/shm/nfsThe above will create a directory in your RAM disk to mount the PXE server’s NFS share on and the second command will mount the NFS share /srv/nfs/disklessboot in the directory you just created in your RAM disk locally, thus allowing you to now read and write data to that NFS share by using /dev/shm/nfs locally.
- Now let’s copy the OS files from the temporary hard-disk to the PXE server’s NFS share:
$ sudo cp -avx /. /dev/shm/nfs/. $ sudo cp -avx /dev/. /dev/shm/nfs/dev/.The above commands will take a minute or two to finish and will show you a giant list of files being copied.
- We are now done with the soon-to-be-diskless PC, so shut it down and remove your temporary hard-drive.
. - Go back to your server and type in the following at the Terminal prompt:
$ sudo mkdir -p /srv/tftp/disklessboot $ sudo cp /srv/nfs/disklessboot/home/USERNAME/vmlinuz /srv/tftp/disklessboot/ $ sudo cp /srv/nfs/disklessboot/home/USERNAME/initrd.img /srv/tftp/disklessboot/Note: Replace USERNAME above with whatever your username was on the temporary hard-disk setup, eg: “/home/jbloggs/”)
- We now need to change the network setup of the diskless boot install so that it doesn’t try to configure itself with a new IP address on boot (since it’ll already have one when you do the initial PXE boot):
$ sudo nano /srv/nfs/disklessboot/etc/network/interfaces - Look for a reference to “eth0″ which is your first ethernet adapter. It will generally be the last line in the file and may look like:
auto eth0…or:
iface eth0 inet dhcp - Once you locate it, comment out that line by putting a hash symbol at the front like so:
#auto eth0…or:
#iface eth0 inet dhcp - Now add a new line with the following:
iface eth0 inet manual - Save your changes with CTRL+X, then “Y” and then “Enter”.
. - Now we need to ensure that the devices mounted by your diskless booting PC do not try to mount physical disk devices for things like /home and the root filesystem. Type in the following command:
$ sudo nano /srv/nfs/disklessboot/etc/fstab - Once in the text editor, DELETE EVERYTHING and replace it all with the following:
proc /proc proc defaults 0 0 /dev/nfs / nfs defaults 1 1 none /tmp tmpfs defaults 0 0 none /var/run tmpfs defaults 0 0 none /var/lock tmpfs defaults 0 0 none /var/tmp tmpfs defaults 0 0 - Save your changes with CTRL+X, then “Y” and then “Enter”.
. - That’s 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:
$ sudo nano /srv/tftp/mybootmenu.cfg - In the text editor, scroll down to the bottom of your configuration file and add the following lines:
label My Diskless Boot PC kernel disklessboot/vmlinuz append initrd=disklessboot/initrd.img root=/dev/nfs nfsroot=192.168.0.10:/srv/nfs/disklessboot ip=dhcp rwThe 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 which will be mounted on the diskless system at /dev/nfs as the root filesystem.
- Save your changes by pressing CTRL+X, then “Y” and then “Enter”.
. - Finally, make sure that the TFTP daemon can read the new files you added to it with the following command:
$ sudo chmod 777 -R /srv/tftp - That’s it! You are now ready to boot! Turn on your now-diskless PC and tell it to boot from PXE. When the PXE boot menu appears, choose “My Diskless Boot PC” and watch in wonder and amazement as Ubuntu boots up without a hard-disk as if by magic!
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 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’s directory (in this case /srv/tftp/disklessboot/) otherwise your updated system will not boot anymore. Alternatively, simply allow all updates to be performed except for kernel updates.
Finally, hardware drivers: If you install the NVidia proprietary drivers for your Diskless Boot system, ensure that you don’t try to boot other systems that do not contain NVidia graphics hardware otherwise X will break. The reason for this is that the NVidia driver installation makes a number of changes to system-level libraries to work, effectively binding that system to NVidia graphics-based systems only. If you intend to use your Diskless setup on multiple hardware platforms, such as NVidia, Intel and ATi, do not install the proprietary NVidia (or ATi) driver.
Enjoy!



Hi there.
Thanks so much for this walkthrough, it was very helpful in setting up my own system.
I think you made a mistake in step 14 though. When editing the /etc/exports file, the IP address should not be the IP address of the server, but the IP address of the diskless client, or “192.168.0.*”, corresponding to all machines on the local network.
I suppose the only way to know the IP address of the client is to give it a static lease in the DHCP server configuration.
Actually that part should read just an asterisk, not an IP address (unless you want to restrict it down for security etc).
Well spotted! Fixed.
Hi !
Thanks for the tutorial, all in all it seems to work for me except the final boot ^^
On the diskless machine, I’m able to reach the boot menu, then to run the diskless stuff.
vmlinuz & initram are loaded, then the last lines I see are an error message complaining about “… phy0 : hardware not responding” then the terminal asking for a login and from this point black screen and nothing else…
Do you have any cue about how to solve this issue ?
up : after a bit of struggling (I’m windows user… ^^’) I managed to boot in text mode and there I can access the diskless system.
However if i type startx I got rejected with “Cannot open /dev/tty0 no such file or directory”…
Sounds to me that your initrd has not been built correctly, ie: it might still be looking for a physical disk instead of doing a network boot. Try rebuilding your initrd and see what happens.
What are you trying to boot diskless – Ubuntu?
Hi, I’m trying to boot ubuntu 11.04 yes.
In fact when I copy the system to the server I got on all file the message :
cp: failed to preserve ownership
could it be a reason of my problem?
Most likely, yes – I imagine that the boot process literally has not got permission to read critical boot files, hence you don’t boot very far.
As an experiment, try setting global read/write access for everyone on all your NFS diskless boot files, ie: sudo chmod 777 -R /srv/nfs/disklessboot (if you did the same paths as my guide) and see if the system magically boots up. If it does, then change the permissions to 755 instead so it’s a little more secure and repeat the test.
Great ! The system boots magically ^^
I tried with 755 and I got an error message, although everything seems to work fine.
I’ll stay with 777 since the configuration is within a local lab network, it should be safe…
Anyway, thank you very much for your tuto ! You helped even a completely linux noob xD
gud day sir! hi im from Philippines, sir im very much interested in diskless, here in our country HDD are expensive and i have a micro business internet shop at least 11units only, i want to learn step by step how to create/build a diskless system. im not very good enough to understand some terms about programming but with your friendly step by step it would really HELP a LOT! im using WinXp and i want put a “menu” for lan games, on line games, mini games for kids. somebody offer here their services in diskless but i want learn on my own though im a newbie in programming…. sir can you help me? thank you! (pls email me…)
joel lim
Philippines
Unfortunately these instructions are only for Linux operating systems – you cannot make Windows boot diskless due to the restrictive nature of that operating system. The closest you will get is a remote terminal session on a Windows server, but you can’t play much more than solitaire in that.
hello, how are you?
i want to ask questions about diskless
if u can help me please send a msg to me at my email [DELETED]
Sorry – I don’t do email correspondence due to not being a tech support service nor wanting to have my email address spammed. I’ve also deleted your email address in your comment so no spam bots can scrape it.
good day sir!
is it possible to run a 20+ units in one server. with a dual os(linux,windows)on my high end server. i heard some rumor about michealsoft dds diskless node that can run mass of units that can play heavy games with dual os on it’s server. the server is linux and the client is running in windows xp. are they using ccboot or pxe? and last Q. do your tutorial above can perform like michealsoft? thank you
Unless it’s some kind of remote terminal service, Windows cannot run off PXE and neither can Windows games. Besides that, short of running 10x gigabit on your LAN, it’d be too slow for loading large modern game data anyway.
While you can definitely boot multiple Linux diskless stations with one setup, I would suggest they do it as read-only so they don’t stomp all over each other when settings/preferences within your Linux setup are changed.
On step 17 I had a problem with the Mount command giving me an error about bad fs etc…
I solved it by installing the nfs-common package. FYI…
Step 11′s install of the NFS Server should install nfs-common for you as it’s a dependency.
I have a problem with sudo when using the thin client. it gives me the following massge:
sudo: must be setuid root
Basically, I can’t do anything the requiers su permission. Any advice?
Got it sorted by changing the premissions on server side using:
chown root:root /usr/bin/sudo
chmod 4755 /usr/bin/sudo
chmod 0440 /etc/sudoers
Now I have access to sudo. There another problem that I think is related and that is I can’t install sodtware from the Ubuntu Software Center. I click INSTALL but it doesn’t pop up the usual dialog asking me for my password. Any advice on that?
Not quite sure what you are doing differently, but for me the whole setup works identically to a normal setup other than installation of new kernels which will require you to make a new initrd for the PXE server.
Given what you’ve discovered, are the permissions for all the diskless files set correctly on your server? If you can’t install new packages, then that suggests you are not able to write to the NFS drive.
I’ve set the permission for all diskless files to 777. Then, I changed the permission of sudo and sudoers. I can install packages from the terminal and I can execute commands using sudo but it seems that if I try to do stuff that requires su permission OUTSIDE of the terminal, for example: installing software from ubuntu software center, I don’t get a dialog box asking me to enter my password. I have no idea why…
I’ve run software-center from terminal using sudo. When I tried to install a package (7zip) still nothing happens. Here’s a pastebin from terminal: http://pastebin.com/y1pfcjMt
Technically the sudo command shouldn’t be used for GUI apps. Did you try using gksudo?
Sadly I am unable to reproduce your problem. Everything works fine for me.
OK, I’ve managed to solve the problem by reinstalling dsub and running software-center as su. If I try to run it the usual way, the dialog asking me to enter my password appears but then instantly disappears, it kind of flickers… Guess it will have to do.
Thank you, great instructions! Very complete and at the same time easy to follow.
I also was affected by the same problem as Stéphane (cp: failed to preserve ownership, invalid argument) while copying the system to the NFS share. This is a configuration problem with NFSv4 on Oneiric that should be fixed in Precise Pangolin (see here: https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/662711) and prevents the diskless system to boot correctly.
The workaround looks like this (do following steps on BOTH the NFS server and the client):
sudo nano /etc/default/nfs-common
NEED_STATD=no
NEED_IDMAPD=yes
Save by pressing CTRL+X, then “Y” and then “Enter”
sudo service idmapd restart || sudo service idmapd start
Also, I want to remind that the option no_root_squash in /etc/exports is VERY important for this to work.
Ah! And of course, remount the share afterwards!
.. HELP .. i am stuck at
/srv/nfs/disklessboot *(rw,no_root_squash,async)
once i run the exportfs -a command ..
it says ” exportfs: /etc/exports [2]: Neither ‘subtree_check’ or ‘no_subtree_check’ specified for export “*:/srv/nfs/disklessboot”.
Assuming default behaviour (‘no_subtree_check’).
NOTE: this default has changed since nfs-utils version 1.0.x”
…. i googled few place and change it to
/srv/nfs/disklessboot *(rw,async,no_subtree_check)
it works .. but then later when i boot the diskless system …
i ended up with ” /dev/nfs/ does not exist. Dropping to a shell ..
googled again … he says somewhere error on the /etc/export …
How now … ??
why is ” /srv/nfs/disklessboot *(rw,no_root_squash,async) ” … ending up with the error …
I’ve updated step 14 to reflect the required changes for the current release of NFS – just add “no_subtree_check” to the parameters and you’ll be fine. You MUST have “no_root_squash” specified as well – that’s what’s stuffing you around right now.
The error you were originally getting was simply informing you of the missing parameter – it wasn’t falling over altogether. It was working fine.