0

I'm need of finding a way to programatically determine if the Guest virtual machine disk is a GPT or MBR partition .I'm not able to achieve this with vijava or Vddk api's . Is there any other c++ or java libraries that can help me to achieve this . Or parsing the MBR manually is the only solution available.

Thanks in Advance,

Thiyagarajan A.

Thiyagarajan
  • 1,271
  • 1
  • 14
  • 19
  • 1
    I haven't actually verified, but it seems unlikely that the API would provide this information because VMware has no need to know what kind of data is on a disk. All VMware needs to do is present the block devices to the virtual machine and start executing the BIOS or UEFI code. It doesn't need to know what (if anything) is on the disks to do that. I expect you will have to inspect the disks yourself. – nobody May 16 '14 at 17:17

1 Answers1

0

You need use VMWare tools installed on your guests and run commands inside the guest. This article illustrates how to do so using vijava: http://www.doublecloud.org/2012/02/run-program-in-guest-operating-system-on-vmware/

If you use windows I recommend PowerCLI + Invoke-VmScript cmdlet(https://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Invoke-VMScript.html)

It will allow you to run a powershell command (for a windows boxes) to determine partition layout. The following lines will return $True if GPT partition is detected.

$disks = gwmi -query "Select * from Win32_DiskPartition" 
foreach($disk in $disks) { 
    if ($disk.Type.StartsWith("GPT")){ 
        return $true
    }
}

Similarly, on a linux guests something like this will achieve desired effect:

fdisk -l | grep -i gpt > /dev/null ; echo $?

Above command will return 0 if GPT partitions exits because you should get a warning "WARNING: GPT (GUID Partition Table) detected on.." which grep -i gpt will pick up.

Raf
  • 9,681
  • 1
  • 29
  • 41