Add scripts to generate raw images

See: https://github.com/kairos-io/kairos/issues/377
This commit is contained in:
Ettore Di Giacinto
2022-11-03 21:37:32 +00:00
parent 1f932a7644
commit dc55928694
4 changed files with 117 additions and 1 deletions

15
tools-image/azure.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
# Transform a raw image disk to azure vhd
RAWIMAGE="$1"
VHDDISK="${2:-disk.vhd}"
MB=$((1024*1024))
size=$(qemu-img info -f raw --output json "$RAWIMAGE" | gawk 'match($0, /"virtual-size": ([0-9]+),/, val) {print val[1]}')
# shellcheck disable=SC2004
ROUNDED_SIZE=$(((($size+$MB-1)/$MB)*$MB))
echo "Resizing raw image to $ROUNDED_SIZE"
qemu-img resize -f raw "$RAWIMAGE" $ROUNDED_SIZE
echo "Converting $RAWIMAGE to $VHDDISK"
qemu-img convert -f raw -o subformat=fixed,force_size -O vpc "$RAWIMAGE" "$VHDDISK"
echo "Done"