How to Install Ubuntu WSL in a Custom Location (Windows Subsystem for Linux)

How to Install Ubuntu WSL in a Custom Location (Windows Subsystem for Linux)

πŸ“¦ How to Install Ubuntu WSL in a Custom Location (Windows Subsystem for Linux)

Want to install Ubuntu WSL on a different drive or folder instead of the default location? You're not alone. Whether you're optimizing space on your C: drive or just love organizing your setupβ€”this tutorial will walk you through installing Ubuntu WSL in a custom location with full control. πŸš€

❓ Why Install WSL in a Different Location?

By default, WSL stores Linux distributions under %LOCALAPPDATA%\Packages, usually on the C: drive. This can fill up fast. Installing Ubuntu in a custom folder like D:\WSL\Ubuntu can free space and make your setup easier to manage or backup.

πŸ”§ Prerequisites

  • βœ… Windows 10 or 11 with WSL2 enabled
  • βœ… Admin privileges
  • βœ… At least one other partition/drive (like D: or E:)
  • βœ… Internet access to download Ubuntu rootfs

πŸ“₯ Step 1: Download Ubuntu RootFS

1. Head to the official Ubuntu WSL page

2. Pick your preferred version (e.g., Ubuntu 22.04 LTS) and download the rootfs.tar.gz archive

πŸ“ Step 2: Create Your Custom Install Directory

Example command in PowerShell or CMD:

mkdir D:\WSL\Ubuntu

πŸ§™β€β™‚οΈ Step 3: Install Ubuntu Manually

Use the built-in wsl.exe tool to import Ubuntu into the custom location:

wsl --import UbuntuCustom D:\WSL\Ubuntu C:\Users\YourName\Downloads\ubuntu-rootfs.tar.gz

This installs the Linux filesystem to D:\WSL\Ubuntu with the name UbuntuCustom.

πŸš€ Step 4: Launch Your Custom Ubuntu

Now launch your new Ubuntu install with:

wsl -d UbuntuCustom

It will drop you into the shell for the first time. Set your username and password as prompted.

πŸ›  Step 5: Optional Config Tweaks

  • Add aliases or PATH updates to your ~/.bashrc
  • Set UbuntuCustom as default: wsl --set-default UbuntuCustom
  • Enable systemd support if needed (Ubuntu 22.04+ supports it)

πŸ“Œ Bonus Tips

  • 🧹 Clean up by deleting the original rootfs.tar.gz after import
  • πŸ”’ Keep a backup of your D:\WSL\Ubuntu folder for disaster recovery
  • πŸ“ You can import multiple distributions with different names

πŸŽ‰ Conclusion

Now you've got Ubuntu running under WSL exactly where you want it. Custom locations give you the flexibility to organize, manage disk space, and even take backups easily. Whether you're a developer, power user, or Linux learnerβ€”this method gives you the control that the default WSL install lacks. Happy coding! πŸ§πŸ’‘

Have questions or a cool WSL tip? Share it in the comments! πŸ‘‡

Comments (0)

No comments yet. Be the first to comment!

Leave a Comment