wsl2里面的文件物理存储在哪里? [英] Where are the files inside wsl2 physically stored?

查看:640
本文介绍了wsl2里面的文件物理存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的 Windows 机器上安装了 wsl2,但我无法弄清楚文件的实际存储位置.
请注意,我并不是说我想在文件资源管理器中浏览它们 - 我知道这可以通过在资源管理器中输入 \\wsl$\ 来完成.
如果我不得不猜测,我会说这些文件存储在存储操作系统的同一个硬盘驱动器中.

I've installed wsl2 on my windows machine and I was not able to figure out where the files are actually stored.
Note, that I don't mean that I wanna browse them inside the file explorer - I know it can be done by typing in the explorer \\wsl$\.
If I would have to guess I would say the files are stored in the same hard-drive that the os is stored.

所以实际上我有两个相关的问题.

So actually I have two related questions.

  1. 文件存储在哪里?
  2. 如果它们存储在我的操作系统的硬盘驱动器中,我可以以某种方式将我的 wsl 重新定位到另一个硬盘驱动器吗?


我能够找到安装路径,在我的机器中路径是:
C:\Users\Eliran\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState

有没有办法将它挂载到另一个位置?

Is there a way to mount this to another location?

推荐答案

所有文件都存放在安装目录下的一个ext4.vhd文件中,不能直接挂载到windows上它在 ext4 (obv) 中

All the files are stored in a ext4.vhd files in the installation directory, which you can't mount directly onto windows as it is in ext4 (obv)

有两种方法可以改变上述vhd文件的位置,官方的,繁琐的方式和非官方的快速和肮脏的方式

There's two ways to change the location of the above mentioned vhd file the official, tedious way and an unofficial quick and dirty way

官方繁琐的方式

  1. 使用 wsl.exe --export 将发行版导出到某个位置<文件名> 来自 CMD/PowerShell
  2. 使用 wsl.exe --import 将发行版导入到其他位置<安装位置><文件名>[选项]
  1. Export the distro to a location with wsl.exe --export <Distro> <FileName> from CMD/PowerShell
  2. Import the distro to a different location with wsl.exe --import <Distro> <InstallLocation> <FileName> [Options]

这样做的问题是它非常耗时,并且在您执行此操作后,祈祷它可以毫无问题地导出和导入价值数 GB 的数千个文件

The problems with this is it's quite time consuming and after you do this, pray that it exported and imported several gigabytes worth of thousands of files without any problems

快速而肮脏的方式

这涉及一个名为 lxrunoffline

要安装它(最多需要一分钟),请阅读开发人员的说明此处

To install it (takes like a min at max) read through the instructions by the dev here

如果您通过从发布页面手动下载二进制文件来安装它,请确保将其安装到 PATH 中的目录,例如 C:\Windows

If you installed it by manually downloading the binaries from the release page, make sure to install it to a directory in PATH, like C:\Windows

现在这个过程很简单 lxrunoffline move -n -d <目标文件夹>

例如 lxrunoffline move -n Ubuntu-20.04 -d G:\wsl\

希望对我有帮助

错别字

这篇关于wsl2里面的文件物理存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