VMware Cloud Community
pratt26
Enthusiast
Enthusiast

HARD DISK 1 AND WINDOWS DISK 0 disk extend

I see that this question has been asked a lot of times, but I don't see a concrete response:

In VRO, trying to extend a VMDK and Windows logical drive in a single workflow. The problem I have is Windows starts at disk 0 and VMWare starts at Hard Disk 1...etc. If you have a VM with multiple disks, then you'll always be ahead by one disk number on the Windows side. Has anyone gotten this working?

Tags (1)
Reply
0 Kudos
2 Replies
sbeaver
Leadership
Leadership

I do not expand C: drives at this point, with that said I use this action in the presentation to get the disk names

var devices = vm.config.hardware.device;

var disks = new Array();

for (i in devices){

    if (devices[i].DeviceInfo.Label.indexOf('Hard disk') >= 0){

        if (devices[i].DeviceInfo.Label != "Hard disk 1"){

            var capacityGB = devices[i].capacityInKB / 1024 / 1024;

            var description = devices[i].deviceInfo.label + "-" + capacityGB + " GB";

            disks.push(description);

        }

    }

}

return disks;

Then I use this to expand based on the name returned above

var devices = vm.config.hardware.device;

System.log(devices)

for (i in devices){

    if (devices[i].deviceInfo.label == diskString){

        var disk = devices[i]

        System.log("Disk = " + disk.deviceInfo.label)

    }

}

var newSizeKB = disk.capacityInKB + (increaseSizeGB * 1024 * 1024)

System.log("New Size KB = " + newSizeKB)

var spec = new VcVirtualMachineConfigSpec();

spec.changeVersion = vm.config.changeVersion;

spec.deviceChange = System.getModule("com.vmware.onyx").array(VcVirtualDeviceConfigSpec, 1);

spec.deviceChange[0] = new VcVirtualDeviceConfigSpec();

spec.deviceChange[0].operation = VcVirtualDeviceConfigSpecOperation.edit;

spec.deviceChange[0].device = new VcVirtualDisk();

spec.deviceChange[0].device.key = disk.key;

spec.deviceChange[0].device.deviceInfo = new VcDescription();

spec.deviceChange[0].device.deviceInfo.label = disk.deviceInfo.label;

spec.deviceChange[0].device.deviceInfo.summary = disk.deviceInfo.summary;

spec.deviceChange[0].device.backing = new VcVirtualDiskFlatVer2BackingInfo();

spec.deviceChange[0].device.backing.fileName = disk.backing.fileName;

spec.deviceChange[0].device.backing.diskMode = disk.backing.diskMode;

spec.deviceChange[0].device.backing.split = disk.backing.split;

spec.deviceChange[0].device.backing.writeThrough = disk.backing.writeThrough;

spec.deviceChange[0].device.backing.thinProvisioned = disk.backing.thinProvisioned;

spec.deviceChange[0].device.backing.uuid = disk.backing.uuid;

spec.deviceChange[0].device.backing.contentId = disk.backing.contentId;

spec.deviceChange[0].device.backing.digestEnabled = disk.backing.digestEnabled;

spec.deviceChange[0].device.controllerKey = disk.controllerKey;

spec.deviceChange[0].device.unitNumber = disk.unitNumber;

spec.deviceChange[0].device.capacityInKB = newSizeKB;

spec.deviceChange[0].device.shares = new VcSharesInfo();

spec.deviceChange[0].device.shares.shares = disk.shares.shares;

spec.deviceChange[0].device.shares.level = disk.shares.level;

spec.deviceChange[0].device.storageIOAllocation = new VcStorageIOAllocationInfo();

spec.deviceChange[0].device.storageIOAllocation.limit = disk.storageIOAllocation.limit;

spec.deviceChange[0].device.storageIOAllocation.shares = new VcSharesInfo();

spec.deviceChange[0].device.storageIOAllocation.shares.shares = disk.storageIOAllocation.shares.shares;

spec.deviceChange[0].device.storageIOAllocation.shares.level = disk.storageIOAllocation.shares.level;

return vm.reconfigVM_Task(spec);

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
pratt26
Enthusiast
Enthusiast

Thanks, I am using this same action, it's helpful as it returns the VMDK disk names. I can't depend on it alone because you could have two disks of the same size, which is a bummer, because I have plenty of code using diskpart to sweep and extend any drive that is not fully extended.

Reply
0 Kudos