如果你正在使用 Windows 11 Build 22000 或更高版本,现在已支持通过 WSL 直接挂载 Linux 磁盘

Windows 文档显示,如果要访问不受 Windows 支持的 Linux 磁盘格式(如 EXT4),可以使用 WSL 2 挂载磁盘然后再访问其内容。

相关命令

--mount <Disk>
   Attaches and mounts a physical disk in all WSL2 distributions.
   Options:
    --bare
        Attach the disk to WSL2, but don't mount it.

    --type <Type>
        Filesystem to use when mounting a disk, if not specified defaults to ext4.

    --options <Options>
        Additional mount options.

    --partition <Index>
        Index of the partition to mount, if not specified defaults to the whole disk.

--unmount [Disk]
   Unmounts and detaches a disk from all WSL2 distributions.
   Unmounts and detaches all disks if called without argument.

值得注意的是,在 WSL 2 挂载磁盘需要管理员权限。WSL 2 的挂载命令mount不支持挂载目前正在使用的磁盘(或属于该磁盘的分区)。wsl --mount命令用于挂载整个磁盘,即使你需要挂载的只是一个分区。此外也不能挂载 Windows 安装盘。

简单使用

  • 挂载未分区的磁盘

如果磁盘没有任何分区,可以使用挂载命令wsl --mount命令直接加载。首先需要标记磁盘:

GET-CimInstance -query "SELECT * from Win32_DiskDrive"

然后挂载磁盘:

wsl --mount <DiskPath>

详细使用方式查看文档

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。