Mar 122014
 

This article discussed how to install CentOS VM automatically with kickstart. I tried to do similar thing for Ubuntu as well but failed so many times. It seems kickstart works with RedHat families pretty well which makes perfect sense, while Ubuntu does not like that way too much.

So I turned to preseed, which was from Debian but works for its derivatives as well. After dig around here comes the preseed file:
[raw]
## Options to set on the command line
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us

d-i netcfg/choose_interface select eth0

d-i base-installer/kernel/override-image string linux-server
d-i clock-setup/utc-auto boolean true
d-i clock-setup/utc boolean true
d-i time/zone string US/Pacific
d-i clock-setup/ntp boolean true

d-i mirror/country string US
d-i mirror/http/proxy string
d-i mirror/http/mirror select mirror.facebook.net
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select none
d-i tasksel/first select OpenSSH server

d-i partman-auto/disk string /dev/vda
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic
d-i partman/default_filesystem string ext4
d-i partman/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 passwd/make-user boolean false
d-i passwd/root-password-crypted password i-wont-tell-you-for-sure
d-i passwd/root-login boolean true
d-i user-setup/encrypt-home boolean false

d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i finish-install/reboot_in_progress note
[/raw]

and launch the installation by:
[shell]
sudo virt-install –name ubuntu-test \
–ram 1024 –vcpus 1 \
–disk path=/tmp/test.img,size=20 \
–bridge=br2 \
–os-variant rhel6 –accelerate \
–location http://mirror.facebook.net/ubuntu/dists/trusty/main/installer-amd64 \
–graphics none \
-x ”
preseed/url=http://192.168.0.11/preseed.cfg
console=ttyS0
locale=en_US
console-keymaps-at/keymap=us
console-setup/ask_detect=false
console-setup/layoutcode=us
keyboard-configuration/layout=USA
keyboard-configuration/variant=USA
hostname=some-special-name
domain=your.domain

[/shell]

After the unattended installation finished, you will have:

  • Ubuntu 14.04 (trusty) from facebook.net mirror
  • whole disk partitioned in to / and swap
  • root is the only user to allowed to login with encrypted password
  • host name set to some-special-name if DHCP does not provide valid one

To make things better, you can configure your DHCP server to have MAC address map to some good name and IP address, then add “–mac=52:54:00:xx:xx:xx” to virt-install command line, the host name and domain from the DHCP server will have higher priority.

Play with it, you will like it. ๐Ÿ˜›

  5 Responses to “Unattended Ubuntu VM installation with preseed”

  1. Hi. Thank you for this much-needed article!

    I’m trying to create a very simple installation image for Ubuntu 14.04. Where does the information under “Launch the installation by:” go and how are you launching the installation?

  2. Nevermind, as I’ve just realised it’s installed in a VM.

    I’m trying to do a similar thing, but with Ubuntu 14.04 desktop. Do you know how to bypass the GUI prompts?

  3. Not sure what you mean “bypass the GUI prompts”, if you want a text-based installation, grab a server/minimal installation disc may be easier, though I guess there is an text-based installation option with desktop disc.

  4. If you want to specify IP (instead of get it from DHCP):

    netcfg/disable_dhcp=true
    netcfg/confirm_static=true
    netcfg/get_ipaddress=192.168.0.101
    netcfg/get_netmask=255.255.255.0
    netcfg/get_gateway=192.168.0.1
    netcfg/get_nameservers=8.8.8.8 8.8.8.4

  5. And if you want to use your own account instead of root:


    d-i passwd/root-login boolean false
    d-i passwd/make-user boolean true
    d-i passwd/user-fullname string Who am I
    d-i passwd/username string joe
    d-i passwd/user-password-crypted password ENCRYPTED
    d-i user-setup/encrypt-home boolean false

Sorry, the comment form is closed at this time.