我已经安装了WSL2并在其上部署了两台计算机:
可以在我的Ubuntu-20.04机器上运行多个win10实例吗?
发布于 2021-02-05 17:16:33
是的完全有可能。以下是我推荐的步骤。在PowerShell中(您也可以使用cmd ):
WSL。这不一定在你的C:\驱动器上。images和instances。再说一次,名字真的取决于你。wsl -l -v只是为了确认您当前的发行版名称。wsl --export Ubuntu images\2021-02-05_Ubuntu20.04_snapshot.tar的东西备份现有的20.04发行版(当然,假设您的发行版名为"Ubuntu“)。wsl --import Ubuntu20.04_clone instances\Ubuntu20.04_clone images\2021-02-05_Ubuntu20.04_snapshot.tar --version 2的快照创建一个新实例。当ext4.vhdx文件完成时,您应该会在instances\Ubuntu20.04_clone目录中看到它。--version是可选的,但如果需要,可以同时创建WSL1和WSL2实例。(例如,如果需要访问NTFS文件系统,WSL1要快得多。)wsl ~ -d Ubuntu20.04_clone启动该实例。或者重新启动Windows终端(假设您正在使用它),则应该自动检测到新实例。/etc/wsl.conf来设置您的用户名:
用户default=me
..。当然,替换你的用户名。wsl --terminate Ubuntu20.04_clone)并重新启动该发行版,并确认您的环境正在按您的预期操作。- "Reset" the old image to a clean state by `wsl --unregister <distroname>` of the original distribution.- Re-run the "App" (technically it's an "App Execution Alias") from the Windows Start Menu with _Start->Run_ and type _Ubuntu_. This will re-run the configuration steps and create your default user/password/etc. (Thanks @JackoBongo for the suggestion in the comments for this).- For convenience, I recommend going ahead and adding the `/etc/wsl.conf` as described above to this instance. That will keep you from having to do it each time you add or replace an instance. Note: Don't do this if you plan to distribute this image to other users; just if you are doing this for yourself.- Back up this "clean copy" using the `wsl --export` command as above, to something like `2021-02-05_Ubuntu20.04_default.tar`. This "clean" version can now be your starting point for a `wsl --import` if you want to spin up a new Ubuntu 20.04 to test something out without worrying that your apps/customizations from your normal working environment get in the way.- Since you are already running multiple distributions (CentOS and Ubuntu), then I'm guessing you are using something like Windows Terminal already. But if you launch Ubuntu through the start menu with the "Ubuntu" entry, then you will probably want to copy your cloned `vhdx` file back over the newly installed clean version. You'll find the "default" version in `%userprofile%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc` (or something similar).发布于 2021-09-18 00:27:45
GitHub (我的项目)上也有一个GUI,用于管理多个WSL2实例。也许能帮你节省一点时间。
https://stackoverflow.com/questions/66065419
复制相似问题