开始在 WSL 2 (preview 中安装 Linux 磁盘)Get started mounting a Linux disk in WSL 2 (preview)
04/08/2021
本文内容
如果要访问 Windows 不支持的 Linux 磁盘格式,则可以使用 WSL 2 来装入磁盘并访问其内容。If you want to access a Linux disk format that isn't supported by Windows, you can use WSL 2 to mount your disk and access its content. 本教程将介绍如何识别要附加到 WSL2 的磁盘和分区,如何装载这些磁盘和分区,以及如何对其进行访问。This tutorial will cover the steps to identify the disk and partition to attach to WSL2, how to mount them, and how to access them.
备注
需要管理员访问权限才能将磁盘附加到 WSL 2。Administrator access is required to attach a disk to WSL 2.
WSL 2 mount 命令不支持装入磁盘 (或属于当前正在使用的磁盘) 的分区。The WSL 2 mount command does not support mounting a disk (or partitions that belong to the disk) that is currently in use. wsl --mount 即使只请求了一个分区,也始终会附加整个磁盘。wsl --mount always attaches the entire disk even if only a partition is requested. 无法装载 Windows 安装磁盘。You can't mount the Windows installation disk.
先决条件Prerequisites
需要在 Windows 10 版本20211或更高版本上才能访问此功能。You will need to be on Windows 10 Build 20211 or higher to access this feature. 可以加入 Windows 预览 体验计划 ,以获取最新的预览版。You can join the Windows Insiders Program to get the latest preview builds.
装载未分区的磁盘Mounting an unpartitioned disk
在这种最简单的情况下,如果磁盘不包含任何分区,则可以使用命令直接装载该磁盘 wsl --mount 。In this simplest case, if you have a disk that doesn't have any partitions, you can mount it directly using the wsl --mount command. 首先需要标识该磁盘。First you need to identify the disk.
确定磁盘Identify the disk
若要列出 Windows 中的可用磁盘,请运行:To list the available disks in Windows, run:
wmic diskdrive list brief
磁盘路径位于 "DeviceID" 列下。The disks paths are available under the 'DeviceID' columns. 通常在 \\.\PHYSICALDRIVE* 格式下。Usually under the \\.\PHYSICALDRIVE* format.
装载磁盘Mount the disk
然后,在 Powershell 中,可以使用上面发现的磁盘路径装载磁盘。Then in Powershell you can mount the disk using the Disk path discovered above.