1. 与Windows网络共享

在Windows用户文件夹下新建.wslconfig文件并写入

[experimental]
autoMemoryReclaim=gradual # 可以在 gradual 、dropcache 、disabled 之间选择
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true
sparseVhd=true

2. 排除对Windows中的文件检索

在WSL的/etc/wsl.conf文件中加入如下内容

[interop]
appendWindowsPath = false
[automount]
enabled = false

理论上可以关闭与Windows的交互,但是由于WSL共享了Windows的网络,所以无法真正禁止磁盘挂载。

可以修改updatedb的搜索范围来减小磁盘挂载的影响,编辑 /etc/updatedb.conf的方法并不是对所有发行版全部适用,可以在.zshrc或者.bashrc中加入如下内容

alias updatedb="sudo updatedb --prunepaths=\"/mnt/c /mnt/d\""

以后只需要执行updatedb就行了