Skip to content

Instantly share code, notes, and snippets.

@x011
Created February 20, 2025 01:49
Show Gist options
  • Save x011/09eed44b731d3a1dbca481a4c6c7ff1c to your computer and use it in GitHub Desktop.
Save x011/09eed44b731d3a1dbca481a4c6c7ff1c to your computer and use it in GitHub Desktop.
๐Ÿ› ๏ธ How to Recover VMware Virtual Machine Files When the Parent Disk is Deleted, Removed, or Corrupted ๐Ÿ’พ

๐Ÿ› ๏ธ How to Recover VMware Virtual Machine Files When the Parent Disk is Deleted, Removed, or Corrupted ๐Ÿ’พ

๐Ÿšจ Error Message Example:

File not found: 449_win-000004.vmdk

This file is required to power on this virtual machine. If this file was moved, specify the new location.

2025-02-20_00h56_43

If you've just moved the file, the solution is simple: browse and select the missing file.
However, if the file was deleted or corrupted, you'll need to follow a few extra steps to recover your data.


๐Ÿ› ๏ธ Tools Youโ€™ll Need:

๐Ÿ”น QEMU Windows Binaries โ€“ Get them here
๐Ÿ”น TestDisk โ€“ Download here


๐Ÿ“‚ Step 1: Navigate to Your Virtual Machine Directory

Locate the folder where your VMware virtual machine files are stored.


๐Ÿ“ Step 2: Create and Edit a New VMDK File

1๏ธโƒฃ Make a Copy

  • Find the first .vmdk file (e.g., 449_win-cl1.vmdk).
  • This file should be very small (2โ€“3 KB).
  • Copy it and rename it to fixed.vmdk.

2๏ธโƒฃ Edit the File

  • Open fixed.vmdk using a text editor.

  • Find and remove the following line:

    parentFileNameHint="F:\vms\449_win\449_win-000004.vmdk"
    

    ๐Ÿ“Œ Note: The path above is just an exampleโ€”your path will be different!

  • Change parentCID to mark the disk as standalone:

    parentCID=ffffffff
    
  • If ddb.adapterType is missing, add:

    ddb.adapterType = "lsilogic"
    
  • Save the file.


๐Ÿ”„ Step 3: Convert the VMDK to a Raw Image

๐Ÿ“Œ Important: Open Command Prompt (cmd) in the same directory where fixed.vmdk is located.

Then, run the following command:

"c:/full/path/to/qemu-img.exe" convert -f vmdk -O raw "fixed.vmdk" "fixed.img"

๐Ÿ• This process may take a few minutes depending on the file size and disk speed.


๐Ÿ› ๏ธ Step 4: Extract Files Using TestDisk

๐Ÿ“Œ Important: You must open a Command Prompt as Administrator (elevated cmd prompt), and navigate to the same directory where fixed.img is located.

Then, run the following command:

"c:/full/path/to/testdisk_win.exe" fixed.img

Follow these steps:

  • Select: Proceed โžก๏ธ Press Enter
  • Choose Partition Type: [Intel] Intel/PC partition โžก๏ธ Press Enter
  • Select: [Analyse] to check for lost partitions โžก๏ธ Press Enter
  • Choose: [Quick Search] โžก๏ธ Press Enter

โœ… If all goes well, you should see a list of partitions:

2025-02-20_00h37_06


๐Ÿ“‚ Step 5: Recover Your Files

1๏ธโƒฃ Create the Recovery Destination

  • Open Windows Explorer, and create a new folder where you want to save the recovered files.
    ๐Ÿ“Œ For convenience, it should be in the same directory where fixed.img is located.

2๏ธโƒฃ Select the Partition Containing Your Data

  • Example:
    P HPFS - NTFS  82  57 40  7832  95  7  124506112
    
  • Press P to list files:

2025-02-20_00h40_46

3๏ธโƒฃ Browse and Select Files

  • Navigate to the folder you wish to recover using the arrow keys.
  • Press c to copy all files within that directory.
  • TestDisk will ask you to choose a folder to save the files.
  • Select the folder you created earlier and press c again to start the recovery.

๐ŸŽ‰ If all goes well, you should see 0 failed and a confirmation of the recovered files!

2025-02-20_00h54_42


โœ… Thatโ€™s It!

Youโ€™ve successfully recovered your VMware virtual machine files! ๐ŸŽ‰

๐Ÿ’พ Save this guide in case you need it in the future.
Happy recovering! ๐Ÿ’ปโœจ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment