User Tools

Site Tools


linux:debian:automatic-installation

This is an old revision of the document!


Debian - Automatic Installation

<note warning> WORK IN PROGRESS

  • NOTE to myself - preseed file can be supplied by DHCP
  • NOTE to myself - preseed generated by CGI script

</note>

As a pretty much any mainstream GNU/Linux distribution, even Debian allows you to automate system installation. You can either use Preseed or build a custom ramdisk and use debootstrap directly.

No doubt each approach has its own pros and cons. Personally, I think Preseed is sufficient for most cases and basic OS installation is what you (should) want. After OS is sucessfully installed, Ansible/Chef/Puppet will take over and finish the job. I really seek nothing else from OS installation. Preseed is capable of handling not only partitions, but software RAID and LVM as well. You can also run commands and do stuff, although admitingly in limited scope.

On the other hand, customized ramdisk can provide you with universal solution - one rules them all. You can add vendor specific tools, assemble HW RAIDs, debug/fix broken OS, run pre/post install tasks via your favourite management tool etc. and create one ramdisk for OS install and rescue.

Now, you might argue every server(hardware configuration) is different and requires specific approach. I'd counter-argue it's more about profiling and you end up with only couple profiles. I agree stuff like HW RAID assembly and vendor specific tools to do that might be a problem. However, you can modify Debian's netboot ramdisk and add these. Preseed allows you to run early command(s). Is it early enough to assembly HW RAID? Would installer notice/update its device list? I don't know, I haven't tried.

I still think rolling with Preseed for basic OS installation is better and easier to maintain way than having to maintain your customized ramdisk. Althouhg, once you automate its [ramdisk] creation, then it won't matter that much.

Customized ramdisk and debootstrap

FIXME

I've seen this being done and used. However, it seems like a ton of work for my use case. Also, I can see some cons as well like a constant maintenance and keeping stuff up to date. Of course there are pros like having customized tool-set, “one” universal ramdisk for installation and debugging, I guess more variability/freedom.

Here comes an idea I haven't exploited. Take Debian's netboot ramdisk, uncompress it, modify it in a way it boots into shell instead of installer, add stuff you need want, remove stuff you don't need, pack it, run with it.

Preseeding

Requirements

  • TFTP, DHCP, web server
  • time
  • patience

Example of preseed file

I've removed pretty much all comments. What's below is my preseed file. Please, see example preseed files/documentation for explanation, hints and, actually, more.

### l18n, i18n, keyboard
d-i debian-installer/locale string en_US
d-i debian-installer/language string en
d-i debian-installer/country string CZ
# keymap is an alias for keyboard-configuration/xkb-keymap
d-i keymap select us

### Network configuration
# netcfg will choose an interface that has link if possible.
d-i netcfg/choose_interface select auto
# In case of a slow dhcp server
d-i netcfg/dhcp_timeout string 60
# despite defined here, it must be preseeded via cmd line as well
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain

d-i netcfg/wireless_wep string
# load non-free firmware without asking
d-i hw-detect/load_firmware boolean true

### Mirror settings
# If you select ftp, the mirror/country string does not need to be set.
d-i mirror/protocol string http
d-i mirror/country string cz
d-i mirror/http/hostname string test-deb-01.vm.zeratul.czf
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string

### Account setup
# Alternatively, to skip creation of a normal user account.
d-i passwd/make-user boolean false
# Root password, either in clear text
d-i passwd/root-password password toor
d-i passwd/root-password-again password toor

### Clock and time zone setup
d-i clock-setup/utc boolean true
d-i time/zone string UTC
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server ntp.vm.zeratul.czf

### Partitioning
# this must be set in case you have more than one HDD present
d-i partman-auto/disk string /dev/vda
# possible values: regular, lvm, crypto
d-i partman-auto/method string lvm

d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

# possible values - atomic, home, multi
d-i partman-auto/choose_recipe select atomic

d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-md/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

### Package selection
tasksel tasksel/first multiselect standard
# Individual additional packages to install
d-i pkgsel/include string openssh-server
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
d-i pkgsel/upgrade select none

popularity-contest popularity-contest/participate boolean false

### GRUB
d-i grub-installer/only_debian boolean true
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
# don't eject CD as there isn't any
d-i cdrom-detect/eject boolean false
# Setup SSH keys for root; the last command to be run before reboot
d-i preseed/late_command string wget http://test-deb-01.vm.zeratul.czf/preseed/set-ssh-keys.sh; sh set-ssh-keys.sh;

Example of parameters passed to kernel

LABEL Debian64-7.1.0-netinstall
  MENU LABEL Debian64 7.1.0 Wheezy PreSeed NetInst
  KERNEL kernel/debian64-7.1.0-netinstall
  APPEND initrd=img/debian64-7.1.0-wheezy-initrd.img \
    auto \
    url=http://test-deb-01.vm.zeratul.czf/preseed.cfg \
    preseed-md5=299d7a67793464e7e1e013a79660b64e \
    fb=false \
    locale=en_US \
    language=en \
    country=CZ \
    keymap=us \
    interface=auto \
    netcfg/dhcp_timeout=60 \
    netcfg/get_hostname=unassigned-hostname \
    netcfg/get_domain=unassigned-domain

Now, that's a quite a lot, isn't it? I hear you. This is because preseed file won't be retrieved until network configuration is done. At least I guessed so. And this also was a bit of unpleasant surprise to me. May be I've missed something, but I'd try to retrieve preseed file before installer starts up. However, Debian's preseed doesn't work this way and thus it seems to be necessary to supply all, well some of these, options.

  • auto - turns on automatic installation
  • url - URL to preseed file
  • preseed-md5 - MD5 checksum of preseed file
  • fb - whether installer should use Frame Buffer or not
  • locale, language, country, keymap - to beat i18n, l18n questions
  • interface - choose the first interface with link up(perhaps not necessary and on by default)
  • netcfg/dhcp_timeout - just for sure
  • netcfg/get_hostname, netcfg/get_domain - despite set from DHCP, installer kept asking for confirmation unless defaults were passed as kernel param

Turning off Frame Buffer(fb) in installer is usefull when eg. curses is used instead of SDL to display VGA output. However, turning Frame Buffer off means graphics in installer will go wonky from time to time even when running in SDL window.

When things go wrong - unusual/additional questions asked

It may, and probably will over the time, happen you'll be asked some unusual question during installation. What you should do depends whether system boots after installation is finished. I've encountered quite weird problem with GRUB when I downloaded Jessie(at the time of this writing under development) netboot instead of Wheezy 7.1 and I wasn't able to get the system working in the sane ammount of time. No biggie; only to demonstrate it can happen - something gets changed or doesn't work out. I've used working configuration of Wheezy 7.0 to confirm there is nothing wrong with Preseed file.

Falling back to the last known working configuration is one option. However, if system boots after installation is finished, you can run the following command and “guess” what question(s) you were asked and add responses to your preseed file. No worries, there are comments to ease the search. Don't forget to update checksum of preseed file!

# debconf-get-selections --installer > di-selections.txt
linux/debian/automatic-installation.1371985941.txt.gz · Last modified: 2013/06/23 06:12 by stybla