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>

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.

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.

Preseeding

Requirements

  • TFTP, DHCP, web server
  • time
  • patience

Example of preseed file

# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US
# The values can also be preseeded individually for greater flexibility.
d-i debian-installer/language string en
d-i debian-installer/country string CZ
# Keyboard selection.
# 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. This makes it
# skip displaying a list if there is more than one interface.
d-i netcfg/choose_interface select auto
# If you have a slow dhcp server and the installer times out waiting for
# it, this might be useful.
d-i netcfg/dhcp_timeout string 60
# 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
# Disable that annoying WEP key dialog.
d-i netcfg/wireless_wep string
# If non-free firmware is needed for the network or other hardware, you can
# configure the installer to always try to load it, without prompting. Or
# change to false to disable 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 debian.mirror.dkm.cz 
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
# 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 UTC
# 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.
d-i clock-setup/ntp-server ntp.vm.zeratul.czf

### Partitioning
## Partitioning example
# If the system has free space you can choose to only partition that space.
# This is only honoured if partman-auto/method (below) is not set.
#d-i partman-auto/init_automatically_partition select biggest_free

# Alternatively, you may specify a disk to partition. If the system has only
# one disk the installer will default to using that, but otherwise the device
# name must be given in traditional, non-devfs format (so e.g. /dev/hda or
# /dev/sda, and not e.g. /dev/discs/disc0/disc).
# For example, to use the first SCSI/SATA hard disk:
#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: use the usual partition types for your architecture
# - lvm:     use LVM to partition the disk
# - crypto:  use LVM within an encrypted partition
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-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home:   separate /home partition
# - multi:  separate /home, /usr, /var, and /tmp partitions
d-i partman-auto/choose_recipe select atomic
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
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
# This makes partman automatically partition without confirmation.
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
d-i grub-installer/bootdev string (hd0,0)

### Finishing up the installation
# Avoid that last message about the install being complete.
d-i finish-install/reboot_in_progress note
# This will prevent the installer from ejecting the CD during the reboot,
# which is useful in some situations.
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/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

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 mean, I've encountered quite weird and unusual GRUB problem when I updated Debian Wheezy netboot from 7.0.0 to 7.1.0. I've failed to solve it, simply because of lack of time, and I've fallen back to 7.0.0 which works just fine and confirmed problem isn't in preseed file.

Ok, that was one variant - fall back to the last known working configuration. 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. Don't forget to update checksum of preseed file!

# debconf-get-selections --installer > di-selections.txt
linux/debian/automatic-installation.1371637818.txt.gz · Last modified: 2013/06/19 05:30 by stybla