当我进入WSL时,C
驱动器会自动挂载到/mnt/c
。我还想在挂载点/mnt/d
上挂载一个文件夹C:\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
报告"mount: only root can use "--all“option”时,不会挂载它。
发布于 2021-03-11 23:57:47
这个问题很老,但如果有人还在问这个问题,我在WSL release notes中找到了答案
WSL现在在实例启动GH2636期间处理/etc/fstab文件。这是在自动挂载DrvFs驱动器之前完成的;任何已经由fstab挂载的驱动器都不会自动重新挂载,从而允许您更改特定驱动器的挂载点。
因此,在绑定挂载之前,必须为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
https://stackoverflow.com/questions/59959090
复制相似问题