Moving WSL to Another Drive
WSL is a great stuff! 😍 But sometimes, it may take up too much space in C drive, especially its
ext4 file system. So in this article, I’d like to show how to move it to another drive so as to release drive storage pressure.
Step 1. Preparation
First, you should make sure you know your username and password of WSL. If not, just open it, and use
whoami command to find it out. Then, your WSL should be shutdown. In PowerShell, run the following command to make sure your WSL is down.
wsl --list --verbose
If the output is like , it means your WSL is down. If not, run
wsl --shutdown to … shut it down. 😌
Notice: Here, remember the name of your distribution. :)
Then, create some directories. For example, here, I created
Backup\ for intermediate file backup, and
Storage\ for the final location.
Step 2. Export WSL File System
Now, it’s time to export WSL to another place. So, open your PowerShell, and execute the following command. Remember to replace the directory with your own.
wsl --export Ubuntu-20.04 E:\IDE\WSL\Backup\ubuntu.tar
If everything goes well, you will see this.
Step 3. Import WSL File System
Before your import stuffs, there are few steps to go. First, you got to unregister your WSL temporarily.
wsl --unregister Ubuntu-20.04
And you will see the following output.
Then, you can start import. Remember the directory we created before? Will place our file system there.
# wsl --import distro destination source
And you will se this.
Step 4. Finishing up
Now, finally, we got to set up our WSL again. There won’t be any output on success.
Notice: If you’re using Ubuntu 20.04, the executable file should be
ubuntu2004.exe. Otherwise, please use
lscommand to check it by yourself.
Ta-da!🎉 Now you can run WSL again!
Easy, huh? :)
You can visit this site at both: