IT资讯 WSL 2 已支持直接挂载 Linux EXT4 磁盘

skot · 2021-11-14 10:30:06 · 热度: 17

如果你正在使用 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>

WSL 2 已支持直接挂载 Linux EXT4 磁盘

详细使用方式查看文档

猜你喜欢:
暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册