VMFS Recovery™
Recover data from damaged or formatted VMFS disks or VMDK files
Recover data from damaged or formatted VMFS disks or VMDK files
Last updated: Oct 01, 2024

How to Mount a VMDK File from Another VM in VMware

VMDK files represent virtual machines hosted in a VMware environment. If a VMDK file becomes inaccessible or corrupted, the corresponding VM won’t open. So, VMDK files are to be protected securely. Also, you can move a VM’s VMDK file to another VM, if need be.

When you move a VM’s VMDK file to another VM, the VM (where you moved the VMDK file) will operate with the files and folders from the other VM (the one that has the VMDK file originally). This article explains everything you should know about moving or mounting VMDK files on secondary VMs.

What is a VMDK File and Why Mounting from Another VM is Important

A VMDK (Virtual Machine Disk) file is a format used by VMware virtual machines to store their virtual hard disk contents. It contains the entire virtual disk image, including the file system, applications, and data. Here are key aspects of VMDK files:

Key Features of VMDK Files

  • Disk Image: VMDK files store the complete content of a virtual machine's hard disk.
  • Flexibility: They can represent virtual disks of various sizes and can be either dynamically allocated or pre-allocated.
  • Portability: VMDK files can be moved between different virtual machines or environments, making it easy to clone or migrate VMs.

Types of VMDK Files

  • Monolithic Sparse: Stores all the data in a single file and allocates space as needed.
  • Monolithic Flat: Allocates all the space upfront in a single file.
  • Split Sparse: Divides the disk image into multiple 2GB files, allocating space as needed.
  • Split Flat: Divides the disk image into multiple 2GB files, with all space allocated upfront.

Why Mounting a VMDK from Another VM is Important

1. Data Recovery

  • Scenario: If a virtual machine fails to boot or the OS gets corrupted, mounting its VMDK file from another VM can allow access to its data.
  • Benefit: This allows for the retrieval of critical data without needing to repair or restore the entire virtual machine.

2. Troubleshooting and Maintenance

  • Scenario: Administrators may need to access system files or logs stored within a VMDK to troubleshoot issues.
  • Benefit: Mounting the VMDK from another VM provides direct access to these files without booting the problematic VM.

3. Backup and Migration

  • Scenario: When migrating VMs or performing backups, VMDK files may need to be accessed and copied.
  • Benefit: Directly mounting VMDK files can simplify the process of data migration and backup, ensuring data integrity and reducing downtime.

4. Cloning and Duplication

  • Scenario: Cloning a VM for testing or deployment purposes.
  • Benefit: By mounting the VMDK, administrators can easily copy or modify the disk contents for the new virtual machine.

5. Security and Forensics

  • Scenario: Security teams might need to inspect the contents of a VMDK file during an investigation.
  • Benefit: Mounting the VMDK allows for a detailed analysis of the virtual disk without altering its state.

Preparing for VMDK Mount

If you have VM-A and VM-B and wish to access VM-A’s files on VM-B, you will have to mount VM-A’s VMDK file on VM-B. However, you cannot access the same VMDK file on two different VMs simultaneously, you must have to shut down one of the VMs to access the VMDK data using the other VM.

Having understood the illustration above, it is also important to note these prerequisites to mounting a VM’s VMDK file on another machine.

  • The two VMs must be set up on VMware appliances of the same version
  • Guest OSes on the two VMs must be the same, or compatible
  • The VMDK file in question must not be corrupted
  • Make a backup of the original VM before proceeding

Steps to Mount VMDK from Another VM

First things first, you need to identify the VMDK file you want to move and mount on another VM. After identifying the location, the next is to ensure the VMDK file is accessible; if it’s not accessible on the main VM, it won’t be accessible on the secondary VM you’re moving it to.

Step 1: Identifying the VMDK and Ensuring Accessibility

  1. 1. Locate the VMDK File:

    • Identify the location of the VMDK file on the host system or datastore.
    • Note the file path or datastore location.
  2. 2. Check Permissions:

    • Ensure you have the necessary permissions to access and mount the VMDK file.
  3. 3. Verify VMDK Integrity:

    • Ensure the VMDK file is not corrupted by using tools on VMware ESXi.

