VHD (Virtual Hard Disk) is created as Read-Only by default and cannot write file to

Beresteanu Gil 0 Reputation points
2024-12-31T15:35:27.5033333+00:00

I Created VHD on Windows 11

The Disk was created with a label

While trying to copy a file to the new VHD it says it is write protected.

Trying to resolve the issue using diskpart didn't help:

diskpart
list disk
select disk X
attributes disk clear readonly
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
40,763 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 26,451 Reputation points MVP
    2024-12-31T15:47:33.2966667+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    If you are unable to write to a Virtual Hard Disk (VHD) because it is write-protected, here are steps to resolve the issue:

    1. Check and Clear the Read-Only Attribute

    Using diskpart to clear the read-only attribute was a good start, but ensure you've followed the process correctly:

    1. Open Command Prompt as Administrator.
    2. Run diskpart and execute the following commands: list disk select disk X # Replace X with your VHD disk number attributes disk clear readonly
    3. Next, select the partition and ensure it is not read-only: list volume select volume Y # Replace Y with your VHD volume number attributes volume clear readonly Exit
    4. Verify the VHD Mounting State
    • Ensure the VHD is mounted in Read/Write mode. When mounting the VHD, some tools default to read-only mode.
      1. Detach the VHD:
        - Open Disk Management (`diskmgmt.msc`).
        
              - Right-click the mounted VHD and select Detach VHD.
        
                 1. Re-attach the VHD:
        
                       - Click Action > Attach VHD.
        
                             - In the dialog box, uncheck Read-only if it is selected.
        
    1. Check File System and Permissions
    • Verify the file system of the VHD:
      • If the file system is RAW, the VHD might not be formatted. You’ll need to format it as NTFS or another supported file system.
        • If formatted, right-click the VHD in File Explorer, go to Properties, and check permissions under the Security tab. Ensure your user has Write permissions.
    1. Check Disk Policies

    Certain Windows policies or third-party software might prevent writing to removable media. To check this:

    1. Open Registry Editor (regedit) --> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control
    2. Look for a key named WriteProtect. If it exists:
      • Set its value to 0 to disable write protection.
    3. Restart your computer.
    4. Verify Anti-Virus or Encryption Software Sometimes anti-virus or encryption tools can mistakenly apply write-protection to a mounted VHD. Temporarily disable such tools and retry.
    5. Check the VHD File Attributes Ensure the VHD file itself (the .vhd file) is not marked as read-only:
      1. Locate the .vhd file in File Explorer.
      2. Right-click and select Properties.
      3. Uncheck the Read-only attribute, if checked.
    6. Test with a Different VHD If the issue persists, create another VHD as a test:
      1. Open Disk Management.
      2. Create a new VHD, attach it, and format it.
      3. Test file operations on the new VHD to confirm if the issue is specific to the original file.

    If none of these steps work, the problem may be due to a corrupted VHD file or misconfigured system settings. Re-creating the VHD or checking for Windows updates might help resolve the issue.

    Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.