forked from YurkoWasHere/tdx-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-efi-img.sh
executable file
·47 lines (39 loc) · 1.1 KB
/
create-efi-img.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
#!/usr/bin/bash
ISO="RHEL-8.7.0-20221013.1-x86_64-dvd1.iso"
# Kickstart scripts
KS_DIR="kickstart"
KS_EFI="base.ks"
KS_OS="rhel-8.ks"
# Guest image size(unit: GB)
IMAGE_SIZE=8
IMAGE_NAME="td-guest-rhel-8.7.qcow2"
VIRT_NAME="setup-guest-rhel-8.7"
CURR_DIR=$(readlink -f "$(dirname "$0")")
pushd "${CURR_DIR}" || exit 1
if ! command -v "virt-install" ; then
echo "virt-install not found, please install package virt-install"
exit 1
fi
eval virt-install \
--name ${VIRT_NAME} \
--cpu host \
--virt-type=kvm \
--ram 16384 \
--vcpus 8 \
--os-type linux \
--os-variant rhel8-unknown \
--network bridge=virbr0 \
--nographics \
--disk=${IMAGE_NAME},bus=virtio,format=qcow2,size=${IMAGE_SIZE} \
--location="${ISO}" \
--initrd-inject ${KS_DIR}/${KS_EFI} \
--initrd-inject ${KS_DIR}/${KS_OS} \
--extra-args="\"inst.ks=file:/${KS_EFI} console=ttyS0,115200\"" \
--destroy-on-exit \
--transient
if [[ -f ${IMAGE_NAME} ]] ; then
echo "[ OK ] EFI image created: ${IMAGE_NAME}"
else
echo "[FAILED] EFI image failed: ${IMAGE_NAME}"
fi
popd || exit 1