WSL2数据迁移

Posted by shensunbo on March 12, 2024
  1. WSL2的ubuntu默认安装在C盘,占用空间较大,介绍如何将数据迁移到其他盘,主要方法就是建立一个软链接
  2. 一般安装路径 C:\Users\vfvaf0\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx
  3. ext4.vhdx 拷贝到其他盘, 如 D:\wsl\ext4.vhdx
  4. 管理员权限打开cmd wsl
  5. 输入 mklink "C:\Users\vfvaf0\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\ext4.vhdx" "D:\wsl\ext4.vhdx"
  6. 如果存在以下报错,输入 cmd , 切换一下解释器,再执行 5 步骤
1
2
3
4
5
6
7
mklink : The term 'mklink' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ mklink "C:\Users\vfvaf0\AppData\Local\Packages\CanonicalGroupLimited. ...
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (mklink:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException