
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