Creating additional virtual hard disk (VHDX) for WSL2 with ext4 filesystem
Lines starting with #
mean the commands have to be executed by root user under Linux shell (WSL distro).
All other commands have to be executed under Windows-PowerShell as Administrator.
New-VHD support.vhdx -SizeBytes 25GB -Dynamic -BlockSizeBytes 1MB
Write-Output "\\.\PhysicalDrive$((Mount-VHD -Path support.vhdx -PassThru | Get-Disk).Number)"
Tip: Open "Computer Management" GUI program, then navigate to "Storage/Disk Management" and U can see all the drives attached to Windows. The new virtual disk should also be there.
wsl --mount \\.\PhysicalDriveX --bare
# lsblk
# dmesg
# fdisk -l
# fdisk /dev/sdX
Using above tool create GPT partition table and one (or more) partition(s). Write all changes and quit. Then format the partition and mount it somewhere:
# mkfs.ext4 -G 4096 /dev/sdX1
# mkdir ~/support
# mount /dev/sdX1 ~/support
Done.
# unmount ~/support
wsl --unmount \\.\PhysicalDriveX
Dismount-VHD support.vhdx
Happy WSL!