2013-02-12

Preseed KVM using virt-install

Install a new VM on an LVM volume using preseed and virt-install

The preseed is mostly taken from https://help.ubuntu.com/12.04/installation-guide/example-preseed.txt.

The 'atomic' partman method would not work with LVM, requiring a manual validation.

Instead, the filesystem inside the VM is going to be a regular ext4 partition.

The VM is still stored over an LVM Volume on the host.

  • /root/preseed.cfg
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string
d-i mirror/country string manual
d-i mirror/http/hostname string some.local.ubuntu.mirror.tld
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
d-i clock-setup/utc boolean true
d-i time/zone string US/Eastern
d-i clock-setup/ntp boolean true
# regular as lvm would not work
d-i partman-auto/method string regular
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-auto/choose_recipe select atomic
d-i partman/default_filesystem string ext4
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
d-i passwd/user-fullname string Default User
d-i passwd/username string defaultuser
d-i passwd/user-password password stupidpassword
d-i passwd/user-password-again password stupidpassword
d-i user-setup/encrypt-home boolean false
tasksel tasksel/first multiselect server
d-i pkgsel/update-policy select unattended-upgrades
popularity-contest popularity-contest/participate boolean false
d-i pkgsel/updatedb 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
  • run virt-install
virt-install \
  --disk pool=VG0,size=5 \
  -n test1 --accelerate \
  -r 1024 --connect qemu:///system \
  -l /srv/stuffs/1210-mini.iso \
  --initrd-inject=/root/preseed.cfg \
  --nographics \
  --extra-args="\
      auto=true text\
      console=ttyS0 hostname=test1" \
  --virt-type kvm \
  --os-variant ubuntuquantal