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
|
#! /bin/bash -x
#
# This script helps creating a new LibVirt domain starting from a base image
#
# Run as root user
#
# TODO: fill in the variables below with proper values
# ----------------------------------------------------
BASE_IMAGE=
domain_name=
cpus=
disk_size=
memory=
mac=
# ----------------------------------------------------
test -f /var/lib/libvirt/images/${domain_name}.qcow2 || cp -i ${BASE_IMAGE} /var/lib/libvirt/images/${domain_name}.qcow2
qemu-img resize /var/lib/libvirt/images/${domain_name}.qcow2 +${disk_size}G
virt-install \
--name ${domain_name} \
--vcpus ${cpus} \
--memory ${memory} \
--network bridge=virbr0,mac=${mac}\
--graphics none\
--virt-type kvm\
--disk /var/lib/libvirt/images/${domain_name}.qcow2,size=${disk_size}\
--boot hd \
--osinfo detect=on,require=off --import
|