🪟 Windows
驱动和软件
-
MS 激活
irm https://get.activated.win | iex
Hyper-V 直通 GPU
关机、关闭虚拟机的动态内存、关闭检查点、关闭安全启动
-
直通 GPU
PowerShell 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# 目标虚拟机 $vm = "dda" # 1. 虚拟机关机 Set-VM -Name $vm -AutomaticStopAction TurnOff # 2. 启用CPU的写合并功能 Set-VM -GuestControlledCacheTypes $true -VMName $vm # 3. 配置 32 位 MMIO(内存映射 I/O)空间 Set-VM -LowMemoryMappedIoSpace 3Gb -VMName $vm # 4. 配置大于 32 位的 MMIO 空间 Set-VM -HighMemoryMappedIoSpace 33280Mb -VMName $vm # 1. 查找所有 pnp 设备 $pnpdevs = Get-PnpDevice -presentOnly # 2. 筛选出制造商为 NVIDIA 且属于“显示”类别的设备 $gpudevs = $pnpdevs | Where-Object {$_.Class -like "Display" -and $_.Manufacturer -like "NVIDIA"} # 3. 获取第一个设备的设备位置路径 $locationPath = ($gpudevs | Get-PnpDeviceProperty DEVPKEY_Device_LocationPaths).data[0] # 1. 禁用该设备 Disable-PnpDevice -InstanceId $gpudevs[0].InstanceId # 2. 从主机中卸载该设备 Dismount-VMHostAssignableDevice -Force -LocationPath $locationPath # 3. 将设备分配给虚拟机 Add-VMAssignableDevice -LocationPath $locationPath -VMName $vm
-
取消直通 GPU
PowerShell 1 2 3 4 5 6 7 8 9 10 11 12 13
# 目标虚拟机(同上) # 1. 查找所有 pnp 设备 $pnpdevs = Get-PnpDevice # 2. 筛选出制造商为 NVIDIA 且属于“显示”类别的设备 $gpudevs = $pnpdevs | Where-Object {$_.Class -like "Display" -and $_.Manufacturer -like "NVIDIA"} # 3. 获取第一个设备的设备位置路径 $locationPath = ($gpudevs | Get-PnpDeviceProperty DEVPKEY_Device_LocationPaths).data[0] # 1. 从虚拟机中移除设备 Remove-VMAssignableDevice -LocationPath $locationPath -VMName $vm # 2. 重新启用该设备 Mount-VMHostAssignableDevice -LocationPath $locationPath
-
查询
PowerShell 1 2 3 4 5 6 7 8
# 查看设备 Get-PnpDevice | Where-Object {$_.FriendlyName -like "*NVIDIA*"} # 获取 locationPath $locationPath = (Get-PnpDevice | Where-Object {$_.FriendlyName -like "*NVIDIA*"} | Get-PnpDeviceProperty DEVPKEY_Device_LocationPaths).data[0] # 确认 locationPath Write-OutPut $locationPath
WSL2
安装
-
- 启用适用于 Linux 的 Windows 子系统
Bash 1
wsl --update --web-download # 更新 WSL
Bash 1
wsl -l -o # 查看可用 Linux 发行版
Bash 1
wsl --install -d Ubuntu-22.04 # 下载安装 Ubuntu 22.04
Bash 1
wsl -l -v # 查看已安装的
Bash 1
wsl --unregister Ubuntu # 删除 Ubuntu
-
手动安装:ms/WSL
镜像网络 官方文档
- 创建
C:\Users\<UserName>\.wslconfig
文件Bash 1 2 3 4
[wsl2] networkingMode=mirrored dnsTunneling=true autoProxy=true
启动脚本
- win + r 输入
shell:startup
- 新建
wsl.vbs
文件Bash 1 2
Set ws = WScript.CreateObject("WScript.Shell") ws.run "wsl -d Ubuntu-22.04 -u user /home/user/startupsh"
挂载网络磁盘 非官文档
-
下载软件
sudo apt install cifs-utils
-
创建挂载目录
sudo mkdir /mnt/z
-
挂载
sudo mount -t drvfs Z: /mnt/z
-
持久化
vim /etc/fstab
Bash 1
Z: /mnt/z drvfs defaults 0 0