V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hellos
V2EX  ›  Windows

请问 WSL 怎样取消(自动)挂载 Windows 系统中的分区?

  •  
  •   hellos · 2020-07-10 21:57:39 +08:00 · 2601 次点击
    这是一个创建于 1385 天前的主题,其中的信息可能已经有所发展或是发生改变。

    打开 WSL 后,Windows 中的 C 盘 D 盘等是自动挂载到 /mnt 下的,当使用 find 、grep 等命令的时候,会去 Windows 下查找文件,有没有方法取消挂载呢? 我试过 umount 但是并没有什么效果,会提示 umount: /mnt/d: not mounted.

    hellos
        2
    hellos  
    OP
       2020-07-10 22:07:35 +08:00
    @codehz 多谢。
    tolerance
        3
    tolerance  
       2020-07-10 22:56:59 +08:00   ❤️ 1
    搜一下 find 、grep 排除指定目录
    hellos
        4
    hellos  
    OP
       2020-07-10 23:53:57 +08:00
    @tolerance 谢谢,这样也不错,而且 find 中有个-mount 参数,可以直接过滤挂载的磁盘
    murmur
        5
    murmur  
       2020-07-10 23:55:27 +08:00
    我在 wsl1 里也遇到了这个问题,是 npm 找到了 windows 版的 npm,然后各种出错

    我尝试了各种解除 mount 的方式无果,最后在脚本里加了自动从环境变量删掉 windows 目录的代码
    hellos
        6
    hellos  
    OP
       2020-07-11 00:01:23 +08:00
    @murmur 用 1 楼方法可以不自动挂载,但是只是不自动挂载 C 、D,其他分区( E 、F )还是会挂载
    hellos
        7
    hellos  
    OP
       2020-07-11 15:44:03 +08:00
    @hellos 更正:所有的分区都不挂载
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2950 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 13:28 · PVG 21:28 · LAX 06:28 · JFK 09:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.