Move Ubuntu WSL to Another Drive in Windows 11

The article provides a step-by-step guide on transferring Ubuntu WSL to another drive on Windows 11. It outlines methods using the graphical interface and the Windows Terminal commands, including the –move and –import commands. Users are advised to shut down WSL before transferring to prevent data corruption and enhance performance.

This article explains how to transfer Ubuntu WSL to another drive on Windows 11.

Windows Subsystem for Linux (WSL) lets developers run a GNU/Linux environment directly in Windows without setting up a virtual machine or dual-boot, including most command-line tools, utilities, and applications.

With WSL version 2 installed on Windows, you can move a Linux distribution (Ubuntu) to a different drive than the one it was installed.

Using the WSL --move command, you can relocate a Linux distribution from one drive to another. Or do the same by exporting and importing using the --import command.

The steps below walk you through moving or migrating your Linux distribution on WSL to another drive.

Transfer WSL distros to another drive

As mentioned, WSL lets you move or transfer a Linux distro to a drive other than the one it was initially installed on.

Here’s how to do it.

First, shut down WSL using the command below by running the Windows Terminal app as administration.

wsl --shutdown

Once WSL is shut down, click Start -> Settings – > Apps in the Settings app.

On the Apps window, select the “Install apps” tile to expand it.

Then, scroll down the installed apps and select Ubuntu or the Linux distro you want to move to another drive.

Then, click the menu option (three dots) and select Move on the drop-down menu.

Select the new drive you wish to move to and click “Move.”

After a brief moment, the distro will be relocated to the new drive you selected above.

Change the WSL drive using the Move command

Another way to move a distro to another drive is to use the ‘Move’ command using Windows Terminal as administrator.

First, launch the Windows Terminal app as administrator.

Then, use the command below to list all the distros on the machine.

wsl --list --all

Next, shut down WSL by running the command below.

wsl --shutdown

Then, move the distro to a new drive by running the command below.

wsl --manage Ubuntu --move D:\WSL\Ubuntu

After a brief moment, the distro will be relocated to the new drive specified in the command.

Use the Import command to change the WSL distro drive

Another way to change the WSL distro drive is to export and import the distro to a new location.

First, the post below shows you how to export and import WSL distros.

After reading the post above, you can use the command below to import the distro to a new drive.

wsl --import Ubuntu D:\WSL\Ubuntu C:\Ubuntu-export.tar

The D:\ drive is the location, and the C:\ drive is the exported tar file.

After a brief moment, the distro will be imported to the location specified above.

That should do it!

Conclusion:

Transferring Ubuntu WSL to another drive on Windows 11 is a straightforward process that can enhance performance or free up space on your main drive. Here are the key takeaways:

  • Multiple Methods: You can move your WSL distribution using the graphical interface in Settings or via the command line with the --move command.
  • Shut Down WSL: Always shut down your WSL instance before making any moves to avoid data corruption.
  • Use Windows Terminal: For advanced users, executing commands in the Windows Terminal is efficient and provides more control over the process.
  • Export and Import: For a more manual approach, utilize the export and import commands to relocate your distribution as needed.
  • Efficiency: Moving your WSL installation can optimize performance, especially if transitioning to faster storage solutions.

Following these guidelines allows you to manage your WSL installations and organize your development environment easily.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *