additional post image hook to assist in img conversion to qcow2 for virtual-qemu image

This commit is contained in:
Lane Jennison 2021-07-11 14:03:22 -04:00
parent 1098ed436d
commit 6ee2ce463a
2 changed files with 22 additions and 6 deletions

View File

@ -1,20 +1,21 @@
# Armbian virtual ARM64 image for qemu
#
#
# produces a single partition VM image in qcow2 format.
# how to use
# the resulting cache/sources/u-boot/v22021.04/u-boot.bin will need to be copied.. that is your bios
# i recommend converting image to qcow2 adn resize
# qemu-img convert -f raw -O qcow2 original.img armbian.qcow2
# how to run on linux
##!/bin/bash
#
#export image=armbian.qcow2
#export image=armbian.img
#smp=4
#rams=1000M
#bios=u-boot.bin
#/usr/bin/qemu-system-aarch64 -name ArmbianVirtualTest -m ${rams} -smp ${smp} -drive file=${image} -nographic -enable-kvm -M virt -cpu host -bios ${bios} -netdev user,id=user.0,hostfwd=udp::31783-:22,hostfwd=tcp::31783-:22 -device virtio-net,netdev=user.0 -machine gic-version=3
#
#how to run on mac... i'm using utm and making a custom config...
#/Applications/UTM.app/Contents/XPCServices/QEMUHelper.xpc/Contents/MacOS/QEMULauncher /Applications/UTM.app/Contents/Frameworks/libqemu-aarch64-softmmu.utm.dylib -L /Applications/UTM.app/Contents/Resources/qemu -S -qmp tcp:127.0.0.1:4000,server,nowait -vga none -spice port=4001,addr=127.0.0.1,disable-ticketing,image-compression=off,playback-compression=off,streaming-video=off -device virtio-ramfb -cpu host -smp cpus=8,sockets=1,cores=8,threads=1 -machine none,highmem=off -accel hvf -accel tcg,tb-size=1024 -boot menu=on -m 4096 -name armbian -usb -device virtio-blk-pci,drive=drive0,bootindex=0 -drive if=none,media=disk,id=drive0,file=/Users/lane/Library/Containers/com.utmapp.UTM/Data/Documents/armbian.utm/Images/armbian.qcow2,cache=writethrough -device virtio-net-device,mac=AE:C6:BD:B0:F1:33,netdev=net0 -netdev user,id=net0 -uuid 3952DB60-A50E-4838-BAAE-BD13C526CC7A -rtc base=localtime -M virt -cpu host -accel hvf -bios u-boot.bin -device virtio-mouse -device virtio-keyboard
#how to run on mac... i'm using utm and making a custom config...
#
#/Applications/UTM.app/Contents/XPCServices/QEMUHelper.xpc/Contents/MacOS/QEMULauncher /Applications/UTM.app/Contents/Frameworks/libqemu-aarch64-softmmu.utm.dylib -L /Applications/UTM.app/Contents/Resources/qemu -S -qmp tcp:127.0.0.1:4000,server,nowait -vga none -spice port=4001,addr=127.0.0.1,disable-ticketing,image-compression=off,playback-compression=off,streaming-video=off -device virtio-ramfb -cpu host -smp cpus=8,sockets=1,cores=8,threads=1 -machine none,highmem=off -accel hvf -accel tcg,tb-size=1024 -boot menu=on -m 4096 -name armbian -usb -device virtio-blk-pci,drive=drive0,bootindex=0 -drive if=none,media=disk,id=drive0,file=/Users/lane/Library/Containers/com.utmapp.UTM/Data/Documents/armbian.utm/Images/armbian.img,cache=writethrough -device virtio-net-device,mac=AE:C6:BD:B0:F1:33,netdev=net0 -netdev user,id=net0 -uuid 3952DB60-A50E-4838-BAAE-BD13C526CC7A -rtc base=localtime -M virt -cpu host -accel hvf -bios u-boot.bin -device virtio-mouse -device virtio-keyboard
#
BOARD_NAME="virtual qemu"
BOARDFAMILY="virtual"
@ -29,3 +30,16 @@ USE_OVERLAYFS='no'
BOOT_USE_MAINLINE_ATF=yes
BOOT_SOC=qemu
EXTRAWIFI='no'
ROOTFS_TYPE="ext4"
post_build_image_modify() {
local IMAGE_PATH=${1}
##fixme put this where it belongs
apt install -y qemu-utils
display_alert "converting image to qcow2 format" "$(qemu-img convert -f raw -O qcow2 ${IMAGE_PATH} ${IMAGE_PATH}.qcow2)" "info"
display_alert "resizing qcow2 image to 50G" "$(qemu-img resize ${IMAGE_PATH}.qcow2 50G)" "info"
display_alert "shuffling image files" "$(mv -vf ${IMAGE_PATH}.qcow2 ${IMAGE_PATH})" "info"
display_alert "check img format" "$(qemu-img info ${IMAGE_PATH} | fgrep qcow2)" "info"
}

View File

@ -774,7 +774,9 @@ create_image()
if [[ -z $SEND_TO_SERVER ]]; then
# custom post_build_image_modify hook to run before fingerprinting and compression
[[ $(type -t post_build_image_modify) == function ]] && display_alert "Custom Hook Detected" "post_build_image_modify" "info" && post_build_image_modify "${DESTIMG}/${version}.img"
if [[ $COMPRESS_OUTPUTIMAGE == "" || $COMPRESS_OUTPUTIMAGE == no ]]; then
COMPRESS_OUTPUTIMAGE="sha,gpg,img"
elif [[ $COMPRESS_OUTPUTIMAGE == yes ]]; then