Last active
November 19, 2020 19:43
-
-
Save lucaspwbx/b60693dc127dae73c28901338ba64be4 to your computer and use it in GitHub Desktop.
launch ubuntu box with a good setup
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
#!/usr/bin/env bash | |
set -eux | |
# Parameters. | |
id=pop-os_20.10_amd64_intel_2 | |
disk_img="${id}.img.qcow2" | |
disk_img_snapshot="${id}.snapshot.qcow2" | |
iso="${id}.iso" | |
# Get image. | |
if [ ! -f "$iso" ]; then | |
# wget "http://releases.ubuntu.com/18.04/${iso}" | |
wget "https://pop-iso.sfo2.cdn.digitaloceanspaces.com/20.10/amd64/intel/2/${iso}" | |
fi | |
# Go through installer manually. | |
if [ ! -f "$disk_img" ]; then | |
qemu-img create -f qcow2 "$disk_img" 1T | |
qemu-system-x86_64 \ | |
-cdrom "$iso" \ | |
-drive "file=${disk_img},format=qcow2" \ | |
-enable-kvm \ | |
-m 2G \ | |
-smp 2 \ | |
; | |
fi | |
# Create an image based on the original post-installation image | |
# so as to keep a pristine post-install image. | |
if [ ! -f "$disk_img_snapshot" ]; then | |
qemu-img \ | |
create \ | |
-b "$disk_img" \ | |
-f qcow2 \ | |
"$disk_img_snapshot" \ | |
; | |
fi | |
# Run the copy of the installed image. | |
qemu-system-x86_64 \ | |
-drive "file=${disk_img_snapshot},format=qcow2" \ | |
-enable-kvm \ | |
-m 2G \ | |
-smp 2 \ | |
-soundhw hda \ | |
-vga virtio \ | |
"$@" \ | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment