Try   HackMD

在 WSL 中掛載 windows 檔案系統

根據 WSL 跨文件系統配置 介紹中 Automount Settings章節的描述,WSL 會自動將 windows 檔案系統通過 DrfFS 檔案系統掛載到 /mnt 路徑下。

如需將 windows 檔案系統挂載到 WSL 的指定位置,首先需要停用自動掛載:編輯 /etc/wsl.conf 檔案,添加以下内容:

[automount]
enabled=false

然後,在 /etc/fstab 檔案中配置掛載:

C:      /mnt/c  drvfs   errors=remount-ro       0       1
F:      /path/to/mount/point        drvfs   defaults,uid=<loginuid>,gid=<logingid>      0       0

注意需要挂在 C 盤符到 /mnt/c ,權限設置參考 Ubuntu 中的 fstab,否則 WSL 啓動時會報錯;然後掛載指定的盤符到指定的掛載點,權限設置參考鳥哥的 Linux 私房菜 14.1.3 實作 Quota 流程-1:檔案系統的支援與觀察(/etc/fstab, /etc/mtab)章節

修改完 /etc/fstab 後,務必要驗證一下!若有發生錯誤得要趕緊處理!

# umount /mnt/c # umount /mnt/f # mount -a $ df -h |grep mnt/c drvfs 500G 100G 400G 25% /mnt/c $ df -h |grep home drvfs 151G 98M 151G 1% /path/to/mount/point

以後再啓動 WSL,就以上面的配置掛載 windows 檔案系統了。