If you’re a Windows user exploring Linux through Windows Subsystem for Linux (WSL), you’ve likely noticed how quickly your C: drive can fill up. By default, WSL installs distributions like Ubuntu under %LOCALAPPDATA%\Packages\…
, which isn’t ideal—especially if you’re managing multiple distros, working with large files, or have limited space on your system drive.
To avoid clutter and gain better control over your system’s storage, it’s smart to install Ubuntu 24.04 (or any other distro) in a custom directory, such as a dedicated folder on your D: or E: drive. This tech concept, not only helps with storage optimization but also simplifies backup and versioning. Below are two reliable methods to set up WSL with a custom installation path.
I’ve spent 20+ years empowering businesses, especially startups, to achieve extraordinary results through strategic technology adoption and transformative leadership. My experience, from writing millions of lines of code to leading major initiatives, is dedicated to helping them realize their full potential.
Method 1: Install via Store and Then Move
1.1 Install Ubuntu 24.04 from Microsoft Store
wsl --install -d Ubuntu-24.04
This downloads and installs the distribution in the default location.
1.2 Shut Down WSL
wsl --shutdown
Ensure no distributions are running.
1.3 Move the Distribution
wsl --manage Ubuntu-24.04 --move D:\WSL\Ubuntu24
This moves the entire .vhdx
filesystem to your specified folder.(Super User, lpcodes.github.io)
1.4 Launch Ubuntu
wsl -d Ubuntu-24.04
You’re now running Ubuntu from your custom directory.
Method 2: Import Directly Into a Custom Folder
2.1 Download Ubuntu 24.04 Rootfs
Get the .tar
or .wsl
image from Canonical’s official site.
2.2 Create Your Target Folder
mkdir D:\WSL\Ubuntu24
2.3 Import the Distribution
wsl --import UbuntuCustom D:\WSL\Ubuntu24 C:\path\to\ubuntu-24.04-rootfs.tar --version 2
This installs Ubuntu under the chosen folder with the name UbuntuCustom
.(lpcodes.github.io, LoopGuy)
2.4 Launch and Configure
wsl -d UbuntuCustom
Set your default user via:
distribution.exe config --default-user <username>
or edit /etc/wsl.conf
.
Additional Tips
- List installed distributions and check versions:
wsl --list --verbose
- Set a default distribution:
wsl --set-default Ubuntu-24.04
- To enable
systemd
, Ubuntu 24.04 includes it by default. You can further customize it via/etc/wsl.conf
(Microsoft Learn, Ubuntu Documentation). - If you prefer not to move after installation, the import approach skips the store entirely.
- A manual export/import workflow also works:
wsl --export Ubuntu-24.04 D:\ubuntu24.tar
wsl --unregister Ubuntu-24.04
wsl --import Ubuntu-24.04 D:\WSL\Ubuntu24 D:\ubuntu24.tar --version 2
My Tech Advice: Installing Ubuntu or Linux flavour into a custom folder not only frees up your system drive but also enhances flexibility for backups, organisation, and performance management. Whether you import directly or move a store-installed distro, each approach delivers a clean, controlled WSL environment.
Ready to build your own tech solution ? Try the above tech concept, or contact me for a tech advice!
#AskDushyant
Note: The names and information mentioned are based on my personal experience; however, they do not represent any formal statement.
#TechConcept #TechAdvice #Windows #WSL #Linux #Ubuntu
Leave a Reply