From d16b8e1696a50d5aca6bcce02a220069bfed0e87 Mon Sep 17 00:00:00 2001 From: dandaolrian <86479955+dandaolrian@users.noreply.github.com> Date: Wed, 29 Nov 2023 23:51:19 +0100 Subject: [PATCH] fix(vm): resize image once imported (#753) fix(vm): Resize image once imported #737 Signed-off-by: dandalorinan --- proxmoxtf/resource/vm.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/proxmoxtf/resource/vm.go b/proxmoxtf/resource/vm.go index c7b951948..494b905dc 100644 --- a/proxmoxtf/resource/vm.go +++ b/proxmoxtf/resource/vm.go @@ -2809,12 +2809,10 @@ func vmCreateCustomDisks(ctx context.Context, d *schema.ResourceData, m interfac fmt.Sprintf(`file_path_tmp="%s"`, filePathTmp), fmt.Sprintf(`vm_id="%d"`, vmID), `source_image=$(pvesm path "$file_id")`, - `cp "$source_image" "$file_path_tmp"`, - `qemu-img resize -f "$file_format" "$file_path_tmp" "${disk_size}G"`, - `imported_disk="$(qm importdisk "$vm_id" "$file_path_tmp" "$datastore_id_target" -format $file_format | grep "unused0" | cut -d ":" -f 3 | cut -d "'" -f 1)"`, + `imported_disk="$(qm importdisk "$vm_id" "$source_image" "$datastore_id_target" -format $file_format | grep "unused0" | cut -d ":" -f 3 | cut -d "'" -f 1)"`, `disk_id="${datastore_id_target}:$imported_disk${disk_options}"`, `qm set "$vm_id" "-${disk_interface}" "$disk_id"`, - `rm -f "$file_path_tmp"`, + `qm resize "$vm_id" "${disk_interface}" "${disk_size}G"`, ) importedDiskCount++