You can install two Windows Subsystem for Linux (WSL) instances by using the
wsl --import command to create a new virtual hard disk on a non-C drive. This method allows you to store your Ubuntu 20.04 or 22.04 distribution files on a separate partition, such as D: or E:, effectively separating system resources from user data. By specifying a custom path during the import process, you ensure that the second instance runs independently of the default C: drive installation while maintaining full functionality and access to both distributions simultaneously.
Prerequisites for Dual WSL Setup
Before creating a second instance, you must ensure that WSL is properly enabled on your Windows machine. Open PowerShell or Command Prompt as an administrator and run
wsl --set-default-version 2. This command ensures that all new installations use the modern WSL2 architecture, which provides better performance and full system call compatibility compared to WSL1. Additionally, verify that your target drive has sufficient free space, as each Linux distribution requires several gigabytes for the root file system and additional storage for packages and user files.
It is also advisable to check if you already have a default distribution installed. You can list existing instances by running
wsl -l -v. If you see an active Ubuntu version, you can proceed with adding a second one without removing the first. This setup is particularly useful for developers who need isolated environments for different projects or testing scenarios. For more information on managing existing installations, you might find our guide on
transferring WSL Ubuntu installation to USB helpful for understanding how WSL handles file paths and external storage.
Preparing the Destination Drive
The core of this solution involves preparing a location on a non-C drive to host the new virtual hard disk. Navigate to your desired directory, such as
D:\WSL\Ubuntu22, using File Explorer or the command line. Create a subdirectory for the specific distribution you intend to install. This structure keeps your WSL instances organized and makes it easier to manage backups or move them in the future.
Next, you need a tarball of the Linux distribution. You can download the latest Ubuntu 22.04 or 20.04 tar.gz file from the official Canonical archives or use the Microsoft Store app to export an existing installation. If you choose to export an existing instance, you can do so by running
wsl --export Ubuntu D:\Backup\Ubuntu.tar.gz. This creates a portable archive that can be imported into a new location. Ensure that the tarball is accessible via a short, simple path to avoid issues with long file name limits in Windows.
Importing the Second Instance
With the destination folder ready and the tarball available, you can now import the new WSL instance. Use the following command structure in an elevated PowerShell window:
wsl --import Ubuntu22 D:\WSL\Ubuntu22 D:\Backup\Ubuntu.tar.gz
Replace
Ubuntu22 with the name you want for the new instance,
D:\WSL\Ubuntu22 with the path to the empty folder you created earlier, and
D:\Backup\Ubuntu.tar.gz with the path to your tarball. The
--import flag tells WSL to create a new virtual hard disk at the specified location and extract the contents of the tarball into it. This process may take several minutes depending on the size of the archive and the speed of your storage drive.
Once the import completes, you will have a fully functional Ubuntu instance residing on your non-C drive. You can start it by running
wsl -d Ubuntu22. This command launches the new distribution, allowing you to install packages, configure services, and develop applications just as you would with the default instance. The key advantage here is that the heavy I/O operations are directed to the secondary drive, reducing load on your primary system drive.
Configuring User Permissions
By default, the imported instance may start with the root user. To improve security and usability, you should set up a default non-root user. Inside the new WSL session, you can add a new user with
adduser username and then switch to that user. Alternatively, you can modify the
.wslconfig file in your Windows user profile to set specific configurations for the new instance.
If you encounter permission issues when accessing files from Windows, remember that WSL2 uses a network filesystem to mount the Windows drives. Accessing
/mnt/c/ from within WSL is generally slower than accessing native Linux files. Therefore, keeping your project files within the WSL file system (e.g.,
/home/username/projects) is recommended for optimal performance. This practice applies to both your C: drive instance and your new non-C drive instance.
Managing Multiple Instances
Running multiple WSL instances concurrently can consume significant RAM and CPU resources. Monitor your system's resource usage using the Windows Task Manager or the
wsl --list --verbose command to see the current state of each distribution. You can shut down all WSL instances efficiently by running
wsl --shutdown from PowerShell. This ensures that background processes do not drain battery life on laptops or leave resources occupied unnecessarily.
For advanced configuration, you can edit the
wsl.conf file inside each instance to set hostname, networking, and mount options. Each instance maintains its own separate environment, meaning package installations in one do not affect the other. This isolation is beneficial for testing different library versions or operating system updates without risking your primary development environment.
Frequently Asked Questions
Can I run both WSL instances at the same time?
Yes, you can run multiple WSL distributions simultaneously. Each instance operates as a separate lightweight VM, allowing you to open terminals for both Ubuntu 20.04 and 22.04 in parallel. Just be aware that running both concurrently will increase RAM usage significantly.
How do I delete a WSL instance stored on a non-C drive?
To remove the instance, first shut it down using
wsl --terminate InstanceName. Then, simply delete the folder where the virtual hard disk was stored (e.g.,
D:\WSL\Ubuntu22). You can also use
wsl --unregister InstanceName to clean up the registration entry in WSL.
Is there a performance penalty for storing WSL on a secondary drive?
No, there is no inherent performance penalty. In fact, storing large datasets on a faster SSD secondary drive can improve overall system responsiveness by freeing up I/O bandwidth on your main boot drive. The performance depends entirely on the speed of the physical storage device used.
Can I transfer my existing C: drive WSL to another drive later?
Yes, you can export your existing installation and re-import it to a new location. Use
wsl --export to create a backup tarball, then use
wsl --import to place it on the new drive. Remember to unregister the old instance after confirming the new one works correctly.
Does this method work for distributions other than Ubuntu?
Absolutely. The
wsl --import command supports any valid tarball containing a Linux root file system. You can import Debian, Kali, Alpine, or custom-built distributions into any directory on any mounted drive, provided they are compatible with WSL2.