]> Operation on file "\\.\PyshicalDrive0" failed. 🌐:aligrant.com

Operation on file "\\.\PyshicalDrive0" failed.

Alastair Grant | Wed 15 Nov 2023

One of the things I like about VMware Worksation (which is now free), is the ability to attach a physical disk to a virtual machine.  This is really handy for working on a disk that's going to be plugged into another computer at somepoint, or to pull out data off a drive from another computer, without having to mount it in your main OS.

When I've done this on Windows, I've occasionally get sporadic errors popping up, with the drive number varying on the host configuration:

Operation on file "\\.\PyshicalDrive0" failed.

You're presented with options to Retry, Continue, or Cancel.  Retrying usually gets you the same error, Continuing escalates I/O errors to the guest, which may or may not like that, and Cancel tends to crash the whole VM immediately.

The issue here is the guest is trying to do something on the drive that is not allowed, and for me I found the workaround was thus.

  1. Through an Administrative command prompt, run diskpart:
    diskpart
  2. Identify the disk you're working with (don't get the wrong one!!):
    list disk
  3. Select the disk you're working with by using the number from the previous step (still don't get the wrong one!!):
    select disk 99
  4. Offline the disk (this stops Windows from doing things with it):
    offline disk
  5. Clear the read-only attribute from the disk:
    attributes disk clear readonly
  6. Quit:
    exit

This should enable you to use the disk in VMware Workstation without it erroring frequently.

Breaking from the voyeuristic norms of the Internet, any comments can be made in private by contacting me.

Related