Technomancy

Installing (Ed)ubuntu from the network

written by rory, on Jul 28, 2009 10:13:00 PM.

(This is a repost from some archives, hence the references to an old version of Ubuntu. I've written scripts to automate a lot of this, in future there'll be a new post about how to do this anew)

I initially described how to automate an edubuntu install disc so you didn’t have to select the same options again and again.

Next I want to be able to install a PC with edubuntu by just plugging it into the network and booting off the network.

Basic Overview

When a computer does a network boot, a DHCP server gives it it’s network configuration, aswell as the path of the PXE (pre execution environment) that it is to boot. Luckily ubuntu comes with a PXE imagine prepared. It also needs to download the packages from an apt mirror. We can use the packages straight from the install CD for this. We can use one machine for all this. It’s only a matter of sticthing it all together.

Set up dhcpd

On Ubuntu install the dhcp3-server package You also need to tell the DHCP server (which will tell the clients) the path to the operating system to boot.

For example, here is section of my DHCPd configuration for the clients

      subnet 192.168.2.0 netmask 255.255.255.0 {
          filename = "pxelinux.0";
          range 192.168.2.10 192.168.2.254;
          option subnet-mask 255.255.255.0;
          option broadcast-address 192.168.2.255;
          option routers 192.168.2.1;
          next-server 192.168.2.1;
      }

All the install clients will get an IP address in the range 192.168.2.10 → 192.168.2.254. The ‘filename’ option tell the clients to download the file named ‘pxelinux.0′ over TFTP from this server and boot that OS. You’ll need the network interface to have the IP 192.168.2.1 for this.

Set up TFTP

TFTP (Trivial File Transfer Protocol) is used to send the base operating system image to the clients. In Ubuntu install the tftp-hpa package. By default the files in /var/lib/tftpboot will be server to the clients. So the clients will try to boot the image in /var/lib/tftpboot/pxelinux.0. Thanks to Conor Daly for assembling most of this. My /var/lib/tftptboot can be uncompressed into /var/lib/tftpboot to start you off.

Configure the PXE

When a machine boots the PXE, it uses /var/lib/tftpboot/pxelinux.cfg/default to give a little menu to the clients. This is the option for the installer:

      label camarabuntu
          kernel camarabuntu/linux
          append initrd=camarabuntu/ubuntu-installer/i386/initrd.gz locale=en_IE console-setup/layoutcode=uk netcfg/get_hostname=camarabuntu netcfg/disable_dhcp=true netcfg/choose_interface=auto netcfg/get_ipaddress=192.168.2.10 netcfg/get_netmask=255.255.255.0 netcfg/get_gateway=192.168.2.1 netcfg/get_nameservers=192.168.2.1 netcfg/confirm_static=true preseed/url=http://192.168.2.1/camarabuntu.seed --

You’ll note there is lots of options for the installer in there. In earlier kernels there was a limit of about 8 options on the command line. In that case we would have had to make a custom initrd. Luckily in later kernels we can have up to 32 options, so we don’t need an initrd. We had to do something similar for the CD install. I’m not sure but I think the fact that the network is hardcoded in will break when there are more than one client. The important part is the preseed/url=http://192.168.2.1/camarabuntu.seed option which tells the installer to download that file and use that as the preseed file for the installer.

Preseed file

This is my camarabuntu preseed file. It’s very similar to the one for the CD. However we don’t need to do any network stuff, since that was set as a kernel boot option. Secondly we can’t do any network options here because if the installer is reading this file, it will have downloaded it and hence already have it’s network set up. Place this file in /var/www/camarabuntu.seed so it can be downloaded by the install clients.

      # Set the installer language to Hiberno-English and UK keybaord layout
      # Note: This are set before the cd is loaded, so they must be specified in the
      # kernel options as so:
      # locale=en_IE console-setup/layoutcode=uk
      # These lines are incl
      #d-i debian-installer/locale string ie_IE
      #d-i console-setup/layoutcode string uk
      # Install source
      d-i     mirror/country    string enter information manually
      d-i     mirror/http/hostname    string 192.168.2.1
      d-i     mirror/http/directory   string /edubuntu
      d-i     mirror/suite            string dapper
      d-i     mirror/http/proxy       string
      ## Network
      #d-i netcfg/choose_interface select auto
      #d-i netcfg/disable_dhcp boolean true
      #d-i netcfg/get_nameservers string 127.0.0.1
      #d-i netcfg/get_ipaddress string 127.0.0.1
      #d-i netcfg/get_netmask string 255.255.255.0
      #d-i netcfg/get_gateway string 127.0.0.1
      #d-i netcfg/confirm_static boolean true
      # Adjust the default hostname.
      d-i netcfg/get_hostname  string camarabuntu
      # Apt mirror
      d-i mirror/http/proxy    string  
      ## Partitioning
      # Put everything in one partition
      d-i partman-auto/disk string /dev/hda
      d-i partman-auto/choose_recipe \
             select All files in one partition (recommended for new users)
      d-i partman/confirm_write_new_label boolean true
      d-i partman/choose_partition \
             select Finish partitioning and write changes to disk
      d-i partman/confirm boolean true
      # Sync clock to UTC
      d-i clock-setup/utc boolean true
      # Set the timezone
      d-i time/zone string Europe/Dublin
      ## user set up
      # No root
      d-i passwd/root-login boolean false
      # But make a normal user
      d-i passwd/make-user boolean true
      # Set username & password
      d-i passwd/user-fullname string Camara
      d-i passwd/username string camara
      d-i passwd/user-password password camara
      d-i passwd/user-password-again password camara
      # install grub in MBR, a handy default
      d-i grub-installer/with_other_os boolean true
      # Install the Edubuntu desktop and server.
      tasksel tasksel/first    multiselect edubuntu-desktop, edubuntu-server
      # don’t show us the ‘Installing successful’ dialog
      d-i finish-install/reboot_in_progress note
      # XServer set up.
      xserver-xorg xserver-xorg/autodetect_monitor boolean true
      xserver-xorg xserver-xorg/config/display/modes multiselect 1280×1024, 800×600, 640×480
      xserver-xorg xserver-xorg/config/monitor/selection-method select medium
      xserver-xorg xserver-xorg/config/monitor/mode-list select 1024×768 @ 60 Hz

Set up the ‘mirror’

In a CD install, the software packages are on the CD. When doing a network install you’re obviously going to be grabbing the software from the network cause there is no CD. Luckily you can use the same software packages from the install CD. In Ubuntu install the apache2 package, and start the apache webserver with the command

sudo /etc/init.d/apache2 start

Apache serves files from /var/www. I created a symlink /var/www/edubuntu to the cd-image folder (eg:

sudo ln -s /home/rory/camara/camarabuntu/cd-image /var/www/edubuntu

Make sure the permissions are OK. All the files and folders are going to have to be world readable.

chmod -R a+rX /home/rory/camara/camarabuntu

Done

That’s it. ☺

References

Files

  • Contents of /var/lib/tftpboot

Leave a Reply