As usual, I couldn’t find any kind of documentation or walkthrough on the web that explained how I could do an ubuntu install the way I wanted to: pxe boot the machine, then install from media that is located on the local network, NOT from any ubuntu repositories. In other words, install ubuntu to a machine that is PXE-enabled, but don’t require any media to be directly attached to the machine (i.e., cd-rom or usb), and don’t require a connection to the internet. After banging my head against the ol’ “google search wall” and trying out a whole bunch of stuff, I finally figured it out. I’m not going to explain a whole lot outside of what I’m trying to accomplish, but I’ll include some links at the bottom of the post to resources I found useful. Here we go:
First, you’ll need a DHCP server configured for sending the PXE configuration to your client(s). There’s more than enough documentation on this, so I won’t delve into it (check the links at the bottom). For my own network, I already have a DHCP server that supports PXE (it’s running pfsense), so I just used that. Second, you’ll need a tftp server. I’m using an ubuntu (9.10) server for this. It’s located on the same local network as the machine I want to PXE boot. Let’s call it “installerhost”, and say it has the IP address 192.168.1.19. I’ll install tftp on it. One thing to note is to not use tftpd, but tftp-hpa:
sudo apt-get install tftp-hpa
Next, grab a copy of an ubuntu install cd iso. I’m using the ubuntu server 9.10 amd64 distribution. If you use another just note that there may be some file / directory name differences (especially for a different architecture), but the concept should remain the same. I have it downloaded at ~/ubuntu-9.10-server-amd64.iso. The following commands will mount the iso, and copy the needed netboot files to the newly created tftp root directory (you could also just copy from the cd-rom if you have one handy):
cd ~ sudo mkdir /mnt/ubuntu sudo mount -o loop ubuntu-9.10-server-amd64.iso /mnt/ubuntu sudo cp -av /mnt/ubuntu/install/netboot/* /var/lib/tftpboot/
alter the tftp configuration file at /etc/default/tftp-hpa to be:
#Defaults for tftpd-hpa RUN_DAEMON="yes" OPTIONS="-l -s /var/lib/tftpboot"
the restart tftp:
sudo /etc/init.d/tftpd-hpa restart
Next, we set up a way for the installer to get the packages it needs to set up ubuntu on our new server. I’m choosing to do this over http (using apache), just because it’s simple, and I’m used to reading apache logs so I can check on how things go. You can set up an ftp server if you prefer, and that will accomplish the same thing (with slight modifications to the instructions below).
So first we set up apache:
sudo apt-get install apache2
At this point I can browse to http://installerhost and it shows the apache is working page. Now I’ll copy over the required installation media to the web directory. Obviously at this point you could create multiple directories containing various distributions, do symlinking, or apache-alias some dirs, etc, etc, but I’ll keep it simple for the purposes of this post. Remember that the iso (or cd) should still be mounted. We’ll also get rid of the default “index.html”:
sudo cp -av /mnt/ubuntu/* /var/www/ sudo rm /var/www/index.html
Now, when I go to http://installerhost, I see a directory listing that should be identical to that of the installer cd rom.
Of course, if you’re setting up on a larger network, or have one or more of your computers publicly exposed, you’ll want to secure the services we set up (tftp, pxe, dhcp, apache). Each service provides methods of restricting access, but configuring that seems outside the scope of this post. You could also set up tftp and apache folders to overlap (by modding each service’s config) so you don’t have duplicate files, but again, I just tried to keep things clear.
Now ensure that your DHCP server is configured to point PXE clients to the new tftp server. The IP address should be the address of our installerhost, 192.168.1.19, and the filename is “pxelinux.0″. I just enter those values in my pfsense box and I’m good to go. If you set up dhcp on another server (or even on your version of “installerhost”), see the links below for help configuring it.
At this point, you should be able to pxe-boot your machine. However, it will still (by default) download packages from the ubuntu repositories (if it has internet access), not your local network.
In order to get the installer to choose the apache-served media, do the follow:
- Start the machine you want the installation to occur on in PXE-boot mode
- The ubuntu installer should start — when the menu comes up, choose one of the advanced installation methods
- Choose “set up repositories”, and complete the other required steps
- When it gets to the point where you choose your location, choose the first option, “enter manually”
- For the hostname, enter your apache server’s name (in my case, “installerhost”), and leave the path as “/” in the next screen
- Complete the installation… it will pull from your local network!
The other neat thing I discovered is that the installer will automatically configure apt to use the local network, rather than “remote” repositories. Pretty neat…
Next I’m going to work on setting up preseed info, so that installation can occur completely unattended. More soon!
Here’s some useful stuff I found while working on this:
- http://www.alexonlinux.com/opening-and-modifying-the-initrd – Editing an initrd (I didn’t have to do this, but I found it interesting to pull an initrd apart and look at what’s inside)
- https://help.ubuntu.com/community/Installation/Netboot – Netboot docs from ubuntu help. Has info on configuring dnsmasq
- http://sites.google.com/site/golinuxnow/installing-from-a-lan-server – more network booting stuff
cheeaz!
{ 2 comments… read them below or add one }
hello, I read your guide and i want to do the same thing, but changing the distribution of ubuntu (not server). I have the problem: the iso that i downloaded from the ubuntu servers (http://www.ubuntu.com/desktop or a iso that i do with remastersys) don’t have the path /install/netboot/… ! Is there a mode for create this?
Thanks
justux
You can actually grab the netboot images straight from the ubuntu archives. For example, lucid’s is located at:
http://archive.ubuntu.com/ubuntu/dists/lucid/main/installer-amd64/current/images/netboot/
I haven’t tried this process with anything other than the server version, but I assume it should work ok. Good luck!