From f2bcf86aca83d25dd76f9ed373dad22a187362a9 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 14 Apr 2020 14:33:05 -0700 Subject: [PATCH] Allow shrinking vhdx disk formats for hyperv provider --- plugins/providers/hyperv/cap/configure_disks.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/providers/hyperv/cap/configure_disks.rb b/plugins/providers/hyperv/cap/configure_disks.rb index 36d124574..0782d1e9d 100644 --- a/plugins/providers/hyperv/cap/configure_disks.rb +++ b/plugins/providers/hyperv/cap/configure_disks.rb @@ -123,9 +123,13 @@ module VagrantPlugins defined_disk_size = disk_actual["Size"] if defined_disk_size > requested_disk_size - # TODO: Check if disk (maybe use file path) is of type `VHDX`. If not, the disk cannot be shrunk - machine.ui.warn(I18n.t("vagrant.cap.configure_disks.shrink_size_not_supported", name: disk_config.name)) - return false + if File.extname(disk_actual["Path"]) == ".vhdx" + # VHDX formats can be shrunk + return true + else + machine.ui.warn(I18n.t("vagrant.cap.configure_disks.shrink_size_not_supported", name: disk_config.name)) + return false + end elsif defined_disk_size < requested_disk_size return true else