Win10中将资源管理器中的OneDrive彻底移除的方法,Windows下subsystem子系统(wsl)的默认安装位置,Windows启用WSL2并完成默认安装位置变更
1、使用Win+R打开运行对话框,输入regedit打开注册表编辑器;
2、定位到HKEY_CLASSES_ROOT\CLSID{018D5C66-4533-4307-9B53-224DE2ED1FE6},在右边双击System.IsPinnedToNameSpaceTree这个键,将System.IsPinnedToNameSpaceTree中的值从1改为0。
关闭资源管理器再打开就可以发现 oneDrive 没了 .
参考:
https://blog.csdn.net/shylogo/article/details/78148668
Windows下subsystem子系统(wsl)的默认安装位置
C:\Users\THINK\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
备注:THINK是我的Windows登录用户名,你换成自己的用户名即可,知道了这个文件夹之后就可以方便地进行subsystem的文件管理了,写好后的程序也可以转移到自己的windows系统下,避免了程序丢失的烦恼。
Windows启用WSL2并完成默认安装位置变更
一 前置条件
1.1 启用“适用于 Linux 的 Windows 子系统”
以管理员权限运行cmd.exe或PowerShell,输入如下内容:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
也可在程序和功能中点击“启用或关闭Windows功能”,勾选“虚拟机平台”。
1.2 启用虚拟机功能
启用虚拟机功能,安装 WSL 2 之前,必须启用“虚拟机平台”可选功能。 使用管理员权限运行cmd.exe或PowerShell,输入如下内容:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
也可在程序和功能中点击“启用或关闭Windows功能”,勾选“适用于 Linux 的 Windows 子系统”。
下载 Linux 内核更新包:wsl.exe --install或wsl.exe --update,适用于 x64 计算机的 WSL2 Linux 内核更新包,单击即可下载。
二 系统配置
将 WSL 2 设置为默认版本:
wsl --set-default-version 2
列出目前支持的发行版信息:
wsl --list --online
安装所选的 Linux 分发即可体验。如:
wsl --install -d AlmaLinux-8
三 导出并完成WSL迁移
列出当前系统已安装的WSL发行版信息:
wsl -l -v
停止WSL及相关发行版:
wsl --shutdown
导出需要迁移的发行版,默认为tar包:
wsl --export AlmaLinux-8 F:\AlmaLinux-8.tar
取消注册分发版并删除根文件系统:
wsl --unregister AlmaLinux-8
从备份恢复、导入发行版:
wsl --import AlmaLinux-8 D:\Work\WSL\AlmaLinux-8 F:\AlmaLinux-8.tar --version 2
参考资料
WSL2 默认安装在 C 盘下,系统盘空间有限,推荐迁移安装目录。
1. 默认安装的 WSL2 目录
C:\Users\cheng\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx

2. 将安装的 WSL2 迁移至指定目录
wsl --list --verbose-wsl -l -v
查看安装在 Windows 计算机上的 Linux 发行版列表,其中包括状态和运行发行版的 WSL 版本 (WSL 1 或 WSL 2)。
wsl --shutdown
立即终止所有正在运行的发行版和 WSL 2 轻量级实用工具虚拟机。
Microsoft Windows [版本 10.0.22621.1265]
(c) Microsoft Corporation。保留所有权利。
C:\Users\cheng>wsl --list --verbose
NAME STATE VERSION
* Ubuntu-20.04 Running 2
C:\Users\cheng>
C:\Users\cheng>wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Running 2
C:\Users\cheng>
C:\Users\cheng>wsl --shutdown
C:\Users\cheng>
C:\Users\cheng>wsl --list --verbose
NAME STATE VERSION
* Ubuntu-20.04 Stopped 2
C:\Users\cheng>
wsl --export Ubuntu-20.04 f:\ubuntu20.04.tar
将指定 tar 文件导出为新的发行版。--export 选项后面是查看运行状态中 Linux 系统的名字。
C:\Users\cheng>wsl --export Ubuntu-20.04 f:\ubuntu2004.tar
C:\Users\cheng>

- Unregister or uninstall a Linux distribution (注销或卸载 Linux 发行版)
While Linux distributions can be installed through the Microsoft Store, they can’t be uninstalled through the store.
尽管可以通过 Microsoft Store 安装 Linux 发行版,但无法通过 Store 将其卸载。
To unregister and uninstall a WSL distribution
wsl --unregister <DistributionName>
Replacing <DistributionName> with the name of your targeted Linux distribution will unregister that distribution from WSL so it can be reinstalled or cleaned up. Caution: Once unregistered, all data, settings, and software associated with that distribution will be permanently lost. Reinstalling from the store will install a clean copy of the distribution. For example, wsl --unregister Ubuntu would remove Ubuntu from the distributions available in WSL. Running wsl --list will reveal that it is no longer listed.
如果将 <DistributionName> 替换为目标 Linux 发行版的名称,则将从 WSL 取消注册该发行版,以便可以重新安装或清理它。警告:取消注册后,与该分发版关联的所有数据、设置和软件将永久丢失。从 Store 重新安装会安装分发版的干净副本。 例如:wsl --unregister Ubuntu 将从可用于 WSL 的发行版中删除 Ubuntu。运行 wsl --list 将会显示它不再列出。
You can also uninstall the Linux distribution app on your Windows machine just like any other store application. To reinstall, find the distribution in the Microsoft Store and select Launch.
还可以像卸载任何其他应用商店应用程序一样卸载 Windows 计算机上的 Linux 发行版应用。若要重新安装,请在 Microsoft Store 中找到该发行版,然后选择 Launch。
C:\Users\cheng>wsl --list --verbose
NAME STATE VERSION
* Ubuntu-20.04 Stopped 2
C:\Users\cheng>
C:\Users\cheng>wsl --unregister Ubuntu-20.04
正在注销...
C:\Users\cheng>
C:\Users\cheng>wsl --list --verbose
适用于 Linux 的 Windows 子系统没有已安装的分发版。
可以通过访问 Microsoft Store 来安装分发版:
https://aka.ms/wslstore
C:\Users\cheng>
wsl --import Ubuntu-20.04 f:\ubuntu_20_04 f:\ubuntu2004.tar
将指定 tar 文件导入为新的发行版。
wsl --import <Distribution Name> <InstallLocation> <FileName>
C:\Users\cheng>wsl --import Ubuntu-20.04 f:\ubuntu_20_04 f:\ubuntu2004.tar
C:\Users\cheng>
迁移成功之后,可在安装目录下查看 vhdx 文件。F:\ubuntu_20_04\ext4.vhdx

ubuntu2004.exe config --default-user yongqiang
设置默认登陆用户为安装时的用户名。
C:\Users\cheng>ubuntu2004.exe config --default-user yongqiang
C:\Users\cheng>
- 删除
f:\ubuntu2004.tar文件
C:\Users\cheng>del f:\ubuntu2004.tar
C:\Users\cheng>
3. 通过终端打开 Ubuntu-20.04
- 在 Windows 图标 [开始] 处点击鼠标右键

- 终端 / 终端 (管理员)


浙公网安备 33010602011771号