Skip to content

Commit 7d4917d

Browse files
committed
image_to_vm: add support for hyper-v vhdx format
Add support for Gen 2 Hyper-V VMs. `./image_to_vm` tool has now a new supported format: `hyperv_vhdx`, that produces .vhdx dynamic disks. How to use: ```bash ./image_to_vm.sh --from ../build/images/amd64-usr/developer-latest/ --format hyperv_vhdx ``` See: flatcar/Flatcar#1009 Uses PR: flatcar/bootengine#92 Signed-off-by: Adrian Vladu <avladu@cloudbasesolutions.com>
1 parent fd2766c commit 7d4917d

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

build_library/release_util.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ compress_disk_images() {
8989
# We want to compress images, but we also want to remove the uncompressed files
9090
# from the list of uploadable files.
9191
for filename in "${local_files_to_evaluate[@]}"; do
92-
if [[ "${filename}" =~ \.(img|bin|vdi|vhd|vmdk)$ ]]; then
92+
if [[ "${filename}" =~ \.(img|bin|vdi|vhd|vhdx|vmdk)$ ]]; then
9393
# Parse the formats as an array. This will yield an extra empty
9494
# array element at the end.
9595
readarray -td, FORMATS<<<"${FLAGS_image_compression_formats},"

build_library/vm_image_util.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ VALID_IMG_TYPES=(
1616
exoscale
1717
gce
1818
hyperv
19+
hyperv_vhdx
1920
iso
2021
openstack
2122
openstack_mini
@@ -297,6 +298,11 @@ IMG_azure_OEM_SYSEXT=oem-azure
297298
IMG_hyperv_DISK_FORMAT=vhd
298299
IMG_hyperv_OEM_PACKAGE=oem-hyperv
299300

301+
## hyper-v vhdx
302+
IMG_hyperv_vhdx_DISK_FORMAT=vhdx
303+
IMG_hyperv_vhdx_OEM_PACKAGE=oem-hyperv
304+
305+
300306
## cloudsigma
301307
IMG_cloudsigma_DISK_FORMAT=qcow2
302308
IMG_cloudsigma_OEM_PACKAGE=oem-cloudsigma
@@ -431,7 +437,9 @@ _disk_ext() {
431437
vmdk_scsi) echo vmdk;;
432438
vmdk_stream) echo vmdk;;
433439
hdd) echo hdd;;
434-
vhd*) echo vhd;;
440+
vhd) echo vhd;;
441+
vhd_fixed) echo vhd;;
442+
vhdx) echo vhdx;;
435443
*) echo "${disk_format}";;
436444
esac
437445
}
@@ -620,6 +628,11 @@ _write_vhd_fixed_disk() {
620628
assert_image_size "$2" vpc
621629
}
622630

631+
_write_vhdx_disk() {
632+
qemu-img convert -f raw "$1" -O vhdx -o subformat=dynamic "$2"
633+
assert_image_size "$2" vhdx
634+
}
635+
623636
_write_vmdk_ide_disk() {
624637
qemu-img convert -f raw "$1" -O vmdk -o adapter_type=ide "$2"
625638
assert_image_size "$2" vmdk
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Added Hyper-V VHDX image ([flatcar/scripts#1791](https://github.com/flatcar/scripts/pull/1791))

0 commit comments

Comments
 (0)