This guide explains how to create, mount, and maintain a VHDX drive for use with WSL (Windows Subsystem for Linux).
- Windows 10/11 with WSL2 installed
- Administrative access
- PowerShell
- Sufficient disk space
- First, check existing devices in your WSL distribution:
ls /dev/sd* -la
- Create the VHDX file in PowerShell (run as Administrator):
New-VHD -Path "Z:\Disks\wsl-ubuntu-2404\data_disk.vhdx" -SizeBytes 500GB -Dynamic
wsl --mount --vhd "Z:\Disks\wsl-ubuntu-2404\data_disk.vhdx" --bare
- Identify the new device:
ls /dev/sd* -la
Note: Compare with the previous listing to identify the new device (e.g., /dev/sdd)
- Create a mount point:
sudo mkdir /mnt/data
- Initialize the disk using fdisk:
sudo fdisk /dev/sdX # Replace X with your disk letter
Enter these commands in sequence:
n
(new partition)p
(primary partition)1
(partition number)- Enter (default first sector)
- Enter (default last sector)
w
(write changes)
- Format the partition:
sudo mkfs.ext4 /dev/sdX1 # Replace X with your disk letter
- Get the partition UUID:
sudo blkid
- Mount the partition:
sudo mount UUID="YOUR-UUID" /mnt/data
- Add to /etc/fstab:
echo 'UUID="YOUR-UUID" /mnt/data ext4 defaults 0 0' | sudo tee -a /etc/fstab
- Configure WSL automount by adding to /etc/wsl.conf:
sudo tee -a /etc/wsl.conf << EOF
[automount]
enabled=true
mountFsTab=true
EOF
- Create a startup script (mount-wsl-vhdx.bat):
wsl --mount --vhd "Z:\Disks\wsl-ubuntu-2404\data_disk.vhdx" --bare
- Create a scheduled task:
- Open Task Scheduler
- Create a new task with these triggers:
- At system startup
- On event: Log: Microsoft-Windows-Hyper-V-Worker/Admin
- Source: Hyper-V-Worker
- Event ID: 18500
This ensures the disk is mounted when:
- Windows starts
- WSL restarts after shutdown
- Any Hyper-V VM starts
March 10, 2025.
Hello. Thank you very much for guide @omarmciver . It works!
But I must add some details, becuse it doesn't work without them.
My case is Windows 10 x64 Pro, WSL 2, Ubuntu 24 for SVN with Apache SSL
After New-VHD you need detach new disk in Windows Disk Managment (access problem). Don't know why it is attaching in first place
Give "Full control" to "Users" for new vhdx file (permission problem)
When create mount task action:

And WSL autostart task action with 30 secs delay

or copy wsl app from shell:appsfolder to shell:startup