Creating KVM guests


ifconfig xenbr0
osinfo-query os | grep centos


using generic because arful does not exist yet into osinfo (Jan 2018),

virt-install \
--name artful \
--ram 512 \
--disk path=/data/kvm/artful.qcow2,size=8,bus=virtio \
--vcpus 2 \
--os-type linux \
--os-variant generic \
--network bridge=xenbr0,model=virtio \
--graphics none \
    --accelerate \
--console pty,target_type=serial \
--location '' \
--extra-args 'console=ttyS0,115200n8 serial'


you need to fix GRUB setup for talking to the serial console,

mkdir -p /tmp/kvmloop/
guestmount --help
guestmount -d ubuntu17.10 -i /tmp/kvmloop

grub-update has troubles inside the image chroot,

grub-probe: error: unknown filesystem.

so fix grub like a dirty bastard,

cp -pi /tmp/kvmloop/boot/grub/grub.cfg /tmp/kvmloop/boot/grub/grub.cfg
vi /tmp/kvmloop/boot/grub/grub.cfg

(vmlinuz lines... after ro) console=ttyS0,19200 earlyprint=serial,ttyS0,115200

guestunmount /tmp/kvmloop

and eventually do it properly once the guest has booted,

cd /etc/default/
cp -pi grub grub.dist
vi grub

GRUB_CMDLINE_LINUX='console=tty0 console=ttyS0,115200n8'
GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"



netbsd then serial

either launch the installation with graphics,

 virt-install \
    --name netbsd \
    --ram 128 \
    --disk path=/data/kvm/netbsd.qcow2,size=2,bus=virtio \
    --vcpus 1 \
    --os-type generic \
    --os-variant generic \
    --network bridge=xenbr0,model=virtio \
    --graphics vnc,port=5999 \
    --console pty,target_type=serial \
    --cdrom /data/ISO-IMAGES/NetBSD-7.1-amd64.iso

and define com0/115200 for boot blocks

netbsd serial right away

or use the boot-com.iso to start from serial console right away!

wget -O - > /data/guests/ISO-IMAGES/boot-com.iso
wget -O - > /data/guests/ISO-IMAGES/SHA512.netbsd.bootcom

virt-install \
    --virt-type kvm \
    --name netbsdserial \
    --ram 128 \
    --disk path=/data/kvm/netbsdserial.qcow2,size=2,bus=virtio \
    --vcpus 1 \
    --network bridge=xenbr0,model=virtio \
    --graphics none \
    --console pty,target_type=serial \
    --accelerate \
    --noautoconsole \
    --cdrom /data/ISO-IMAGES/boot-com.iso \
    --cpu host

during the installation, choose com0 and baud rate as for boot blocks, and you are good to continue with virsh console already.

Note. the only drawback with the boot-com.iso method is that you will have to provide another source than CDROM as for the installation sets (e.g. network through vioif0). The command,

/sbin/mount -rt cd9660 /dev/cd0a /mnt2

does not work during the installation when using boot-com.iso (83M instead of 374M for the full one).




ubuntu-vm-builder kvm xenial --name guestbuilder --libvirt qemu:///system
#--components 'main,universe,restricted'
tail -F /tmp/tmpARZ01Y



apt install uvtool
uvt-simplestreams-libvirt sync release=xenial arch=amd64
uvt-simplestreams-libvirt sync release=artful arch=amd64

it wants an RSA key pair, not ECDSA or what ever is much better, so let us give this crappy tool some slack,


and finally run a guest,

uvt-kvm create guestuvt
uvt-kvm list
virsh list

and access it,

uvt-kvm ssh guestuvt


Tuning KVM

Tuning Kernel


Chapter 6. Overcommitting with KVM

Chapter 7. KSM

How to use the Kernel Samepage Merging feature

KVM host won’t use memory for caching

Virtualization (KVM) and excessive cached RAM

Kernel same-page merging