forked from derivative-maker/derivative-maker
-
Notifications
You must be signed in to change notification settings - Fork 3
/
4400_convert-raw-to-qcow2
executable file
·62 lines (48 loc) · 1.29 KB
/
4400_convert-raw-to-qcow2
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
61
62
#!/bin/bash
## Copyright (C) 2012 - 2023 ENCRYPTED SUPPORT LP <adrelanos@whonix.org>
## See the file COPYING for copying conditions.
set -x
set -e
true "INFO: Currently running script: $BASH_SOURCE $@"
MYDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$MYDIR"
cd ..
cd help-steps
source pre
source colors
source variables
convert_raw_to_qcow2() {
if [ ! "$dist_build_qcow2" = "true" ]; then
true "${green}INFO: Skipping $BASH_SOURCE, because dist_build_qcow2 is not set to true.${reset}"
return 0
fi
mkdir --parents "${dist_binary_build_folder}"
## Debugging.
qemu-img \
info \
"$binary_image_raw_file"
## Create qcow2 image form raw image.
## VMSIZE defaults to 100G as per help-steps/variables.
qemu-img \
convert \
-p \
-O qcow2 \
-o cluster_size=2M \
-o extended_l2=on,cluster_size=128k \
-o preallocation=metadata \
"$binary_image_raw_file" \
"$binary_image_qcow2_file"
## Debugging.
qemu-img \
info \
"$binary_image_qcow2_file"
true
}
main() {
if [ "$dist_build_qcow2" = "true" ]; then
convert_raw_to_qcow2
else
true "${green}INFO: Skipping $BASH_SOURCE, because dist_build_qcow2 is not set to 'true'.${reset}"
fi
}
main "$@"