Created
January 4, 2023 20:15
-
-
Save igoforth/5d6315489f4401dc380fe306a525a998 to your computer and use it in GitHub Desktop.
Mounting VHD into WSL2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$number = $((Mount-DiskImage -ImagePath "D:\Data\VirtualBox VMs\WSL2 VHD\wsl2.vhdx" -PassThru | Get-Disk).Number) | |
$diskDrive = "\\.\PHYSICALDRIVE$number" | |
$bashDiskDrive = "PHYSICALDRIVE$number" + "p1" | |
wsl --mount $diskDrive -p 1 | |
# remove previously created symlink | |
wsl rm -rf /mnt/wsl/vhd_data | |
# add new symlink | |
wsl ln -s /mnt/wsl/$bashDiskDrive /mnt/wsl/vhd_data | |
# Remember this line for our next part | |
# Start-Process "C:\Program Files\Docker\Docker\Docker Desktop.exe" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment