Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Move a Windows 10 WSL 2 Linux Distribution to Another Location [closed]

Windows 10 has installed a WSL 2 Linux distribution to my C: drive. The drive is running out of space. How can I move the distro to another drive?

like image 969
BSalita Avatar asked Jun 23 '20 10:06

BSalita


1 Answers

The Windows 10 command, wsl, can be used to move a WSL distribution to another location. The procedure uses the --export and --import arguments. For example, this command will export the distro named Ubuntu-20.04 to Moved-Ubuntu-20.04. The imported distribution cannot be an existing distro name therefore, as shown, a different name Moved-Ubuntu-20.04 is specified.

wsl --export Ubuntu-20.04 - | wsl --import Moved-Ubuntu-20.04 d:\wsl -

If desired, you can remove the original distro, thus freeing up space, using wsl --unregister Ubuntu-20.04. The same export/import procedure can be used to rename a distro, such as renaming from Moved-Ubuntu-20.04 back to the original Ubuntu-20.04.

FYI, wsl gives imported distro the filename of ext4.vhdx.

like image 64
BSalita Avatar answered Oct 20 '22 03:10

BSalita