Created
December 25, 2019 19:09
-
-
Save oko/c92948f7984eb9fd0f16b558b4ceb238 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
set -eux | |
iso="$1" | |
hostname="$2" | |
kickstart="$3" | |
test "$(whoami)" == "root" || (echo "must be run as root!" ; exit 1) | |
ks="/var/lib/libvirt/images/$hostname-ks.iso" | |
ksd="$(mktemp -d)" | |
cp "$kickstart" "$ksd/ks.cfg" | |
genisoimage -v -J -r -V OEMDRV -o "$ks" "$ksd/ks.cfg" | |
virt-install \ | |
--name "$hostname" \ | |
--boot uefi \ | |
--qemu-commandline="-boot c" \ | |
--network default \ | |
--console pty \ | |
--vcpus 1 \ | |
--memory 1024 \ | |
--cpu host \ | |
--machine q35 \ | |
--controller type=scsi,model=virtio-scsi \ | |
--disk bus=scsi,size=10,format=qcow2,boot_order=1 \ | |
--disk bus=scsi,path="$iso",device=cdrom,format=raw,boot_order=2 \ | |
--disk bus=scsi,path="$ks",device=cdrom,format=raw \ | |
--check path_in_use=off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment