wsl:不使用sudo挂载-权限被拒绝

时间:2019-11-11 17:33:35

标签: ubuntu windows-subsystem-for-linux

我想在wsl ubuntu 18.04.2 LTS内安装Windows分区。我将以下行添加到/etc/fstab

\\192.168.2.42\c        /mnt/test                drvfs   noauto,defaults,user    0       0

如果我像这样使用sudo运行它,它将起作用:

sudo mount /mnt/test

然后我在这种情况下向/etc/sudoers.d/添加了一个文件(也尝试使用我的用户名和主机名等):

ALL ALL = (root) NOPASSWD: /bin/mount

我重新启动了wsl(也尝试过重新启动):

net stop LxssManager
net start LxssManager

当我现在不使用sudo运行mount时,仍然得到:

mount /mnt/test

mount: only root can use "--options" option <3>init: (146) ERROR:
UtilCreateProcessAndWait:360: /bin/mount failed with status 0x100 No
error information

根据@biswapriyo的反馈进行编辑

我已经在sudo组中(第一步)。启动wsl时,第二步将安装驱动器。 /etc/wsl.conf

# Enable extra metadata options by default
[automount]
enabled = true
options = "defaults,user"
mountFsTab = true

它之所以起作用是因为我想它是作为root启动的。但是,这不是我所需要的。背景:我需要通过Shell脚本安装远程VPN网络驱动器。我并不总是需要它,并且它可能并不总是可用。因此,在启动时挂载不是一种选择。

0 个答案:

没有答案
相关问题