Step 2: Preparing the Target VM

  1. 1. Ensure Compatibility:

    • Ensure the target VM's operating system supports the file system within the VMDK file.
  2. 2. Shut Down or Suspend the Target VM:

    • Safely shut down or suspend the target VM to avoid conflicts during the mounting process.
  3. 3. Backup the Target VM:

    • Create a backup of the target VM before mounting the VMDK to avoid potential data loss.

Step 3: Mounting the VMDK on the Target VM

  1. 1. Using VMware Workstation/Fusion:

    • Open VMware Workstation or Fusion.
    • Go to File > Map Virtual Disks.
    • Browse to the VMDK file and select it.
    • Assign a drive letter (Windows) or mount point (Linux/Mac).
  2. 2. Using VMware vSphere/ESXi:

    • Connect to the ESXi host using vSphere Client.
    • Right-click the target VM and select Edit Settings.
    • Click Add New Device and choose Existing Hard Disk.
    • Browse to the VMDK file and add it to the VM.
  3. 3. Using Command Line Tools on Linux:

    • Use vmware-mount or qemu-nbd to mount the VMDK:
      bash
      sudo modprobe nbd max_part=8 sudo qemu-nbd -c /dev/nbd0 /path/to/your.vmdk sudo mount /dev/nbd0p1 /mnt/vmdk
  4. 4. Using Third-Party Tools:

    • Tool DiskInternals VMFS Recovery can also be used to mount VMDK files directly on Windows.

Step 4: Working with Data on the VMDK

  1. 1. Access the Data:

    • Navigate to the mounted VMDK drive or mount point.
    • Access and work with the files as needed.
  2. 2. Perform Necessary Operations:

    • Copy, move, or modify the data on the mounted VMDK.
    • Ensure you follow best practices for data integrity.
  3. 3. Unmount the VMDK:

    • Once finished, safely unmount the VMDK.
    • For command-line tools, use:
      bash
      sudo umount /mnt/vmdk sudo qemu-nbd -d /dev/nbd0
  4. 4. Remove VMDK from Target VM (if applicable):

    • If the VMDK was added to a VM configuration, remove it from the VM settings in VMware Workstation, Fusion, or vSphere.

(Note: The VMDK file can be mounted directly from the VMware console. Also, you cannot use the same VMDK simultaneously with different VMs; if you try to tweak a VMDK file to use it in multiple VMs at a time, the file would end up being corrupted).

Tip: convert VHDX to VMDK

Alternative Methods for VMDK Mounting

DiskInternals VMFS Recovery tool is a powerful software solution designed for recovering data from VMFS (VMware File System) disks, which includes accessing and recovering VMDK files in environments where VMware systems have experienced failures or data corruption. Here’s how to use this tool:

Installation and Setup

  1. 1. Download and Install:

    • Install the software on a Windows machine that can connect to the VMware ESXi server or access the drives directly.
  2. 2. Prepare for Mounting:

    • If possible, directly attach the storage device containing the VMDK files to your Windows system using iSCSI initiators, Fibre Channel, or physical connections.
    • Alternatively, if you are working with ESXi, ensure network connectivity to the ESXi server hosting the VMDK files.

Steps to Mount VMDK File

  1. 1. Launch DiskInternals VMFS Recovery:

    • Open the software, and it will scan for available VMFS volumes.
    • It automatically detects VMware VMFS disks and mounts them.
  2. 2. Scanning and Mounting VMDK Files:

    • Navigate through the detected VMFS volumes and locate the VMDK files.
    • Use the software’s scanning features to read and recover the contents of the VMDK files.
    • This process might take some time, depending on the size and state of the VMDK files.
  3. 3. Recovering Data (if needed):

    • After scanning, you can preview recoverable files directly within the software. This is useful for verifying the data before full recovery.
    • Select the files or entire VMDK volumes you wish to recover and specify a destination where the data will be saved.
  4. 4. Saving Recovered Data:

    • Recover the selected files to a safe location. It’s recommended to save the data on a different drive to prevent overwriting any recoverable data still on the source drive.
    • DiskInternals VMFS Recovery supports saving recovered files to local drives, network shares, or even directly to a virtual disk format.

