Posted by chantra on June 23rd, 2007
- How-To: Unattended Ubuntu Deployment over Network
- How-To: Unattended Ubuntu Deployment over Network — page 2 — DHCP server
- How-To: Unattended Ubuntu Deployment over Network — page 3 — TFTP server
- How-To: Unattended Ubuntu Deployment over Network — page 4 — PXELinux
- How-To: Unattended Ubuntu Deployment over Network — page 5 — Preseed File
5. Preseed: Installation automation:
Like Red Hat’s kickstart file, Debian based distribution can use a preseed file. The preseed file will contain the different information that the installer will require in order to proceed with the installation.
Basically, this file is going to contain language, keymap layout, repositories, distro version, partitioning, timezone and package selection informations.
An example of this file can be found here: http://www.debian.org/releases/stable/example-preseed.txt .
There is many ways to get the installer loading the preseed file: floppy, harddrive, http… Because we are performing a net install here, it is logical to get the preseed file from the network. In this example our http server will be called http-preseed.
Because we are getting the preseed file from the network, the preseed file will be downloaded only once the installer acquires an IP address. Therefore, we will need to inject a few preseed command to the installer using the append part of pxelinux.cfg/default .
Once the network will be set up, the preseed file will be downloaded and the installer will use its content.
In our example, we will set an en_GB locale, keyboard, the hostname will be provided by our DHCP server, timezone will be Europe/Dublin.
You can find available locales in /usr/share/locale/ . Available timezone can be found in /usr/share/zoneinfo/
Our repository is going to be running apt-cacher and will be accessible at 192.168.0.1:9999.
If you intend to set many systems with netinstall, it is wise running your own repository to minimize bandwidth utilisation.
We will be partitioning our disk on /dev/sda with separate /, /usr, /var, /tmp, /home and we will create a first user called ubuntuadmin with the password mypassword.
Our default install will install an ubuntu lamp server.
A password MD5 can be generated with echo “mypassword” | mkpasswd -s -H MD5
Here is how my preseed file look like:
d-i debian-installer/locale string en_GB
d-i console-setup/layoutcode string en_GB
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
d-i netcfg/wireless_wep string
### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
d-i mirror/country string enter information manually
d-i mirror/protocol string http
d-i mirror/http/hostname string 192.168.0.1:9999
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
# Suite to install.
#d-i mirror/suite string testing
# Suite to use for loading installer components (optional).
#d-i mirror/udeb/suite string testing
d-i mirror/suite string feisty
# If the system has free space you can choose to only partition that space.
# Note: this must be preseeded with a localized (translated) value.
#d-i partman-auto/init_automatically_partition \
# select Guided – use the largest continuous free space
# Alternatively, you can specify a disk to partition. The device name
# can be given in either devfs or traditional non-devfs format.
# For example, to use the first disk:
#d-i partman-auto/disk string /dev/discs/disc0/disc
d-i partman-auto/disk string /dev/sda
# In addition, you’ll need to specify the method to use.
# The presently available methods are: “regular”, “lvm” and “crypto”
d-i partman-auto/method string lvm
# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away…
d-i partman-auto/purge_lvm_from_device boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
# You can choose from any of the predefined partitioning recipes.
# Note: this must be preseeded with a localized (translated) value.
d-i partman-auto/choose_recipe \
select Separate /home, /usr, /var, and /tmp partitions
# This makes partman automatically partition without confirmation.
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
### Clock and time zone setup
# Controls whether or not the hardware clock is set to UTC.
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 Europe/Dublin
### Apt setup
# You can choose to install non-free and contrib software.
d-i apt-setup/multiverse boolean true
d-i apt-setup/universe boolean true
# To create a normal user account.
d-i passwd/user-fullname string Ubuntu Server Administrator
d-i passwd/username string ubuntuadmin
# Normal user’s password, either in clear text
#d-i passwd/user-password password insecure
#d-i passwd/user-password-again password insecure
# or encrypted using an MD5 hash.
d-i passwd/user-password-crypted password $1$ApZFpRq5$X38skX90ZL36YOnbYt/3J
# 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
### Package selection
tasksel tasksel/first multiselect standard, lamp-server
# Individual additional packages to install
d-i pkgsel/include string openssh-server
### Finishing up the first stage install
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note
xserver-xorg xserver-xorg/autodetect_monitor boolean true
xserver-xorg xserver-xorg/config/monitor/selection-method \
xserver-xorg xserver-xorg/config/monitor/mode-list \
select 1024×768 @ 60 Hz
Now, it is time to explain our installer where to get the preseed file from. Go and edit /var/lib/tftpboot/pxelinux.cfg/default and change the line where refering to APPEND for the server from :
append base-installer/kernel/linux/extra-packages-2.6= tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=normal initrd=ubuntu-installer/i386/initrd.gz –
append ramdisk_size=14984 locale=en_GB console-setup/layoutcode=en_GB netcfg/wireless_wep= netcfg/choose_interface=eth0 netcfg/get_hostname= url=http://http-preseed/preseed.cfg vga=normal initrd=ubuntu-installer/i386/initrd.gz –
As you can see here, we inform the installer of a few required informations such as the locale and the keyboard layout. We also force the installer to pick up eth0 and finally, we let it know that our preseed file can be accessed through HTTP, the file is called preseed.cfg and is served by server http-preseed.
That’s it, now you should be able to boot the client using PXE, this client will get a network address, download a kernel and initrd, will start the configuration using the arguments passed to the APPEND entry, get an address through DHCP, get the preseed file and proceed with the installation answering the question with the values found in preseed.cfg.