WSL(Ubuntu on Windows) 中进入/mnt/c /mnt/d 内容为空

2019-01-21 09:46:03 +08:00
 handsomehaitao

以下是 d 盘内容 root@DESKTOP-VRL647H:/mnt# cd d
root@DESKTOP-VRL647H:/mnt/d# ls -alh
total 0
drwxrwxrwx 1 root root 512 Jan 18 10:01 .
drwxr-xr-x 1 root root 512 Jan 18 10:01 ..

mount 命令显示内容

root@DESKTOP-VRL647H:/mnt/d# mount
rootfs on / type lxfs (rw,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
none on /dev type tmpfs (rw,noatime,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,gid=5,mode=620)
none on /run type tmpfs (rw,nosuid,noexec,noatime,mode=755)
none on /run/lock type tmpfs (rw,nosuid,nodev,noexec,noatime)
none on /run/shm type tmpfs (rw,nosuid,nodev,noatime)
none on /run/user type tmpfs (rw,nosuid,nodev,noexec,noatime,mode=755)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noatime)

3643 次点击
所在节点    问与答
15 条回复
lzvezr
2019-01-21 09:52:56 +08:00
重新挂载一下就好了吧,之前在 Windows 里调整分区大小,wsl 挂载就掉了
handsomehaitao
2019-01-21 10:04:19 +08:00
@lzvezr 这个需要自己手动挂载吗,不是自动挂载吗
lzvezr
2019-01-21 10:07:23 +08:00
@handsomehaitao 一般是自动挂载的,但是某些时候,比如我说的调整了分区大小或者其他原因,就得自己手动挂载一下了
yaxin
2019-01-21 10:14:06 +08:00
创建`/etc/wsl.conf`配置文件:

```
[automount]
enabled = true
root = "/mnt/"
options = "metadata,umask=22,fmask=11"
mountFsTab = true

[network]
generateHosts = true
generateResolvConf = true
```
handsomehaitao
2019-01-21 10:33:29 +08:00
@yaxin 多谢你的回答,已经解决了我的问题
handsomehaitao
2019-01-21 10:36:24 +08:00
@yaxin 请问 nginx 配置域名指向了 d 盘文件,访问网站,日志文件没有权限,怎么解决呢,我 ubuntu 中是 root 用户
ReVanTis
2019-01-21 11:11:40 +08:00
sudo mount -t drvfs c: /mnt/c
ysc3839
2019-01-21 12:55:03 +08:00
@handsomehaitao
怎么个没有权限呢?描述一下具体的错误。
handsomehaitao
2019-01-21 13:37:58 +08:00
@ysc3839 The stream or file "/mnt/d/www/laravel/storage/logs/laravel-2019-01-21.log" could not be opened: failed to open stream: Permission denied
ysc3839
2019-01-21 13:40:15 +08:00
stat /mnt/d/www/laravel/storage/logs/laravel-2019-01-21.log
看看?
handsomehaitao
2019-01-21 13:41:21 +08:00
@ysc3839 stat: cannot stat '/mnt/d/www/laravel/storage/logs/laravel-2019-01-21.log': No such file or directory 没有写权限
handsomehaitao
2019-01-21 13:42:46 +08:00
@ysc3839 没有创建文件的权限
ysc3839
2019-01-21 14:50:48 +08:00
@handsomehaitao
ls -al /mnt/d/www/laravel/storage/logs/
看看?
yaxin
2019-01-21 16:07:01 +08:00
1. 首先`ps -ef | grep php`看一下你 php-fpm 的运行用户,假如为 www-data
2. `id www-data`看一下用户`www-data`的 uid
3. `mount`看一下挂载参数,看一下挂载参数中的 uid

这两个 uid 应该是不同的,解决方法有两个:

1. 修改日志文件夹的权限或者所属用户
```shell
chmod 777 /mnt/d/www/laravel/storage/logs/
# 或者
chown www-data /mnt/d/www/laravel/storage/logs/
```

2. 修改 php-fpm 的所属用户,这个 google 一下就能找到修改方法
handsomehaitao
2019-07-17 10:16:50 +08:00
@yaxin 十分感谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/528970

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX