-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathubuntu-18.04.1-desktop-amd64.sh
executable file
·60 lines (52 loc) · 1.07 KB
/
ubuntu-18.04.1-desktop-amd64.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
# Tested on: Ubuntu 18.10.
# https://askubuntu.com/questions/884534/how-to-run-ubuntu-16-04-desktop-on-qemu/1046792#1046792
set -eux
id=ubuntu-18.04.1-desktop-amd64
OPTIND=1
while getopts i: OPT; do
case "$OPT" in
i)
id="$OPTARG"
;;
esac
done
shift "$(($OPTIND - 1))"
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}"
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
# Snapshot the installation.
if [ ! -f "$disk_img_snapshot" ]; then
qemu-img \
create \
-b "$disk_img" \
-f qcow2 \
"$disk_img_snapshot" \
;
fi
# Run the installed image.
qemu-system-x86_64 \
-drive "file=${disk_img_snapshot},format=qcow2" \
-enable-kvm \
-m 2G \
-serial mon:stdio \
-smp 2 \
-soundhw hda \
-vga virtio \
"$@" \
;