gpt4 book ai didi

windows-subsystem-for-linux - 如何在启动时自动在 WSL 中挂载 Windows 文件夹

转载 作者:行者123 更新时间:2023-12-03 19:18:27 25 4
gpt4 key购买 nike

当我进入 WSL 时,C驱动器自动安装在 /mnt/c .我还想挂载一个文件夹 C:\D到挂载点 /mnt/d .
/etc/fstab的内容:

LABEL=cloudimg-rootfs   /        ext4   defaults        0 0
/mnt/c/D /mnt/d none bind
/etc/wsl.conf的内容:
# Enable extra metadata options by default
[automount]
enabled = true
root = /mnt/
options = "metadata,umask=22,fmask=11"
mountFsTab = true

# Enable DNS – even though these are turned on by default, we’ll specify here just to be explicit.
[network]
generateHosts = true
generateResolvConf = true

当我做 sudo mount -a然后它正确安装。但是它没有在启动和运行时挂载 mount -a报告“挂载:只有 root 可以使用“--all”选项”。

最佳答案

这个问题很老,但如果有人仍然遇到这个问题,我在 WSL release notes 中找到了答案

WSL now processes the /etc/fstab file during instance start [GH 2636].This is done prior to automatically mounting DrvFs drives; any drivesthat were already mounted by fstab will not be remountedautomatically, allowing you to change the mount point for specificdrives.


因此,在绑定(bind)挂载之前,必须为 Windows 驱动器添加挂载:
例如:
# <file system> <dir> <type> <options> <dump> <pass>
C: /mnt/c drvfs rw,noatime,uid=1000,gid=1000,case=off,umask=0027,fmask=0137, 0 0
/mnt/c/directory/for/mount /where/to/mount none bind,default 0 0

关于windows-subsystem-for-linux - 如何在启动时自动在 WSL 中挂载 Windows 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59959090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com