So, I get ask a lot on how to move a WSL2 distro to other drive. And this is the easiest I found.
First let us check what distros are we going to move to other drive by running this command:
wsl -l -v
Next, we need to make sure distributions are not running by running.
wsl --shutdown
Its optional but having a backup is important. You can create a directory where you want to put the backup on your system. In my case I will create a wsl folder iny my D drive. And then run wsl export to export the distribution.
mkdir D:/backup
wsl --export Ubuntu-20.04 D:\backup\ubuntu.tar
Wait till the WSL export is over (it may take much time). A TAR archive with your WSL ext4 file system will appear in the target directory.
Then you may remove the WSL files on the source disk:
wsl --unregister Ubuntu-20.04
Set up a new folder on a different drive for your Linux files and use a command to bring those files into the folder. In my case I will create WSL folder in my D drive.
mkdir D:\WSL
Then Let us run the import to import it in our WLS directory.
wsl --import Ubuntu-20.04 D:\WSL\ D:\backup\ubuntu.tar
There you go. You have now moved your distro to your other drive.
Top comments (0)