V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
handsomehaitao
V2EX  ›  问与答

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

  •  
  •   handsomehaitao · 2019-01-21 09:46:03 +08:00 · 3635 次点击
    这是一个创建于 1919 天前的主题,其中的信息可能已经有所发展或是发生改变。

    以下是 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)

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

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

    [network]
    generateHosts = true
    generateResolvConf = true
    ```
    handsomehaitao
        5
    handsomehaitao  
    OP
       2019-01-21 10:33:29 +08:00
    @yaxin 多谢你的回答,已经解决了我的问题
    handsomehaitao
        6
    handsomehaitao  
    OP
       2019-01-21 10:36:24 +08:00
    @yaxin 请问 nginx 配置域名指向了 d 盘文件,访问网站,日志文件没有权限,怎么解决呢,我 ubuntu 中是 root 用户
    ReVanTis
        7
    ReVanTis  
       2019-01-21 11:11:40 +08:00 via Android
    sudo mount -t drvfs c: /mnt/c
    ysc3839
        8
    ysc3839  
       2019-01-21 12:55:03 +08:00 via Android
    @handsomehaitao
    怎么个没有权限呢?描述一下具体的错误。
    handsomehaitao
        9
    handsomehaitao  
    OP
       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
        10
    ysc3839  
       2019-01-21 13:40:15 +08:00 via Android
    stat /mnt/d/www/laravel/storage/logs/laravel-2019-01-21.log
    看看?
    handsomehaitao
        11
    handsomehaitao  
    OP
       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
        12
    handsomehaitao  
    OP
       2019-01-21 13:42:46 +08:00
    @ysc3839 没有创建文件的权限
    ysc3839
        13
    ysc3839  
       2019-01-21 14:50:48 +08:00 via Android
    @handsomehaitao
    ls -al /mnt/d/www/laravel/storage/logs/
    看看?
    yaxin
        14
    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
        15
    handsomehaitao  
    OP
       2019-07-17 10:16:50 +08:00
    @yaxin 十分感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   992 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 22:01 · PVG 06:01 · LAX 15:01 · JFK 18:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.