forked from linux-kdevops/kdevops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirt-install-demo.sh
58 lines (51 loc) · 1.34 KB
/
virt-install-demo.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
#!/bin/bash
# custom virt-install script demo
ISO_URL="http://example.com/linux-release.iso"
REL="somedistro15sp3"
DATE_SHORT="$(date -I | sed -e 's/-//g')"
# Use DISK_BUS="scsi" if you are booting into a kernel which
# is old and does not have virtio
DISK_BUS="virtio"
MEM="2048"
CPUS="2"
QCOW2_SIZE="50g"
# No need to edit anything else below.
VIRT_NAME="${USER}-${REL}"
ISO_FILE="$(basename $ISO_URL)"
ISO_DIR="isos/$REL/"
ISO="$ISO_DIR/$ISO_FILE"
QCOW2_FILE="${REL}-${DATE_SHORT}"
QCOW2_DIR="images/$REL/"
QCOW2="$QCOW2_DIR/$QCOW2_FILE"
set_qcow2()
{
if [ ! -f "$QCOW2" ]; then
mkdir -p $QCOW2_DIR
qemu-img create -f qcow2 $QCOW2 $QCOW2_SIZE
fi
}
get_iso()
{
if [ ! -f "$ISO" ]; then
mkdir -p $ISO_DIR
wget $ISO_URL -O $ISO
fi
}
custom_virt_install()
{
virt-install \
--name $VIRT_NAME \
--memory $MEM \
--vcpus $CPUS \
--network network=default \
--nographics \
--console pty,target_type=serial \
--disk path=$QCOW2,device=disk,bus=$DISK_BUS,format=qcow2 \
--location $ISO \
--location $ISO \
--extra-args 'console=ttyS0,115200n8 serial' \
--os-variant $REL
}
set_qcow2
get_iso
custom_virt_install