Intro

This is taggart’s process for generating lightweight debian VM images that use serial console and libvirt to run them.

Setup vmdb2 yaml file:

steps:
  - mkimg: "{{ output }}"
    size: 2G

  - mklabel: msdos
    device: "{{ output }}"

  - mkpart: primary
    device: "{{ output }}"
    start: 0%
    end: 100%
    tag: root

  - kpartx: "{{ output }}"

  - mkfs: ext4
    partition: root

  - mount: root

  - debootstrap: sid
    mirror: http://mirror:9999/debian
    target: root

  - apt: install
    packages:
      - linux-image-amd64
    tag: root

  - grub: bios
    tag: root
    console: serial

  - chroot: root
    shell: |
       echo "root:test" |chpasswd root

Create VM image

# vmdb2 test.vmdb --output test.img --verbose

Create VM

# virt-install --connect qemu:///system --virt-type kvm --name test --vcpus 2 --memory 1024 --disk size=10,path=/srv/kvm/test.img,format=raw --import --network bridge=br0 --os-type linux --os-variant debiantesting --noautoconsole

Utility commands