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.

Revisions

  1. x011 created this gist Feb 20, 2025.
    121 changes: 121 additions & 0 deletions recover_vmware_vmdk_missing_parent_disk.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,121 @@
    # ๐Ÿ› ๏ธ 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](https://gist.github.com/user-attachments/assets/1cad11ca-cee8-4782-a121-b0923aee6772)

    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](https://qemu.weilnetz.de/)
    ๐Ÿ”น **TestDisk** โ€“ [Download here](https://www.cgsecurity.org/wiki/TestDisk_Download)

    ---

    ## ๐Ÿ“‚ 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:**
    ```plaintext
    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:**
    ```plaintext
    parentCID=ffffffff
    ```
    - **If `ddb.adapterType` is missing, add:**
    ```plaintext
    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:
    ```sh
    "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:

    ```sh
    "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](https://gist.github.com/user-attachments/assets/7286b851-a0d7-448e-af7e-3604464371f7)

    ---

    ## ๐Ÿ“‚ 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:
    ```plaintext
    P HPFS - NTFS 82 57 40 7832 95 7 124506112
    ```
    - Press **`P`** to list files:
    ![2025-02-20_00h40_46](https://gist.github.com/user-attachments/assets/2e0ce929-d92f-43d7-8802-d23deca5f1d5)
    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](https://gist.github.com/user-attachments/assets/cf7d558c-15db-4960-82a9-2b6cd768e496)
    ---
    ## โœ… 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! ๐Ÿ’ปโœจ