Mar*_*ies 14 windows-subsystem-for-linux
I have created a WSL (version 1) Ubuntu 20.04 distro which I have exported, as a backup. I have made some changes to the original distro and want to revert back to export.
The original distro install is called: Ubuntu-20.04
wsl --list
Run Code Online (Sandbox Code Playgroud)
Output:
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
Run Code Online (Sandbox Code Playgroud)
The installation folder for Ubuntu is the default folder from installation:
C:\Users\<my user name>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_xxxxx
Run Code Online (Sandbox Code Playgroud)
(I've changed the user name and UID)
I've looked at the import and export options and I can import the exported file into a new folder easily:
wsl --export Ubuntu-20.04 c:\temp\wcc-ubuntu-20-04-wsl.tar
wsl --import Ubuntu-20.04-New c:\wsl\ubuntu-new wcc-ubuntu-20-04-wsl.tar
Run Code Online (Sandbox Code Playgroud)
That then appears in the list available:
wsl --list
Run Code Online (Sandbox Code Playgroud)
Output:
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
Ubuntu-20.04-New
Run Code Online (Sandbox Code Playgroud)
If I want to use the "new" import I have to first set the default, then open access it from the command line:
wsl --setdefault Ubuntu-20.04-New
wsl -d Ubuntu-20.04-New -u myusername
Run Code Online (Sandbox Code Playgroud)
If I use the Ubuntu icon in the start menu, it seems to ignore the "new" default and will open the original install. Not a problem, I can always start WSL from command line if needed.
I then looked into how to import over the original default install. My research showed that you can delete a distro using the "unregister" option, then import the file again to same location. So I ran the unregister command:
wsl --unregister Ubuntu-20.04
Run Code Online (Sandbox Code Playgroud)
However, when I try the import again, setting the target to the setup folder I got issues with the folder is not empty.
C:\Users\<my user name>\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_xxxxx\LocalState
Run Code Online (Sandbox Code Playgroud)
Having looked at an imported WSL it only has two folders:
Following a unregister the rootfs folder is removed entirely and the temp remains. To overwrite the destination you have to delete the temp folder. Looking back at the original install folder these two folders exist under the "LocalState" subfolder. So I manually deleted these two folders.
I was then able to perform an import to the original folder. I was able to start the WSL via command line and also via the ubuntu icon in the start menu. The only thing I noticed was the command prompt had defaulted to the "root" user.
root@xxxxxxx:~#
Run Code Online (Sandbox Code Playgroud)
I am able to login as the correct user with the switch users "su" command.
su - myusername
myusername@xxxxxxx:~#
Run Code Online (Sandbox Code Playgroud)
I haven't fully tested the imported WSL to make sure it does everything it needs. Not found any errors.
我担心这可能会导致我从未见过的问题。我确实阅读了几篇文章和博客,明确表示不要更改安装文件夹中的任何文件。我希望其他人也想做同样的事情并且没有任何问题,做了不同的事情或发现我使用的方法有问题。
感谢您花时间准备此内容以及任何评论或建议。
iam*_*nph 13
这是我对我所做的:
列出所有发行版和wsl --unregister Ubuntu (Default)
要删除的任何内容。
PS C:\Users\me> wsl --list
Windows Subsystem for Linux Distributions:
docker-desktop (Default)
docker-desktop-data
Run Code Online (Sandbox Code Playgroud)
进行导入。
PS C:\Users\me> wsl --import Ubuntu C:\Users\me\wsl\Ubuntu E:\wsl\Ubuntu.tar
Run Code Online (Sandbox Code Playgroud)
验证发行版是否已导入。
PS C:\Users\me> wsl --list
Windows Subsystem for Linux Distributions:
docker-desktop (Default)
Ubuntu <--
docker-desktop-data
Run Code Online (Sandbox Code Playgroud)
将默认用户更改为root
您
PS C:\Users\me> ubuntu.exe config --default-user me
Run Code Online (Sandbox Code Playgroud)
设置Ubuntu
为 wsl 的默认值
PS C:\Users\me> wsl --set-default Ubuntu
PS C:\Users\me> wsl --list
Windows Subsystem for Linux Distributions:
Ubuntu (Default) <--
docker-desktop
docker-desktop-data
Run Code Online (Sandbox Code Playgroud)
我最近刚刚进行了导入,到目前为止一切正常。我的项目位于 wsl 网络内部,因此它也包含在导出中。
归档时间: |
|
查看次数: |
15424 次 |
最近记录: |