Installing Linux over network (no CDROM drive)

Wednesday, 9 January 2008, michuk

Installing Linux is trivial nowadays. You just need to download ISO image, burn it on CD/DVD and reboot the machine. But, what if… the computer doesn’t have a CD drive? Well, don’t worry. In such case you can install Linux directly through the net. This is called PXE and in this article you’ll learn how to use it.

Author: Borys Musielak

The problem — although it does not concern all of us — is not taken from outer space. It actually exists even in case of modern laptops, like Thinkpad X61, which lack a CD drive to save on weight. Installing Linux over network is one of the few options in such case. But it is handy also in more conventional situations. It’s generally faster (downloading and installing can be done in parallel), cheaper (you don’t need to burn a CD/DVD) and of course ozone-friendly :)

Well, so let’s get it working then! Here is what you need:

  • a computer connected to Internet (called from now on: the server) with any distribution of GNU/Linux installed (I used a Debian system here),
  • second computer (the client) on which we want to install Linux, it needs to be placed in the same network as the server and its BIOS need to provide a network boot option (usually called PXE),
  • files needed for netboot,
  • about one hour free,
  • pizza and coke.

Download netboot files

Netboot is tiny installation image, usually a single file, which is used to load the essential installation modules and connect to the Internet to download the rest of the installation files and packages. It is usually downloadable for any install-worthy distributions. It should be also located on the real installation ISO, especially in catalog called netboot.

Netboot for Ubuntu 7.10 can be downloaded (do this on server computer of course) by issuing the command: wget Next you need to unpack it: tar zxf netboot.tar.gz and place in a selected catalog. In our case it is /home/johnny/netboot.

The procedure is similar for any other distribution, however I won’t help you with the localization of the netboot image. Fortunately, my friend knows the answer and all you need to do is ask him for it. She’ll help.

Preparing a TFTP server

The installation files need to be shared over network. It’s usually done via a TFTP which is a very lightweight protocol implemented by most of the PXE environments. So, we’re going to install the following packages on the server machine:

# apt-get install tftpd-hpa xinetd

When installed, TFTP server needs to be configured so that it points to the correct files needed by the client. Let’s create a file /etc/xinetd.d/tftp and fill it with something like this:

service tftp
        disable                 = no
        socket_type             = dgram
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -v -s /var/lib/tftpboot
        only_from               = 192.168.1.

Please watch the last line, though: only_from. Here you should put all the subnets over which you want to share your files. Usually the local network (192.168.1.*) and the local machine (for testing) is fine. If your network configuration is different, you need to adjust this line to fit your needs. If you don’t know your IP, you can easily find it out by issuing /sbin/ifconfig -a in the terminal window.

The last thing to do is to actually share the files over TFTP. You can do it by copying the needed files to the shared folder of TFTP as you just configured it:

