工程师 - Windows下使用WSL来访问本地的Linux文件系统

    
Access Linux filesystems in Windows and WSL 2
从 Windows Insiders 预览版构建 20211 开始,WSL 2 将提供一项新功能:wsl --mount。这一新参数允许在 WSL 2 中连接并挂载物理磁盘,从而使您能够访问 Windows 本身不支持的文件系统(如 ext4)。
Starting with Windows Insiders preview build 20211, WSL 2 will be offering a new feature: wsl --mount. This new parameter allows a physical disk to be attached and mounted inside WSL 2, which enables you to access filesystems that aren’t natively supported by Windows (such as ext4).
因此,如果你使用不同的磁盘进行 Windows 和 Linux 双启动,现在就可以从 Windows 访问 Linux 文件了!
So, if you’re dual booting with Windows & Linux using different disks, you can now access your Linux files from Windows!
Getting started
要挂载磁盘,请打开具有管理员权限的 PowerShell 窗口并运行:
To mount a disk, open a PowerShell window with administrator privileges and run:
wsl --mount <DiskPath>
要在 Windows 中列出可用磁盘,请运行:
To list the available disks in Windows, run:
wmic diskdrive list brief
要从 WSL 2 中卸载和分离磁盘,请运行:
To unmount and detach the disk from WSL 2, run
wsl --unmount <Diskpath>
磁盘路径可在 “DeviceID ”列中找到。通常是 \.\.\PHYSICALDRIVE* 格式。下面是一个将特定硬盘分区挂载到 WSL 并浏览其文件的示例。
The disks paths are available under the ‘DeviceID’ columns. Usually under the \\.\\\.\PHYSICALDRIVE* format. Below is an example of mounting a specific partition of a given hard disk into WSL and browsing its files.
Accessing these files with File Explorer
挂载后,也可以通过 Windows 资源管理器访问这些磁盘,方法是导航到\\wsl$,然后导航到挂载文件夹。
Once mounted, it’s also possible to access these disks through the Windows explorer by navigating to \\wsl$ and then to the mount folder.
Limitations
默认情况下,wsl --mount 会尝试将磁盘挂载为 ext4。要指定文件系统,或了解更多高级方案,请查看"在 WSL 2 中挂载磁盘"。
By default, wsl --mount attempts to mount the disk as ext4. To specify a filesystem, or for more advanced scenarios, check out Mount a disk in WSL 2.
另外请注意,此功能有一个限制,即只能将物理磁盘连接到 WSL 2。目前还无法附加单个分区。有关限制的更多详情,请点击此处。
Also please note that this feature comes with the limitation that only physical disks can be attached to WSL 2. At this time, it’s not possible to attach a single partition. More details on the limitations here.
参考;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值