Last active
May 25, 2020 02:57
-
-
Save raylee/a83fa819897c47e240e02701bc2d0da5 to your computer and use it in GitHub Desktop.
example of creating an openbsd 6.6 virtual machine with virt-install / kvm
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 | |
| OWNER=libvirt-qemu:libvirtd | |
| RELEASE=https://cloudflare.cdn.openbsd.org/pub/OpenBSD/6.6/amd64 | |
| function sudo { | |
| command sudo -p "Please enter password for %u@%h to fiddle with virtual machines: " ls /dev/null >/dev/null | |
| command sudo "$@" | |
| } | |
| function get { | |
| sudo wget "$1" | |
| } | |
| function download { | |
| cd /var/lib/libvirt/boot/ | |
| sudo mkdir -p openbsd66 | |
| cd openbsd66 | |
| get $RELEASE/SHA256 | |
| get $RELEASE/SHA256.sig | |
| for file in $(sudo egrep -o '(\(.*\))' SHA256 | tr -d '()'); do | |
| get $RELEASE/$file | |
| sudo chown $OWNER $file | |
| done | |
| signify-openbsd -C SHA256.sig | |
| } | |
| function install { | |
| sudo virt-install \ | |
| --name=openbsd66 \ | |
| --virt-type=kvm \ | |
| --memory=1024,maxmemory=1024 \ | |
| --vcpus=1,maxvcpus=1 \ | |
| --cpu host \ | |
| --os-variant=openbsd6.3 \ | |
| --cdrom=/var/lib/libvirt/boot/openbsd66/install66.iso \ | |
| --network=bridge=lxcbr0,model=virtio,mac=52:54:00:0b:5d:66 \ | |
| --boot menu=on,useserial=on \ | |
| --graphics=none \ | |
| --console pty,target_type=virtio \ | |
| --serial pty \ | |
| --disk path=/var/lib/libvirt/images/openbsd.qcow2,size=10,bus=virtio,format=qcow2 | |
| # most of the input, give or take | |
| # set tty com0 | |
| # boot | |
| # I | |
| # \n | |
| # openbsd66 | |
| # vio0 | |
| # 10.0.1.66 | |
| # 255.255.255.0 | |
| # none | |
| # done | |
| # 10.0.1.1 | |
| # v.evq.io | |
| # 10.0.1.1 | |
| # root | |
| # root | |
| # yes | |
| # yes | |
| # 115200 | |
| # username | |
| # password | |
| # password | |
| # no | |
| # \n | |
| # sd0 | |
| # w | |
| # a | |
| # \n | |
| # \n | |
| # done | |
| # yes | |
| # done | |
| # r | |
| } | |
| function delete { | |
| sudo virsh destroy openbsd66 | |
| sudo virsh undefine openbsd66 | |
| } | |
| case $1 in | |
| download) download ;; | |
| install) install ;; | |
| delete) delete ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment