How To Protect Your WSL Distro More Firmly

Jung-Hyun Nam
Mar 29 · 3 min read
Image for post
Image for post
Photo by Sarah Kilian on Unsplash

Beginning Windows 10 Anniversary Update, Windows beloved by hackers and developers again with the Windows Subsystem for Linux. Windows has a great open source experience more than ever. Plus, beginning the release of the Windows 10 2004 release, WSL 2 takes flight to everyone’s place with the real Linux kernel, not the emulated one.

I understand that Microsoft wants to deliver their WSL experiences into a delightful manner through the Microsoft Store. However, this way seems quite dangerous. Why dangerous? Because the store app does not sustain the local data. Even in Windows 10, it is just like the iOS or Android environment. You can accidentally remove or initialize your Ubuntu distro at any time.

So, I suggest you install your WSL distro manually, instead of downloading it through the Microsoft Store.

But how can you do that? It’s simple — install your WSL distro manually.

Install Your WSL Distro Manually

I will elaborate on the manual steps of the WSL installation.

First, find your favorite WSL distros on the Microsoft docs page. Microsoft provides official WSL distros docs page, not only the Microsoft Store. The reason is this page intended for server-side WSL installation. But you can use the manual installation step for your Windows 10 environment too.

I will choose Ubuntu 18.04 for this guide.

Then, Open your PowerShell as an administrative mode with your favorite terminal and run the PowerShell scripts.

# Change your directory into the Download folder.
Set-Location -Path $env:USERPROFILE\Downloads
# Set this variable as your distro download URL.
$TargetUri = "https://aka.ms/wsl-ubuntu-1804"
# Download the file. If the BITS transfer not working, use the curl.exe or Invoke-WebRequest instead. Also, PowerShell cannot extract the archive if the file has .appx package format.
Start-BitsTransfer -Source $TargetUri -Destination .\ubuntu.zip
# I'm using the directory path as 'C:\Distro', but you can change your directory path as your intention.
New-Item -Type Container -Path C:\Distro\Ubuntu
# Extract the archive file.
Expand-Archive -Path .\ubuntu.zip -DestinationPath C:\Distro\Ubuntu
# Remove the downloaded archive file.
Remove-Item -Path .\ubuntu.zip
# Change the directory
Set-Location -Path $env:SYSTEMDRIVE\Distro\Ubuntu
# Run the distro and initial setup process will begin.
.\ubuntu1804.exe

If you want to use the WSL version 2 (and ensure that you have installed the latest version of Windows Insider Preview or Windows 10 2004 release), please set your default WSL version as ‘2’ before running distro.

wsl --set-default-version 2

That’s it! After installation completed, you can find your WSL distro installed firmly into your system. You can use your WSL distro independently from the Store. 😊

WSL Distro Manager

With this approach, you can set up and manage multiple distros on your computer. If you want to manage your distros in graphical interfaces, you can consider using my open-source solution, the WSL Distro Manager.

https://github.com/wslhub/WSL-DistroManager

Image for post
Image for post

This project still under active development. All contributions welcomed. :-)

Revisions

I learned some lessons from your feedback. Thank you.

  • I removed the example case because it does not make sense.
  • I changed the title of this article to prevent misunderstanding.
Image for post
Image for post

Beyond the Windows

DevOps Engineer’s Blog

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store