Recently, the C
drive is almost full with using, and not empty much after cleaning it, so I plan to move WSL to a new drive. In the settings, “Ubuntu on Windows” has a “Move” button, but it is set to “cannot Move”. After spending a long time to try to cleaning, I found that it is better to move it to another drive, otherwise it will easily fill up.
After some research, I didn’t find a perfect implementation method, but I find a method that barely be regarded as a method, it is imperfect (why it is not perfect will be explained in detail later). The operation logic is:
C
drive is full, it is better to directly export to the target drive).One thing you must notice: The reason why this method is not perfect is that all associated data and software will be lost. Because for import, need to log out and uninstall the old WSL to free up the full space and use the following commands to do:
wsl --unregister WSL_NAME_INSTALLED
This command will lost all settings, data and softwares of WSL.
=======2023-04-10========
You can back up your old WSL data and software from C:\Users\USERNAME\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc
. This is the default path for WSL.
The first step is to export the WSL installed. The method is very simple.
Open PowerShell and use the following command:
wsl --export WSL_NAME_INSTALLE TARGET_PATH\CUSTOM_NAME.tar
For example, there is a WSL named “Ubuntu
” located on the C
drive. We want to move it to the G
drive, and the output tar file is named “myUbuntu.tar
”:
wsl --export Ubuntu G:\\WSL\myUbuntu.tar
Importing a compressed package is same as importing a distribution.
But you need free space of old WSL, so use following command:
wsl --unregister WSL_NAME_INSTELLED
This command will lost all settings, data and softwares of WSL.
This is an example as before:
wsl --unregister Ubuntu
Then import the WSL package:
wsl --import WSL_NAME PATH WSL_PACKAGE_PATH
For example:
wsl --import Ubuntu G:\\WSL G:\\WSL\myUbuntu.tar
It have moved to new position and you can re-open terminal to use, but lost all data.
I hope these will help someone in need~