{"id":1676,"date":"2014-03-12T13:42:44","date_gmt":"2014-03-12T20:42:44","guid":{"rendered":"http:\/\/xiehang.com\/blog\/?p=1676"},"modified":"2014-03-20T06:59:51","modified_gmt":"2014-03-20T13:59:51","slug":"unattended-ubuntu-vm-installation-with-preseed","status":"publish","type":"post","link":"https:\/\/xiehang.com\/blog\/2014\/03\/12\/unattended-ubuntu-vm-installation-with-preseed\/","title":{"rendered":"Unattended Ubuntu VM installation with preseed"},"content":{"rendered":"

This article<\/a> discussed how to install CentOS VM automatically with kickstart<\/a>. 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.<\/p>\n

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

d-i netcfg\/choose_interface select eth0<\/p>\n

d-i base-installer\/kernel\/override-image string linux-server
\nd-i clock-setup\/utc-auto boolean true
\nd-i clock-setup\/utc boolean true
\nd-i time\/zone string US\/Pacific
\nd-i clock-setup\/ntp boolean true<\/p>\n

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

d-i partman-auto\/disk string \/dev\/vda
\nd-i partman-auto\/method string regular
\nd-i partman-auto\/choose_recipe select atomic
\nd-i partman\/default_filesystem string ext4
\nd-i partman\/confirm_write_new_label boolean true
\nd-i partman\/choose_partition select finish
\nd-i partman\/confirm boolean true
\nd-i partman\/confirm_nooverwrite boolean true<\/p>\n

d-i passwd\/make-user boolean false
\nd-i passwd\/root-password-crypted password i-wont-tell-you-for-sure
\nd-i passwd\/root-login boolean true
\nd-i user-setup\/encrypt-home boolean false<\/p>\n

d-i grub-installer\/only_debian boolean true
\nd-i grub-installer\/with_other_os boolean true
\nd-i finish-install\/reboot_in_progress note
\n[\/raw]<\/p>\n

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

After the unattended installation finished, you will have:<\/p>\n