Skip to content

Instantly share code, notes, and snippets.

@kabakaev
Created January 8, 2021 11:11
Show Gist options
  • Select an option

  • Save kabakaev/ddb9900482f5f8fa7f2f29671b68c8a9 to your computer and use it in GitHub Desktop.

Select an option

Save kabakaev/ddb9900482f5f8fa7f2f29671b68c8a9 to your computer and use it in GitHub Desktop.
start ubuntu KVM machine

Choose an image: https://cloud-images.ubuntu.com/daily/server/groovy/current/

See also https://serverascode.com/2018/06/26/using-cloud-images.html

cd /tmp
wget -c https://cloud-images.ubuntu.com/daily/server/groovy/current/groovy-server-cloudimg-amd64-disk-kvm.img
qemu-img resize groovy-server-cloudimg-amd64-disk-kvm.img 20G
virt-customize -a groovy-server-cloudimg-amd64-disk-kvm.img --root-password password:ubuntu
virt-customize -a groovy-server-cloudimg-amd64-disk-kvm.img --uninstall cloud-init
virsh define vm.xml
virsh start vm1
virsh console vm1

User is root and password is ubuntu.

Inside machine,

growpart /dev/vda 1
resize2fs /dev/vda1
dhclient
ip ad
apt update
apt install network-manager
touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
systemctl restart NetworkManager
<domain type='kvm'>
<name>vm1</name>
<memory unit='GiB'>8</memory>
<currentMemory unit='GiB'>8</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch='x86_64'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/tmp/groovy-server-cloudimg-amd64-disk-kvm.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<interface type='bridge'>
<source network='default' bridge='virbr0'/>
<model type='virtio'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
</devices>
</domain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment