My colleague Tara and I were working on prepping a system for Azure IoT development and were using WSL2 on our respective machines. The scripts we were running were long-running and tedious and by the time they were done we basically had a totally customized perfect distro.
我和我的同事Tara正在为Azure IoT开发准备系统,并在各自的计算机上使用WSL2。 我们运行的脚本运行时间长且乏味,到完成时,我们基本上有了一个完全定制的完美发行版。
Rather than sharing our scripts and having folks run them for hours, we instead decided to export the distro and import it on n number of machines. That way Tara could set up the distro perfectly and then give it to me.
与其共享我们的脚本并让人们运行几个小时,我们决定导出发行版并将其导入n台计算机上。 这样Tara可以完美地创建发行版,然后将其分发给我。
For example, when using PowerShell I can do this:
例如,当使用PowerShell时,我可以这样做:
C:\Users\Scott\Desktop> wsl --export PerfectWSLDistro ./PerfectWSLDistro.tar
Then I can share the resulting tar and give it to a friend and they can do this! (Note that I'm using ~ which is your home directory from PowerShell. If you're using cmd.exe you'll want to include the full path like c:\users\scott\Appdata\Local\PerfectDistro)
然后,我可以共享生成的tar并将其提供给朋友,他们可以做到这一点! (请注意,我使用的是〜,这是PowerShell中的主目录。如果您使用的是cmd.exe,则需要包括完整路径,例如c:\ users \ scott \ Appdata \ Local \ PerfectDistro)
mkdir ~/AppData/Local/PerfectDistro
wsl --import PerfectDistro ~/AppData/Local/PerfectDistro ./PerfectWSLDistro.tar --version 2
You can list our your WSL distros like this:
您可以像这样列出我们的WSL发行版:
C:\Users\Scott\Desktop> wsl --list -v
NAME STATE VERSION
* Ubuntu-18.04 Stopped 2
WLinux Stopped 2
Debian Stopped 1
PerfectDistro Stopped 2
It's surprisingly easy! Also, make sure you have the latest version of the Windows Terminal (and if you've got an old version and haven't deleted your profile.json, it's time to start fresh) it will automatically detect your WSL distros and make menu items for them!
非常简单! 另外,请确保您具有最新版本的Windows Terminal (并且如果您使用的是旧版本并且尚未删除profile.json,那么现在该重新开始了),它将自动检测您的WSL发行版并制作菜单项为他们!
Also be sure to check out my YouTube video on developing with WSL2!
另外,请务必查看有关使用WSL2开发的YouTube视频!