Narkisr - blog

Narkisr.com where code writes itself.


30
Sep 11

Ubuntu PXE-ing, not a walk in the park

Ubuntu is one of the most user friendly systems both on the desktop side and on the server side, still there is one part in which Ubuntu requires a bit of tinkering which is pre-seeding automatic desktop installations.
Most examples out there are targeted for server installations, in this post will explain how to setup a complete automatic installation for Ubuntu desktop (PXE boot with preseeding).
Note that ill be using cobbler as the PXE server and apt-mirror but I won't be covering those in detail (there is enough material out there about these).

First a couple of perquisites:
  • Get Ubuntu alternate cd, the plain desktop cd cannot be used in automatic installations.
  • Install Cobbler on the server from which your going to serve your installations, following these instructions.
  • Setup apt-mirror, you can follow my guide.
Now that we are all set will import the alternate cd into cobbler:
  $ sudo mount -o loop ubuntu-11.04-alternate-amd64.iso /media/loop
  $ sudo cobbler import --name=ubuntu-alternate  --path=/media/loop --breed=ubuntu --os-version=natty 
Next we will add entries to our /etc/apt/mirror.list file, this is required in order to enable our local mirror during the installation:
  deb http://host/mirrors/ubuntu natty main main/debian-installer restricted restricted/debian-installer
Now comes the fun part, preseeding, iv found it to be a black art that involves a lot of trial and error, feed the following preseed file within cobbler, will go through the important options starting with using our local apt-mirror during installation:
# Mirror settings
# setting country string manual is crucial otherwise the mirror setting will not work!
d-i     mirror/country string manual
d-i     mirror/http/hostname string mirror-url
d-i     mirror/http/directory string /ubuntu
d-i     mirror/http/proxy string
d-i     mirror/udeb/components multiselect main, restricted
Next is partitioning without Lvm which is a bit tricky:
# partitioning
d-i     partman-auto/method string regular
d-i     partman-lvm/device_remove_lvm boolean true
d-i     partman-lvm/confirm boolean true
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
d-i     partman/confirm_nooverwrite boolean true
d-i     partman/default_filesystem string ext4
Now that we partitioned we can proceed to package selection, if we don't tell the installation to setup the Ubuntu desktop we will be left without any GUI, the following sets this up:
tasksel tasksel/first multiselect ubuntu-desktop
Specifying more packages is possible using:
# Making it puppet ready
d-i     pkgsel/include string byobu vim openssh-server puppet 
You can now create a profile within cobbler that will be inherited by systems to be installed, make sure to set:
  • Mac address for systems (so that cobbler will connect the dots).
  • The preseed file within the profile.
  • The following kernel opts priority=critical locale=en_US (without this the preseed will be ignored).
All things should have been ready now for installation but unfortunately cobbler has the following bug, cobbler creates the following /var/lib/tftpboot/pxelinux.cfg/MAC-ADDRESS file for each system:
default linux
prompt 0
timeout 1
label linux
        kernel /images/ubuntu-alternate-x86_64/linux
        ipappend 2
        append initrd=/images/ubuntu-alternate-x86_64/initrd.gz  locale=  priority=critical locale=en_US text  auto url=http://192.168.x.x/cblr/svc/op/ks/system/playing hostname= domain=local.lan suite=natty
The last file within this file states the kernel options that will be used for the system, notice the empty hostname value, this value takes precedence on what ever value we set in the preseed file, making us a bit jammed. The only workaround is to somehow set this value right before the installation takes place, ill update this post if once ill reach the final solution but right now ill be using a simple web service to patch this file.


This website content by Ronen Narkis is licensed under a Creative Commons Attribution 2.5 Israel License, based on a work at narkisr.com, Permissions beyond the scope of this license may be available at narkisr.com.