WSL2挂载DrvFs文件系统

# Automatically mount Windows drive when the distribution is launched
[automount]

# Set to true will automount fixed drives (C:/ or D:/) with DrvFs under the root directory set above. Set to false means drives won't be mounted automatically, but need to be mounted manually or with fstab.
enabled = true

# Sets the directory where fixed drives will be automatically mounted. This example changes the mount location, so your C-drive would be /c, rather than the default /mnt/c. 
root = /

# DrvFs-specific options can be specified.  
options = "metadata,uid=1003,gid=1003,umask=077,fmask=11,case=off"

# Sets the `/etc/fstab` file to be processed when a WSL distribution is launched.
mountFsTab = true

# Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 1.1.1.1).
[network]
hostname = DemoHost
generateHosts = false
generateResolvConf = false

# Set whether WSL supports interop process like launching Windows apps and adding path variables. Setting these to false will block the launch of Windows processes and block adding $PATH environment variables.
[interop]
enabled = false
appendWindowsPath = false

# Set the user when launching a distribution with WSL.
[user]
default = DemoUser

# Set a command to run when a new WSL instance launches. This example starts the Docker container service.
[boot]
command = service docker start

需求: 挂载E盘到/mnt/e目录

挂载之前首先卸载/mnt/e
# sudo umount /mnt/e


方式一:mount不带参数
# sudo mount -t drvfs E: /mnt/e 


方式二:mount带参数
# sudo mount -t drvfs E: /mnt/e -o rw,relatime,uid=1000,gid=1000,metadata,umask=000,fmask=000,case=dir


方式三:/etc/fstab分区表
# emacs /etc/fstab
E: /mnt/e drvfs rw,relatime,uid=1000,gid=1000,metadata,umask=22,fmask=111,case=dir 0 0


方式四:/etc/wsl.conf
[automount]
enabled = true
options = "metadata,uid=0,gid=0,umask=0000,fmask=0000,dmask=0000,case=dir"
mountFsTab = true


注意:WSL2如果使用case=dir,发现在/mnt/e/下无法创建目录,应该是微软的bug,待解决。
1.挂载网络上的其他位置
# sudo mkdir /mnt/test
# sudo mount -t drvfs '\\server\share' /mnt/test


2.挂载NTFS上空的文件夹
# sudo mount -t drvfs 'C:\mountpoint' /mnt/test2

猜你喜欢

转载自blog.csdn.net/u010164190/article/details/125708030