WSL 3.0.5.0 Can Fail to Start With Wsl/Service/CreateInstance/MountDisk/HCS/ERROR_FILE_CORRUPT Even After Space Is Freed
On November 29, a new report of virtual disk corruption appeared in Microsoft's Windows Subsystem for Linux (WSL) issue tracker. The user was running WSL 3.0.5.0 on Windows build 26200 with the sparse virtual disk setting sparseVhd=true enabled.
According to the report, Windows ran out of storage while WSL was running. Linux failed to start even after space was freed. The virtual disk failed to attach, and WSL displayed Wsl/Service/CreateInstance/MountDisk/HCS/ERROR_FILE_CORRUPT.
The initial October report came from a user running Ubuntu 26.04 under WSL 3.0.1.0. A software build consumed all free space on Windows, and the virtual disk could no longer attach. The error code was the same.
A fault in the virtual disk metadata
Microsoft's documentation says WSL2 stores the Linux file system in a virtual disk file named ext4.vhdx on Windows. The file grows as needed, so users do not need to reserve space for the entire Linux disk up front.
The block allocation table (BAT) records the state of each data region and its location within the VHDX file as an offset from the start. Microsoft's VHDX specification prohibits multiple BAT entries from using the same nonzero offset.
The latest reporter found duplicate offsets in the BAT. The UNMAPPED state indicates a block whose contents are no longer needed by the system or application using the virtual disk. Five such entries reportedly pointed to locations occupied by blocks still in use.
The specification permits an offset on an UNMAPPED entry. The problem was the duplication across entries. The reporter said Linux started again after the metadata was repaired.
Writes can fail even when space is available
After the reporter restored startup, Linux writes began failing despite ample free space on Windows. The Linux ext4 file system switched to read-only mode, and some application data was lost.
The VHDX file was split into about 655,000 fragments on the Windows NTFS file system. The reporter suspected extreme fragmentation had prevented further allocations. New invalid references also appeared in the BAT.
Sparse virtual disk corruption in WSL 3.0.5.0
| Measure | Initial failure | Failure after startup recovery |
|---|---|---|
| Free space on Windows | Freed after running out | Ample space available |
| Symptoms | Unable to start | Write failures ext4 switched to read-only Data loss |
| Block allocation table (BAT) | Five unused entries pointed to active offsets | New invalid references |
| VHDX on NTFS | — | About 655,000 fragments Fragmentation may have prevented allocation |
※— indicates unknown.
When a file's data is scattered across NTFS, the file system needs more metadata to track it. Microsoft's SQL Server documentation describes cases where extreme fragmentation exhausts the available metadata and prevents further allocation. It can happen to regular files as well as sparse files.
The Windows file system manages the space used by the VHDX, and the VHDX uses its BAT to manage locations inside the file. Both need to work correctly. A free-space reading alone does not establish that the required storage can be allocated.
What was recovered and what was lost
The reporter created a new, non-sparse VHDX and migrated the data block by block. After checking the Linux file system with e2fsck and switching to sparseVhd=false, the system was still working normally at the time of the report.
The reporter said data from the failed writes could not be recovered.
A follow-up test reproduced the virtual disk attachment failure in an isolated Linux distribution with inconsistent metadata. The reporter saved diagnostic logs from that test. Logs from the original corruption were unavailable.
The test reproduced an attachment failure for a VHDX with invalid metadata. Determining why the BAT became invalid when space ran out requires investigating how the corruption developed.
In October 2023, another user reported VHDX corruption in a WSL 2.0.4.0 preview and suspected a link to sparse disks. A user with WSL 3.0.3 later added their test results. Across about 120 interruptions in sparse and non-sparse test configurations, including low-storage and forced-stop scenarios, the user found no duplicate BAT references. The tests used a Hyper-V VM with a physical NVMe SSD assigned directly to it and did not include physical power loss.
Two tests of WSL2 VHDX corruption
| Measure | Attachment test | Interruption tests |
|---|---|---|
| Test environment | Test Linux distribution | WSL 3.0.3 Sparse and non-sparse disks Hyper-V virtual machine Physical NVMe SSD passed through |
| Test procedure | Test image with invalid BAT metadata | Storage exhaustion, forced stops, and more About 120 interruptions |
| Result | Attachment failure reproduced Diagnostic logs recorded | No duplicate BAT offsets |
| Limitations | No logs from the original failure | Physical power loss to SSD not tested |
One test system survived storage exhaustion, while another suffered corruption after it ran out of space. Both observations help narrow down the conditions that led to the failure. The issue remained open on November 29.
What to protect before saving space
Microsoft enabled creation of sparse virtual disks as an experimental feature in the WSL 3.0.2 preview. It also stopped requiring the --allow-unsafe flag when converting existing virtual disks and instead displays an experimental feature warning when sparse mode is enabled.
Microsoft's WSL configuration documentation lists sparseVhd as an experimental setting, with a default of false. With true, newly created virtual disks use the sparse format.
Sparse files save storage by skipping physical allocation for zero-filled regions. Dynamically expanding VHDX files grow as needed even if sparse mode is off. Changing how new virtual disks are created is separate from recovering a VHDX that is already corrupt.
The default maximum capacity of a WSL2 virtual disk is 1 TiB, which Microsoft's documentation labels 1 TB. In the October report, a VHDX configured for 1 TiB was only about 213 GiB on disk. Linux can show more capacity than Windows has available. Check free space on the Windows host as well as inside Linux.
Microsoft documents how to export and import distributions. While the distribution works, use wsl --export to make a backup and store it separately from the virtual disk. Microsoft's repair instructions attach the disk and check ext4. The reporter's repair addressed the VHDX metadata itself. Preserve the original VHDX before attempting any repair.
The reporter recovered the Linux environment by examining its virtual disk metadata. Even with that expertise, the failed writes could not be recovered. Storage savings show up in the numbers immediately. The value of a backup is harder to see until something goes wrong.
KioskNews shows a cleaned-up reading view extracted from the publisher’s page — the original always lives on their site, not ours.
