Raw VMDK using disk ID

Discussions related to using VirtualBox on Windows hosts.
Post Reply
pderocco
Posts: 22
Joined: 13. Apr 2020, 02:11

Raw VMDK using disk ID

Post by pderocco »

I'm running a Win7 guest under a Win10 host, and it's using a VMDK that refers to an entire physical drive as "\\.\PhysicalDrive2". Sometimes this path changes. Is there a way to reference the drive by some fixed id in Windows? I've found descriptions of how to do this on a Linux host, but not in Windows. There is a 32-bit id that can be retrieved by the diskpart "uniqueid disk" command, but is there a way to refer to a disk by that id in the vmdk file?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Raw VMDK using disk ID

Post by scottgus1 »

pderocco wrote:Sometimes this path changes. Is there a way to reference the drive by some fixed id in Windows?
Unfortunately, no, not on Windows. Thus the expert status of Raw Disk Access. You need to check that number each time lest the wrong disk gets used.

There may be (and I believe there is) some unique UUID or other such number for each drive accessible through a Diskpart script or WMI search that can cross-tabulate each disk's UUID and physical disk number. A VBscript could be made to gather the information, determine the correct physical disk number, then write the raw disk access file before starting the VM.
pderocco
Posts: 22
Joined: 13. Apr 2020, 02:11

Re: Raw VMDK using disk ID

Post by pderocco »

Is there a way to invoke such a script or program from the .vbox file?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Raw VMDK using disk ID

Post by scottgus1 »

No, it would only be from a batch file or shortcut. Virtualbox does not have a setting for running a script before starting the VM, though that could be a useful addition.

You'd have to be careful to use the script to start the VM, not the main Virtualbox window.
Post Reply