cp /home/johnny/netboot/* /var/lib/tftpboot/

Of course if you are using an Ubuntu CD, just copy the files from the CD, you don’t need to download them separately:

cp /media/cdrom/install/netboot/* /var/lib/tftpboot/

Finally restart the xinetd service:

/etc/init.d/xinetd restart

And you are more or less done with TFTP. The server should be up and running, files shared over the local network. It’s time to configure DHCP now so that the client knows how to find your server machine and point to the correct installation file over TFTP.

But first get a slice of pizza, prepared beforehand. It’s cold… strange.

Setting up a DHCP server

DHCP servers are used to automatically distribute IP addresses to client computers in a network. In our case the DHCP server will also point the client to the relevant netboot file. Thanks to this we’ll be able to install Ubuntu over network without even knowing the actual location of the file.

So, let’s install DHCP server with the following command:

# apt-get install dhcp3-server

Of course this should be done on the server machine. Easy so far? Sure it is. What can be a bit troublesome is the configuration of the server. It is done via editing the file /etc/dhcp3/dhcpd.conf. Debian should have created this file for us filling it up with the default values. What we need to do is:

  • to specify the permissions (basing on IP or MAC address),
  • set up the proper DNS servers to be used,
  • and to specify the installation file that should be downloaded by the client after connecting with the server.

In my case the essential part of the dhcpd.conf file that I had to edit looks like this:

# router localization
option routers;
# network mask
option subnet-mask;
# main DNS server to be used
option domain-name-servers;

# set up if our DHCP server is supposed to be the default one in the network

# ping allowed
ping-check = 1;
# important! this is the location of the installation file!
filename = "pxelinux.0";
# subnet IP address
# accepted IDs in the netmask
netmask {

And this was enough in order for DHCP to work properly and assign the right IP addresses to the client computers in the specified local network as well as for downloading the pxelinux.0 file in the PXE mode.

If it looks good, restart DHCP server:

/etc/init.d/dhcp3-server start

and proceed with the installation!

Network installation (PXE)

On the client computer in BIOS (which we can access while rebooting the computer, usually with under keys F12, DEL or such) the first boot option should be set to network (PXE). If this is so, save the BIOS settings, reboot and… wait what happens.

If everything is OK, we should be informed that the DHCP connection has been successful, that we have been assigned an IP address and that the installation file is being downloaded from the TFTP server. In a few seconds time the default installation screen of Ubuntu (or your favorite Linux distribution) should appear. I assume that from now on you’ll be fine. If you encounter issues, first search for “ubuntu network installation” on Google. The process should be explained in detail with screenshots. In case of big trouble, use forums or IRC to find help.

If nothing happens… then… oh well… an error must have occurred. We’ll deal with it soon, but first, grab the second slice of pizza and drink some coke. Already warm… huh.

Coping with errors

If an error occurred (read: the installed did not launch), first of all, don’t panic. This is normal. You need to figure out what prevented it from loading. This is what the system logs are for! Let’s take a quick look at the syslog file on the server::

# less /var/log/syslog

and read it with understanding. The problem may have occurred in a few places: while connecting via DHCP, while downloading the file though TFTP or during the installation — for instance the package list could fail to be downloaded due to incorrect DNS settings.

Testing TFTP is trivial. Just try to connect with the TFTP server locally using a client: tftp localhost. If it works, try to get the installation file: > get pxelinux.0. Exit the program (bye) and see if the file got downloaded. If you can see it in the current folder, this means the server works. At least locally.

DHCP can be tested from a different machine (also a virtual one) by issuing a command like: dhclient eth0. If you managed to connect, it means the DHCP server works fine. If you can ping any network domain on the client machine (try ping, this means the DNS works fine as well. But in this case everything works so you shouldn’t have had any problems with network installation :)

Of course it’s impossible to predict any problem. In my case the procedure worked flawlessly, except for the fact I had a typo in the DNS address and the remaining installation files failed to download forcing me to restart the installation after altering the DNS IPs in the DHCP server configuration file.

The key thing in solving issues is to think reasonably and try to exclude possible problems one by one. If you get stuck, don’t worry. Just post a comment and we’ll try to help you if you can.

Now when the system in finally being installed via PXE, you can finally eat the rest of the cold pizza and empty the warm cola bottle. Doesn’t it taste good!?

Alternative options

In the article I purposely omitted alternative options of doing the same thing. Obviously there are a lot of them (we are using Linux, aren’t we?!). You can achieve the same using multiple methods. Some of them being:

  • instead of xinetd+tftp pair you can use inetd+tftp or run tftp as a standalone daemon service,
  • using alternative TFTP implementation like atftpd…
  • use another operating system as the server (any distribution or GNU/Linux, some BSD family system or even MS Windows),
  • instead of the coke order a sprite or a mountain dew,
  • etc.

The aim of this article was simply installing a Linux distribution over the network so that you can enjoy the free operating system on a computer with no CD drive. I hope we have managed to achieve this goal together successfully.