Ultimate Home Server - Preseeding Network Installs

Okay, this took a lot of trial and error testing. There seems to be two ways of getting information passed to the installer when netbooting, and both have different strengths and weaknesses. First we have kickstart files, which seem to be somewhat lacking in support in ubuntu. Then we also have preseeding, which is supported much more thoroughly and quite flexible. Unfortunately, preseeding can anly affect things after the network has been configured, (unless you put it in an initrd image which I never figured out how to do), so it leaves a few questions at the beginning of the install still needing to be answered. On the flip side, kickstart will cause the network to be configured right off the bat and can be used to get rid of even the first questions, but it has no support for quite a lot of options and so falls somewhat short of being a reliable solution. After many test installs I have gone with the idea that a combination of the two technologies is the only viable option, using kickstart only to answer the questions that preseeding cannot and using a preseed file to take over from there.

This stuff needs to be done on the machine, or virtual machine, that hosts your install server, and most of it need to be done as root, so you will need to log in to that machine and sudo -i to get a root console.

Kickstart: If you’ve followed my walkthrough for setting up apt-mirror and a PXE install server then you should have a small preeseed file at /var/www/html/preseed.cfg. This file can be modified to allow for just about anything during install, but to get rid of the first questions we need to create a kickstart file in the same directory:

vim /var/www/html/ks.cfg

Here is what I’ve entered into my kickstart file:

# System language
lang en_US
# System keyboard
keyboard us
# System mouse
mouse

You will, of course, need to adjust those settings to match your location, but this file is enough to get the install to be question free until the preseed file can be loaded. After that we can get to the good stuff.

Preseeding: You can get a sample preseed file from the ubuntu helps site. I’ve made several changes to the sample file, I’ll post it below. Please read the comments in the my example to for notes about problems or possible options as well as the reasoning behind the options I’ve used.

My preseed file:

#### Contents of the preconfiguration file
##### This stuff is taken care of by the kickstart file I've used.
#### Localization
## Locale sets language and country.
#d-i debian-installer/locale string en_US
#
## Keyboard selection.
## Disable automatic (interactive) keymap detection.
#d-i console-setup/ask_detect boolean false
##d-i console-setup/modelcode string pc105
#d-i console-setup/layoutcode string us
## To select a variant of the selected layout (if you leave this out, the
## basic form of the layout will be used):
##d-i console-setup/variantcode string dvorak
#####

##### This is also taken care of, as long as you use DHCP to configure the
##### first network interface the installer finds.
#### Network configuration
## netcfg will choose an interface that has link if possible. This makes it
## skip displaying a list if there is more than one interface.
#d-i netcfg/choose_interface select auto
#
## Any hostname and domain names assigned from dhcp take precedence over
## values set here. However, setting the values still prevents the questions
## from being shown, even if values come from dhcp.
#d-i netcfg/get_hostname string unassigned-hostname
#d-i netcfg/get_domain string unassigned-domain
#####

##### This is ver important for getting the install to use a local mirror
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
#d-i mirror/protocol string ftp
# this sets the mirror to manually selected
d-i mirror/country string manual
# this actually tells it which mirror you are manually selecting
d-i mirror/http/hostname string installserver.yourdomain.name
# this is the directory to look in, relative to the above url
d-i mirror/http/directory string /ubuntu
# this sets the proxy settings to 'none', may need adjusted
# if you do use a proxy to get to your mirror
d-i mirror/http/proxy string

# Suite to install.
# this tells it which version of ubuntu to install
d-i mirror/suite string hardy
# Components to use for loading installer components (optional).
# this tells it to allow installing components from repositories other than 'main'
d-i mirror/udeb/components multiselect main, restricted, universe, multiverse

### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
# this should be true if this is a linux only machine
d-i clock-setup/utc boolean true

# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string US/Eastern

# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true
# NTP server to use. The default is almost always fine here.
# set this to your local NTP server if you have one, otherwise leave it at default
d-i clock-setup/ntp-server ntpserver.yourdomain.name

# The kernel image (meta) package to be installed; "none" can be used if no
# kernel is to be installed.
# This still installed the 'generic' kernel, but I also get the 'rt' kernel
d-i base-installer/kernel/image select linux-image-rt

### Account setup
# To create a normal user account.
d-i passwd/user-fullname string Administrative Username
d-i passwd/username string administrativeloginname
# user password, encrypted using an MD5 hash for a false sense of security.
# use: echo "<password>" | mkpasswd -s -H MD5 to get hash
d-i passwd/user-password-crypted password $1$jjspYju9wf3skn.iScV7H554ltJFzU/

