-
-
Save dmsimard/5fc6c2125480e470f13fa9eaf7976ba1 to your computer and use it in GitHub Desktop.
Creates a CentOS8 qcow2 image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# From a vanilla centos7 installation | |
yum -y install centos-release-qemu-ev | |
yum -y install libvirt-install libvirt qemu-kvm-ev | |
systemctl enable --now libvirtd | |
curl https://git.centos.org/centos/kickstarts/raw/master/f/CentOS-8-GenericCloud.ks -o /var/tmp/CentOS-8-GenericCloud.ks | |
virt-install \ | |
--name c8-genericcloud \ | |
--vcpus 4 \ | |
--memory memory=4096 \ | |
--disk path=/var/lib/libvirt/images/c8-genericcloud.qcow2,size=20,format=qcow2,device=disk,bus=virtio,cache=none \ | |
--nographics \ | |
--network network=default \ | |
--hvm --accelerate \ | |
--autostart --wait=-1 \ | |
--noautoconsole \ | |
--initrd-inject=/var/tmp/CentOS-8-GenericCloud.ks \ | |
--extra-args "console=ttyAMA0 console=ttyS0 net.ifnames=0 ks=file:/CentOS-8-GenericCloud.ks" \ | |
--location http://mirror.centos.org/centos-8/8/BaseOS/x86_64/os/ | |
virsh destroy c8-genericcloud | |
# Compress from ~1.8GB to ~700MB | |
qemu-img convert -O qcow2 -c c8-genericcloud.qcow2 c8-genericcloud-compressed.qcow2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment