在Windows10中,如何在WSL中安装多个独立的Ubuntu实例?我想为不同的工作空间提供单独的实例。例如,一个用于Python开发,一个用于Ruby开发,一个用于.Net核心开发,等等。我知道我可以将所有这些都塞进同一个Ubuntu实例中,但我更希望每个场景都有一个单独的。这个是可能的吗?
发布于 2020-02-27 15:54:34
较新的wsl命令的导入/导出功能可以很容易地创建发行版的副本,而无需安装任何额外的工具或使用RegEdit。例如
cd C:\Users\MattSlay
wsl --export Ubuntu ubuntu.tar
wsl --import UbuntuRuby .\UbuntuRuby ubuntu.tar
wsl --import UbuntuPython .\UbuntuPython ubuntu.tar
wsl --import UbuntuDotNet .\UbuntuDotNet ubuntu.tar
wsl -d UbuntuRubywsl -d <distro>发布发行版。如果已经安装了WSL 2,那么可以在--import期间使用--version选项在不同版本之间转换发行版:
wsl --import UbuntuRuby .\UbuntuRuby ubuntu.tar --version 2一个较小的发行版,比如Alpine,可以使实验变得更快。最后,wsl --import可以从标准输入-读取,wsl --export可以写入标准输出-。如果需要,这允许使用压缩程序来节省磁盘空间。
发布于 2018-07-30 10:58:37
这是可能的,但需要做一些工作。您可以使用LxRunOffline -“Windows Subsystem for Linux (WSL)的全功能实用程序”。
你可以通过Chocolatey:choco install lxrunoffline安装它,或者下载并解压缩。
您可能希望将LxRunOffline.exe添加到您的路径中。
https://lxrunoffline.apphb.com/download/{distro}/{version}将重定向到所需发行版的下载页面。根据lxrunoffline wiki的说法,在这种情况下,它应该是.../ubuntu/xenial或类似的,或者你可以直接从Canonical下载。
然后,您可以:
使用不同的名称和目标目录多次执行LxRunOffline install -n someName -d where/to/install -f path/to/downloaded/distro。
然后,您可以使用lxrunoffline -w -n someName启动所需的安装,最后,您可以在桌面上创建多个快捷方式,为特定的工作空间提供不同的选项。
LxRunOffline可用命令:
list List all installed distributions.
get-default Get the default distribution, which is used by bash.exe.
set-default Set the default distribution, which is used by bash.exe.
install Install a new distribution.
uninstall Uninstall a distribution.
register Register an existing installation directory.
unregister Unregister a distribution but not delete the installation directory.
move Move a distribution to a new directory.
duplicate Duplicate an existing distribution in a new directory.
run Run a command in a distribution.
get-dir Get the installation directory of a distribution.
get-env Get the default environment variables of a distribution.
set-env Set the default environment variables of a distribution.
get-uid Get the UID of the default user of a distribution.
set-uid Set the UID of the default user of a distribution.
get-kernelcmd Get the default kernel command line of a distribution.
set-kernelcmd Set the default kernel command line of a distribution.
get-flags Get some flags of a distribution. See https://msdn.microsoft.com/en-us/library/windows/desktop/mt826872(v=vs.85).aspx for details.
set-flags Set some flags of a distribution. See https://msdn.microsoft.com/en-us/library/windows/desktop/mt826872(v=vs.85).aspx for details.
version Get version information about this LxRunOffline.exe.发布于 2018-08-05 13:13:32
首先,我们必须找到该Windows应用商店Appx的安装位置。以下是用于查找该路径的Powershell脚本。首先输入分发名称(例如Ubuntu18.04)。
$DistroName=Read-Host "Enter Distribution Name"
$path = (Get-AppxPackage "*$DistroName*").InstallLocation
echo $path
Invoke-Item $path
pauseUbuntu 18.04的安装路径为:
%ProgramFiles%\WindowsApps\CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2018.427.0_x64__79rhkp1fndgsc在PS脚本中,Invoke-Item将在文件资源管理器中打开该路径。如果该路径不可见或显示任何安全问题,则从其“属性”菜单授予访问该文件夹的权限。现在只复制这两个必需的文件:
名为install.tar.gz (或任何TAR.GZ文件)的
下面是下一节。Backup,然后删除注册表项HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss。将这两个文件放在文件夹结构中,如下图所示(或根据您的需要):
C:\MyFiles
|
+-- UbuntuPython
| |
| +-- ubuntu.exe
| +-- install.tar.gz
|
+-- UbuntuRuby
|
+-- ubuntu.exe
+-- install.tar.gz文件夹名称应与不同。现在双击第一个复制的.exe可执行文件,等待它安装完毕。打开HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss\<some-GUID>并将DistributionName字符串注册表更改为UbuntuPython (或any)。对每个实例重复此过程。对于每个实例,GUID都将是新的。确保您将DistributionName 注册表的条目更改为不同的值,否则ubuntu.exe将执行wsl.exe而不是安装。请在GitHub: Microsoft/WSL-DistroLauncher查看这些EXE文件的源代码。
https://stackoverflow.com/questions/51584765
复制相似问题