### Apt setup
# You can choose to install restricted and universe software, or to install
# software from the backports repository.
d-i apt-setup/restricted boolean true
d-i apt-setup/universe boolean true
d-i apt-setup/backports boolean true
d-i apt-setup/multiverse boolean true

# Select which update services to use, security is a good idea
# Choices: security updates (from security.ubuntu.com),
#       volatile updates (from volatile.debian.org)
# If you do not mirror the 'security' updates repository then this should be left at default
d-i apt-setup/services-select multiselect security
# define the mirror for the above
d-i apt-setup/security_host string installserver.yourdomain.name
d-i apt-setup/security_path string /ubuntu

# Additional repositories, local[0-9] available
# this allows to install to use additional repositories
# and will also add them to your sources.list automagically
# I've used a medibuntu mirror as an example
##
# This line tells it where the repository is
apt-setup apt-setup/local0/repository string http://installserver.yourdomain.name/medibuntu hardy free non-free
# this line tells it how to comment the repository in your sources.list file
apt-setup apt-setup/local0/comment string local medibuntu mirror
# Enable deb-src lines
# I've chosen not to mirror the source repositories...
#d-i apt-setup/local0/source boolean true
# URL to the public key of the local repository; you must provide a key or
# apt will complain about the unauthenticated repository and so the
# sources.list line will be left commented out
# This is very important, not only will it not get added to your sources.list
# but it will also blow up the install if you tell it to install anything that
# is only available from this repository.
# I've aimed it strait at the key on the medibuntu website as I don't think
# this key is mirrored...
apt-setup apt-setup/local0/key string http://packages.medibuntu.org/medibuntu-key.gpg

### Package selection
# tasks to install, not all tasks work. These work for me, you may try others
# but I have found that adding things to the individual package selection
# below works better for just about everything.
tasksel tasksel/first multiselect  ubuntu-standard, OpenSSH server, Ubuntu desktop

# Individual additional packages to install
# this line installs several hundred packages that you may not want or need
# you should change it to get what you want...
d-i pkgsel/include string e16, mplayer, ubuntu-restricted-extras, banshee, ubuntustudio-graphics, ubuntustudio-audio, ubuntustudio-audio-plugins, ubuntustudio-video, kubuntu-desktop, xubuntu-desktop, ubuntustudio-look, ubuntustudio-icon-theme, usplash-theme-ubuntustudio, ubuntustudio-controls, ubuntu-restricted-extras, e16, mplayer, w32codecs, banshee, debconf-utils, gstreamer0.10-ffmpeg, gstreamer0.10-pitfdll, gstreamer0.10-plugins-bad, gstreamer0.10-plugins-bad-multiverse, gstreamer0.10-plugins-base, gstreamer0.10-plugins-base-apps, gstreamer0.10-plugins-good, gstreamer0.10-plugins-ugly, gstreamer0.10-plugins-ugly-multiverse, gstreamer0.10-pulseaudio, gstreamer0.10-sdl, gstreamer0.10-tools, gstreamer0.10-x, w32codecs
# Language pack selection
# I have no real need for additional languages
#d-i pkgsel/language-packs multiselect de, en, zh

### Boot loader installation
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true

# This one makes grub-installer install to the MBR if it also finds some other
# OS, which is less safe as it might not be able to boot that other OS.
d-i grub-installer/with_other_os boolean true

### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note

### Preseeding other packages
# Depending on what software you choose to install, or if things go wrong
# during the installation process, it's possible that other questions may
# be asked. You can preseed those too, of course. To get a list of every
# possible question that could be asked during an install, do an
# installation, and then run these commands:
#   debconf-get-selections --installer > file
#   debconf-get-selections >> file

##### I have not used this stuff yet
#### Advanced options
### Running custom commands during the installation
# d-i preseeding is inherently not secure. Nothing in the installer checks
# for attempts at buffer overflows or other exploits of the values of a
# preconfiguration file like this one. Only use preconfiguration files from
# trusted locations! To drive that home, and because it's generally useful,
# here's a way to run any shell command you'd like inside the installer,
# automatically.
#
# This first command is run as early as possible, just after
# preseeding is read.
#d-i preseed/early_command string anna-install some-udeb
#
# This command is run just before the install finishes, but when there is
# still a usable /target directory. You can chroot to /target and use it
# directly, or use the apt-install and in-target commands to easily install
# packages and run commands in the target system.
#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh
#####

