先从windows的磁盘管理工具中脱机

wmic diskdrive list brief

Caption DeviceID Model
Partitions Size WDC WDS100T2B0C-00PXH0 \.\PHYSICALDRIVE2 WDC
WDS100T2B0C-00PXH0 3 1000202273280 ST8000VX0022-2EJ112
\.\PHYSICALDRIVE1 ST8000VX0022-2EJ112 1 8001560609280
WDC WD20EZRZ-00Z5HB0 \.\PHYSICALDRIVE0 WDC WD20EZRZ-00Z5HB0 1
2000396321280

wsl --mount \\.\PHYSICALDRIVE1 --bare 挂载

需要开启Windows防火墙
2023-02-10T01:39:41.png
在开启端口转发
2023-02-10T01:43:17.png

后记,这个不固定IP,还需要固定IP

wsl -d Ubuntu-22.04 -u root ifconfig wsl -d Ubuntu-22.04 -u root
ifconfig eth0 172.20.0.2/24 wsl -d Ubuntu-22.04 -u root route add
default gw 172.20.0.1 wsl -d Ubuntu-22.04 -u root service ssh start
powershell -c "Get-NetAdapter -IncludeHidden 'vEthernet (WSL)' |
Get-NetIPAddress | Remove-NetIPAddress -Confirm:$False;
New-NetIPAddress -IPAddress 172.20.0.1 -PrefixLength 24
-InterfaceAlias 'vEthernet (WSL)'; Get-NetNat | ? Name -Eq WSLNat | Remove-NetNat -Confirm:$False; New-NetNat -Name WSLNat
-InternalIPInterfaceAddressPrefix 172.20.0.0/24;"
歌曲封面
0:00