Advantages of Using DiskInternals VMFS Recovery

  • Comprehensive Recovery: Capable of recovering data even from damaged or corrupted VMFS volumes.
  • Versatility: Supports various VMware setups including VMFS3, VMFS5, and VMFS6 partitions.
  • Ease of Use: Provides a user-friendly interface that guides users through the recovery process, making it accessible even to those with limited technical knowledge.
  • Preview Feature: Allows users to preview files before recovery, ensuring that the correct data is recovered.

Verifying Mounting and Basic Data Operations

Once a VMDK file is mounted, it's important to verify that the mounting was successful and that the data within the VMDK is accessible and manipulatable. Here's how to proceed with these tasks:

Checking Data Availability on the Mounted VMDK

  1. 1. Verify Mount Status:

    • Ensure that the VMDK has been mounted correctly by checking the system's disk management utility. In Windows, this can be done via Disk Management (diskmgmt.msc), and in Linux, by using the df command.
  2. 2. Access the Mounted Drive:

    • Navigate to the drive letter or mount point assigned during the mounting process. For example, in Windows, if the VMDK was assigned as drive E:, you would go to This PC and look for Local Disk (E:).
  3. 3. Check for File Visibility:

    • Browse the directories and files within the mounted VMDK to ensure that they are visible and accessible. If files or folders are expected but not visible, this may indicate a problem with the mounting process or file system integrity within the VMDK.
  4. 4. File System Integrity Check:

    • Run a file system integrity check to ensure there are no underlying issues. In Windows, this could be chkdsk E: /f and in Linux, fsck on the corresponding mount point.

Basic Data Operations: Reading, Writing, Copying, etc.

  1. 1. Reading Data:

    • Open files from the mounted VMDK to ensure they can be read without errors. This can include opening text files, executing programs, or viewing images.
  2. 2. Writing Data:

    • Try creating new files or modifying existing files within the mounted VMDK. This verifies that the mount is not only read-only (unless specifically intended). For example, create a simple text file to check write operations.
  3. 3. Copying Data:

    • Copy files to and from the mounted VMDK. This tests both read and write functionality and is especially important if the VMDK is being used for data recovery or migration purposes.
  4. 4. File Manipulation:

    • Perform other file operations such as renaming, deleting, and folder creation to ensure comprehensive read/write capabilities.
  5. 5. Performance Check:

    • Monitor the system for any performance issues while accessing the VMDK. Heavy lag or unresponsiveness can indicate problems with the mount or the underlying storage hardware.
  6. 6. Unmounting and Remounting:

    • Safely unmount and then remount the VMDK to ensure that all operations can be repeated reliably. This is crucial for environments where VMDKs are regularly attached and detached.

Tools and Commands for Operations

Windows:

  • Explorer: Navigate and manipulate files through the graphical interface.
  • Command Prompt: Use copy, move, del, etc., for file operations.
  • PowerShell: Advanced scripting for bulk operations or automation.

Linux:

  • Terminal: Use cp, mv, rm, mkdir, touch, etc., for managing files.
  • GUI File Managers: For those who prefer graphical interfaces like Nautilus, Dolphin, etc.

Conclusion

You can mount a VMDK file to another VM or create a new VM using the VMDK file of an old (existing) VM. However, the new VM must have similar configurations (including guest OS) to the old VM you’re extracting the VMDK from. Ensure to back up your VM before embarking on this tutorial. If you lost your VMDK file or got it corrupted during the course of this tutorial, DiskInternals VMFS Recovery can help you recover the lost VMDK or repair the corrupted file.

Related articles

FREE DOWNLOADVer 4.23, WinBUY NOWFrom $699

Please rate this article.
51 reviews