# If you have installed packages that as questions you can preseed those
# questions as well, I've included a couple of examples below
# SUN Java
sun-java6-jre   sun-java5-jre/jcepolicy note
sun-java6-jre   sun-java5-jre/stopthread        boolean true
sun-java6-bin   shared/accepted-sun-dlj-v1-1    boolean true
sun-java6-jdk   shared/accepted-sun-dlj-v1-1    boolean true
sun-java6-jre   shared/accepted-sun-dlj-v1-1    boolean true
sun-java6-bin   shared/present-sun-dlj-v1-1     note
sun-java6-jdk   shared/present-sun-dlj-v1-1     note
sun-java6-jre   shared/present-sun-dlj-v1-1     note

# msttcorefonts
msttcorefonts msttcorefonts/defoma note

The above file installs a lot of stuff, including several desktop/window manger environments, all of the Ubuntu Studio graphic/audio/video editing stuff, and full multimedia capabilities. This is enough to make my wife and children happy, though I suspect I will eventually need to figure out a way to include a lot more games in the future. :)

You may also notice that I have left out the partitioning stuff. I did that because all the machines in my home have different sizes and numbers of hard drives in them and I manually partition each on individually. If your situation is different you can easily add in the partitioning information from the sample file at the ubuntu help site. I did play with it a bit, it is lacking in the regards of capability, meaning that it can only partition one disk. If all of your computers have only one disk it might be worth wile to set it up and have a totally hands free install server.

Modifying the install server: Before the above files will work you will need to set up the install server to use them. This is a fairly easy and strait forward thing. First modify the ‘defult’ file for the install server:

vim /var/lib/tftpboot/pxelinux.cfg/default

You need to tell it where the kickstart file is by adding an option to the append lines. I’ve done this by adding an ‘auto-install’ option, which leaves the other install options at default, but lets me run the auto install fairly easily

My /var/lib/ftpboot/pxelinux.cfg/defult file:

DISPLAY ubuntu-installer/i386/boot-screens/boot.txt

F1 ubuntu-installer/i386/boot-screens/f1.txt
F2 ubuntu-installer/i386/boot-screens/f2.txt
F3 ubuntu-installer/i386/boot-screens/f3.txt
F4 ubuntu-installer/i386/boot-screens/f4.txt
F5 ubuntu-installer/i386/boot-screens/f5.txt
F6 ubuntu-installer/i386/boot-screens/f6.txt
F7 ubuntu-installer/i386/boot-screens/f7.txt
F8 ubuntu-installer/i386/boot-screens/f8.txt
F9 ubuntu-installer/i386/boot-screens/f9.txt
F0 ubuntu-installer/i386/boot-screens/f10.txt

DEFAULT install

LABEL install
        kernel ubuntu-installer/i386/linux
        append vga=normal initrd=ubuntu-installer/i386/initrd.gz --
LABEL auto-install
        kernel ubuntu-installer/i386/linux
        append initrd=ubuntu-installer/i386/initrd.gz ks=http://installserver.yourdomain.name/preseed/ks.cfg url=http://installserver.yourdomain.name/preseed/preseed.cfg  --
LABEL linux
        kernel ubuntu-installer/i386/linux
        append vga=normal initrd=ubuntu-installer/i386/initrd.gz --
LABEL cli
        kernel ubuntu-installer/i386/linux
        append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=normal initrd=ubuntu-installer/i386/initrd.gz --

LABEL expert
        kernel ubuntu-installer/i386/linux
        append priority=low vga=normal initrd=ubuntu-installer/i386/initrd.gz --
LABEL cli-expert
        kernel ubuntu-installer/i386/linux
        append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false priority=low vga=normal initrd=ubuntu-installer/i386/initrd.gz --

LABEL rescue
        kernel ubuntu-installer/i386/linux
        append vga=normal initrd=ubuntu-installer/i386/initrd.gz rescue/enable=true --

PROMPT 1
TIMEOUT 0

So, the only thing left is the hostname, whick I set with an option on the boot line. Start the install over the network, when you get to the Ubuntu installer screen type:

auto-install hostname=whateveryouthinkisagoodname

It works for me, hopefully it can work for others too. :)

Now that I’ve got this going I think I’m going to look into that LDAP/Samba/Kerberos/GNUTLS central authentication/file sharing thing I tried doing and failed at before…

Wish me luck!

Share and Enjoy:
  • StumbleUpon
  • Digg
  • Reddit
  • del.icio.us
  • Facebook
  • Mixx
  • Google

2 Comments

  1. Posted September 6, 2008 at 5:54 pm | Permalink

    You can avoid using kickstart by passing those options to preseed in the pxelinux.cfg/default file:

    append initrd=ubuntu-installer/i386/initrd.gz — locale=en_US interface=eth0 hostname= url=http://installserver.yourdomain.name/preseed/preseed.cfg console-setup/layoutcode=us

  2. Posted September 9, 2008 at 1:34 am | Permalink

    Cool, thanks for the added info!

Post a Comment

Your email is never shared.