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

Recent Posts