To mount a Windows 10 base filesystem as read-only, you must use the Deployment Image Servicing and Management (DISM) utility with the
/Mount-WindowsImage parameter. This process allows administrators to inspect system files, extract drivers, or verify configurations within a Virtual Hard Disk (VHD) without risking accidental modifications to the source image.
Understanding the DISM Mount Command
The core mechanism for accessing VHD contents in Windows is the
DISM.exe tool. By default, mounting an image grants write access, which can be dangerous if you are troubleshooting a corrupted boot sector or analyzing malware behavior. The read-only flag ensures that any changes made during the session are discarded when the image is detached, preserving the integrity of the original file.
You will need to run these commands from an elevated Command Prompt or PowerShell window. Administrative privileges are mandatory because DISM interacts directly with low-level storage structures. If you attempt this without elevation, the system will return an "Access Denied" error immediately.
Preparing the VHD File
Before using DISM, ensure your VHD file is accessible via a standard file path. The most common scenario involves a
.vhdx or
.vhd file located on your local drive, such as
C:\Images\Win10Base.vhdx. You do not need to attach the VHD to the operating system first; DISM handles the attachment internally.
However, it is critical to verify that the VHD contains a valid Windows installation structure. A bare disk image without partition data will fail to mount. If you created the VHD using tools like Hyper-V or DiskPart, ensure it includes at least one formatted NTFS partition containing the
Windows folder.
For related tasks involving system configuration, you might also want to check
Is there a command line way to boot into UEFI firmware? to understand how your system boots before making offline changes.
Executing the Read-Only Mount
Open Command Prompt as Administrator and navigate to the directory containing your VHD file, or simply reference the full path in your command. Use the following syntax to mount the image:
DISM /Mount-WindowsImage /ImageFile:"C:\Path\To\Image.vhdx" /Index:1 /MountDir:"C:\MountPoint" /ReadOnly
Let's break down the parameters:
- /ImageFile: Specifies the full path to the VHD or WIM file.
- /Index: Defines which image inside the file to mount. Most single-OS VHDs use index
1. If your file contains multiple editions (e.g., Pro and Home), list them using DISM /Get-WimInfo /WimFile:"..." to find the correct number.
- /MountDir: A local folder where the filesystem will appear. Create this folder beforehand using
mkdir C:\MountPoint.
- /ReadOnly: This is the crucial switch that prevents any write operations.
Once executed successfully, you will see a confirmation message stating the image was mounted. You can now open
C:\MountPoint in File Explorer and browse the registry hives, program files, and system directories just as if they were on your active drive.
Verifying Read-Only Status
After mounting, test the protection by attempting to create a file. Try running
echo test > C:\MountPoint\test.txt. If the command fails with an access denied error, the read-only constraint is active. This verification step is essential before performing complex diagnostic tasks.
If you need to make permanent changes, you must remount without the
/ReadOnly flag. However, for forensic analysis or backup verification, keeping this flag ensures that no stray processes accidentally alter timestamps or delete critical system files.
Another relevant topic for system maintenance is understanding why specific user states persist across reboots. You may find
Windows Requires Last User to Unlock on Startup useful if you are investigating user profile locks within the mounted image.
Detaching the Image Safely
When you are finished, you must detach the image to release the lock on the VHD file. Failure to detach properly can corrupt the VHD or prevent other applications from accessing it. Run the following command:
DISM /Unmount-WindowsImage /MountDir:"C:\MountPoint" /Discard
The
/Discard parameter is vital here. It tells DISM to ignore any changes made during the session, even if you had temporarily removed the read-only flag for testing. If you had made intentional changes, you would use
/Commit instead. Always verify that the mount point folder is empty of new files before discarding.
Troubleshooting Common Errors
If you encounter errors, check the event viewer for details. Common issues include:
- Image Index Invalid: Ensure you are using the correct index number for your specific VHD.
- Path Too Long: Windows has a limit on nested paths. Keep your mount directory short, like
C:\MP.
- Access Denied: Verify that no other application, such as antivirus software, is locking the VHD file.
Frequently Asked Questions
Can I mount a VHD while Windows is running from it?
No, you cannot mount a VHD that is currently the active boot volume for the running OS. The system locks critical system files required for operation. You must boot from a different media, such as a recovery USB or another drive, to safely mount the target VHD.
What is the difference between /Commit and /Discard?
/Commit saves all changes made to the mounted image back to the VHD file, effectively updating the source.
/Discard throws away all changes, leaving the original VHD unmodified. For read-only inspections,
/Discard is always the safer choice.
How do I find the correct Index number for my VHD?
Use the command
DISM /Get-WimInfo /ImageFile:"path_to_vhdx" to list all available images and their corresponding indices. Single-OS images typically use Index 1, but multi-edition files may have higher numbers.
Why does DISM say the image is already mounted?
This error occurs if a previous session did not terminate cleanly or if another process is holding the mount point. Check Task Manager for stuck
dism.exe processes or reboot your computer to clear the lock.
Can I use PowerShell instead of CMD for this task?
Yes, DISM works identically in PowerShell. Simply open PowerShell as Administrator and run the same commands. PowerShell provides better tab completion for file paths, reducing typing errors.
Does mounting a VHD affect its performance?
Mounting itself adds negligible overhead. However, reading large amounts of data from a network-stored VHD may be slower than local storage. For best results, keep the VHD on a fast SSD or local hard drive during the mounting process.