assuming the host is up and running already
warning: Ubuntu is more painful than Debian in this case – choose Debian
guest=focal guest=buster country=fr country=ru mkdir -p /data/guests/$guest/ cd /data/guests/$guest/ osinfo-query os | grep ubuntu | sort -k3 -t'|' -V osinfo-query os | grep debian | sort -k3 -t'|' -V grep short-id /usr/share/osinfo/os/ubuntu.com/ubuntu-20*.xml grep short-id /usr/share/osinfo/os/debian.org/debian-10*.xml virt-install --name $guest --vcpus 12 --ram 1024 \ --disk path=/data/guests/$guest/$guest.qcow2,size=26,bus=virtio \ --network bridge=virbr0,model=virtio \ --graphics none --accelerate \ --console pty,target_type=serial --extra-args 'console=ttyS0,115200n8 serial' \ # ubuntu --os-type linux --os-variant ubuntu20.04 \ --location http://$country.archive.ubuntu.com/ubuntu/dists/$guest/main/installer-amd64/ # debian --os-type linux --os-variant debian10 \ --location http://deb.debian.org/debian/dists/buster/main/installer-amd64/
eventually use generic because lastest distro releases are not always available within osinfo-db
# --os-type linux --os-variant generic \
choose locale, mirror and timezone accordingly, and select those package groups during the installation process
# ubuntu basic ubuntu server openssh server # debian ssh server standard system utilities
once the machine reboots, either it’s an Ubuntu and you need to escape the empty console and shutdown the guest – ideally even before it reboots
ctrl-] reset virsh shutdown focal virsh list --all
or it’s a Debian and you’re good already, there was no kernel messages but you got the prompt.
you need to fix GRUB setup for talking to the serial console
mkdir -p /data/guests/$guest/lala/ cd /data/guests/$guest/ guestmount --help guestmount --domain $guest --inspector lala/ # --rw
grub-update
will complain, even if you mount /dev/
and everything, because the /dev/vda
device is unknown to the chroot
grub-probe: error: unknown filesystem.
hence fix grub.cfg
manually and like a dirty bastard
cp -pi lala/boot/grub/grub.cfg lala/boot/grub/grub.cfg.dist vi lala/boot/grub/grub.cfg (search for vmlinuz) ... console=ttyS0,19200 earlyprint=serial,ttyS0,115200 guestunmount lala/
and eventually do it properly once the guest has booted
virsh start $guest --console cp -pi /etc/default/grub /etc/default/grub.dist vi /etc/default/grub GRUB_DEFAULT=0 #GRUB_TIMEOUT_STYLE=hidden GRUB_TIMEOUT=3 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="" GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8 netcfg/do_not_use_netplan=true net.ifnames=0 biosdevname=0 mitigations=off"
and note this is already there
GRUB_TERMINAL=serial GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
apply
update-grub sync
The kernel messages were missing on the serial console
cp -pi /etc/default/grub /etc/default/grub.dist vi /etc/default/grub GRUB_DEFAULT=0 GRUB_TIMEOUT=3 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="" GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 mitigations=off"
and note this is already there
GRUB_TERMINAL=serial GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1"
apply
update-grub sync
cat /sys/devices/system/clocksource/clocksource0/available_clocksource cat /sys/devices/system/clocksource/clocksource0/current_clocksource passwd -d root userdel -r nouser mkdir .ssh/ vi .ssh/authorized_keys (deploy your SSH pubkey over there) chmod 700 .ssh/ chmod 600 .ssh/authorized_keys
cd /etc/ ln -sf ../usr/share/zoneinfo/Europe/Moscow echo Europe/Moscow > timezone ln -sf ../usr/share/zoneinfo/Europe/Paris echo Europe/Paris > timezone apt update apt install ifupdown net-tools rmdir /etc/network/interfaces.d/ vi /etc/network/interfaces auto lo iface lo inet loopback allow-hotplug eth0 iface eth0 inet dhcp allow-hotplug eth1 iface eth1 inet manual poweroff
poweroff virsh start $guest --console #virsh console $guest
eventually make it available for GNS3
draft
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,
ssh-keygen
and finally run a guest,
uvt-kvm create guestuvt uvt-kvm list virsh list
and access it,
uvt-kvm ssh guestuvt
https://cloud-images.ubuntu.com/artful/current/
https://www.cyberciti.biz/faq/how-to-use-kvm-cloud-images-on-ubuntu-linux/
https://help.ubuntu.com/lts/serverguide/cloud-images-and-uvtool.html
https://askubuntu.com/questions/909617/libvirt-virsh-console-no-response
https://serverfault.com/questions/364895/virsh-vm-console-does-not-show-any-output
Creating a new guest https://wiki.debian.org/KVM#Creating_a_new_guest –> location
https://docs.openstack.org/image-guide/convert-images.html
https://help.ubuntu.com/community/KVM/CreateGuests
https://bugs.launchpad.net/ubuntu/+source/vm-builder/+bug/1618899