mirror-env/mirror-vm

54 lines
1.7 KiB
Makefile
Executable File

#!/usr/bin/make -sf
# script for managing the vm for the csc mirror dev environment
# dependencies =-=-=-=-=-=-=-=
# qemu, genisoimage, ovmf (find the location of OVMF_CODE.fd on your system)
# user config variables =-=-=
disk_size=10G
vm_mem=2G
ovmf_location=/usr/share/edk2-ovmf/x64/OVMF_CODE.fd
install_iso=./ubuntu-20.04.2-live-server-amd64.iso
ssh_port=7777
.PHONY: help create clean run-install run
help:
echo help|create|clean|run-install|run
.ONESHELL:
create:
for i in {1..6}; do
qemu-img create -f qcow2 drive$$i ${disk_size}; done
genisoimage -output seed.iso -volid cidata -joliet -rock user-data meta-data
clean:
rm drive* seed.iso
run-install:
qemu-system-x86_64 -cdrom ${install_iso} -enable-kvm -boot order=d \
-drive file=drive1,if=virtio,id=a,media=disk,format=qcow2 \
-drive file=drive2,if=virtio,id=b,media=disk,format=qcow2 \
-drive file=drive3,if=virtio,id=c,media=disk,format=qcow2 \
-drive file=drive4,if=virtio,id=d,media=disk,format=qcow2 \
-drive file=drive5,if=virtio,id=e,media=disk,format=qcow2 \
-drive file=drive6,if=virtio,id=f,media=disk,format=qcow2 \
-drive file=seed.iso,if=virtio,format=raw \
-bios ${ovmf_location} \
-m ${vm_mem}
run:
qemu-system-x86_64 -enable-kvm -boot order=d \
-drive file=drive1,if=virtio,id=a,media=disk,format=qcow2 \
-drive file=drive2,if=virtio,id=b,media=disk,format=qcow2 \
-drive file=drive3,if=virtio,id=c,media=disk,format=qcow2 \
-drive file=drive4,if=virtio,id=d,media=disk,format=qcow2 \
-drive file=drive5,if=virtio,id=e,media=disk,format=qcow2 \
-drive file=drive6,if=virtio,id=f,media=disk,format=qcow2 \
-bios ${ovmf_location} \
-m ${vm_mem} \
-net user,hostfwd=tcp::${ssh_port}-:22 \
-net nic