Manually installing Ubuntu 24.04.x on WSL on Windows 11 without using the Microsoft Store

#Installing Ubuntu 24.04.x on WSL on Windows 11

#These two items are the minimum install:

#If you want bridged networking then you also have to install Hyper-V so you can create a bridged virtual switch.

#Reboot


Update WSL:

#Other wsl.exe options include:

#Installing WSL with a Custom Tarball

When the Microsoft Store is disabled, you can manually install WSL by downloading a custom tarball. In my case, I have downloaded ubuntu-noble-wsl-amd64-wsl.rootfs.tar.gz from the Ubuntu Cloud WSL Image page. This tarball contains the root filesystem for Ubuntu, which you can use to manually set up WSL without needing the Store.

#Download the WSL image you need from the link below:

https://cloud-images.ubuntu.com/wsl  #Look for Noble folders

#Then run the command below from and elevated command prompt:

A few things to note:

      • To use WSL without the Microsoft Store, for me, Developer Mode needed to be enabled on my Windows system. This had to be done through Microsoft Intune by duplicating and assigning a policy that allows Developer Mode. Please be sure that installing WSL is approved by your IT department before installing if you are on a computer that you use for work purposes.
      • You will initially be logged in as root and this is not meant to be your primary user, at all. Many things only run as root and many more will not run as root. You do not want to leave this, as is, even in a non-production environment.

#This is the version that is current for me now but there are updates so keep reading.


#Set WSL distribution’s virtual disk is set to be sparse:

#This will allow the virtual disk to automatically shrink when files are removed from the distribution

#Another way to manually set a WSL installation to sparse

#Add sparseVhd=true to the [wsl2] section of your .wslconfig file. The .wslconfig file doesn’t already exist most likely. It is located in windows in your home directory usually located at c:\users\username\.wslconfig

#It is not common for a windows file name to begin with a . but that is not a typo. . is the identifier for hidden files in Linux.

#Now manually imported  Linux distributions do not automatically read .wslconfig files so you also need to download wsldl.exe and set that up to launch with as described later on in this post.


#To use the wsldl.exe launcher with your imported WSL distribution and enable it to utilize the .wslconfig file, follow these steps:

#Steps to Configure wsldl.exe

  1. Download wsldl.exe: Ensure you have the latest version of wsldl.exe from the official wsldl repository .
  2. Prepare Your Directory:
    • Create a folder where you want to store your distribution.
    • Place the downloaded wsldl.exe in this folder and rename it to the desired name for your distribution (e.g., MyDistro.exe) .
  3. Add Your Root Filesystem:
    • Place your exported root filesystem tar file (e.g., rootfs.tar.gz) in the same directory as wsldl.exe. Ensure that the tar file is named correctly as rootfs.tar.gz .
  4. Run the Launcher:
    • Right-click on the renamed wsldl.exe (e.g., MyDistro.exe) and select “Run as administrator.” This step is crucial for proper registration and functionality .
  5. Configure .wslconfig:
    • Create or edit a .wslconfig file in your Windows user directory (usually located at C:\Users\<YourUsername>\.wslconfig). This file allows you to set various WSL configurations, such as memory limits and processor settings.
    • Example content for .wslconfig:
      text
      [wsl2]
      memory=4GB
      processors=2
  6. Launch Your Distribution:
    • After running the launcher, you can access your distribution via the command line using its name (e.g., MyDistro). This will allow it to recognize and utilize settings specified in .wslconfig .

#Your imported WSL distribution should now work with the wsldl.exe launcher and respect the configurations set in your.wslconfig file.


#Change the default user for a distribution using wsldl.exe

#Change the default user username for your distribution log-in. The user has to already exist inside the distribution in order to become the default user.

#For example: Ubuntu config --default-user johndoe would change the default user for the WSL instance called “Ubuntu” to the “johndoe” user.

#Note:

#If you are having trouble figuring out the name of your distribution, use the command wsl -l.

#Warning:

#This command will not work for imported distributions, because these distributions do not have an executable launcher. You can instead change the default user for imported distributions using the /etc/wsl.conf file. See the Automount options in the Advanced Settings Configuration doc.


#Update and configure Ubuntu 24.04.x LTS on Windows 11 WSL

#Run update for the first time to initialize apt

#Install the necessary packages that allow apt to use packages over HTTPS:


#Suppressing Pro updates in Ubuntu 24.04.x LTS
 
#Next, also comment out ALL the lines by using arrow keys to navigate, and adding # for each line. When done, press Ctrl+S to save and Ctrl+X to exit.

#Add a new primary user

#Enter a new password and provide any user information you wish to then add the new user to sudousers.

#Edit the /etc/wsl.conf file:
#Open the /etc/wsl.conf file in a text editor. You might need to create this file if it doesn’t exist:

#Add the Configuration for the Default User:
#Add the following lines to the file to set the default user:


#Enable bridged networking instead of NAT

#Create a new bridged virtual switch called WSL

#List configured virtual switches

#Nexts steps to enable bridged networking and to disable IPv6 in WSL2

#Edit the .wslconfig File:

#Create or edit the .wslconfig file located in your user directory (typically C:\Users\<YourUsername>\.wslconfig).

#These settings tell WSL2 to disable IPv6 at the kernel level and to use the virtual switch called WSL.  If you want IPv6 spport then simply omit that line from your .wslconfig

#Add the following lines to the file:

#After saving the changes, you need to shut down WSL for the changes to take effect. You can do this by running the following command in PowerShell or Command Prompt:


#Enable syncookies, disable responses for pings to the broadcast, enable ip spoof protection, disable ICMP redirects and disable source routing. You can do so by adding the following lines to /etc/sysctl.conf

#If you are using NAT rather than bridged networking

#You do not need to do this if you are using bridged mode and DHCP is automatically obtained from your primary DHCP server.

    • WSL NAT mode gives your Linux environment a private IP and makes all traffic appear to come from your host’s IP. This hides your WSL instance from direct access from the Internet, providing a layer of protection.

    • WSL bridged mode lets your Linux environment get its own IP on the network, like a separate computer. This means your WSL session is directly reachable from the Internet or other devices on the network, so it’s more important to secure it properly.

#This means NAT hides WSL behind your host’s IP, while bridged mode makes WSL act like its own device on the network.

#Set permanent DNS to an external DNS provider for NAT

#To prevent the /etc/resolv.conf file from being automatically generated and overwritten by WSL via /etc/wsl.conf

#Add:

#The /etc/resolv.conf file is often a symlink to another file that gets automatically generated. To prevent it from being overwritten, you should remove the symlink and create a regular file:

#List contents of /etc/resolv.conf

#Default Settings in an automatically created resolv.conf

#Get DNS Status

#Remove the existing symlink:

#Create a new /etc/resolv.conf file:

#Edit the new file to add your preferred DNS servers. For example:

#Add additional DNS servers (note tee -a (for append))


#Install and configure zsh shell

#Install zsh (git is needed for the theme I use)

#Configure zsh as your default shell. 

#Run zsh

#Press 2 to create a default config file if prompted


#Configure zsh for root user. You do not need to do this step if you don’t use sudo -i like I do. Operating like that is not recommended but often I am in a non-production environment when I do so exit. This will not work if you were not prompted to create a default .zshrc file. You can run this later if you need to after installing oh.my.zsh.


#Install oh.my.zsh

#I use the Powerlevel10k theme. You can download it from here. This is a per use install and should be installed on a non-root user 1st then sudo -i if you want that too.

#Edit .zshrc configuration file

#Change to:

#Source ~/.zshrc to change to powerlevel10k ohmyzsh theme.

#Answer questions about your screen for customized terminal font support

#Output:


#Create Mount Points in WSL

#Create directories in WSL where you want to mount the CD-ROM drives:

#Check This PC in Windows 11 if you are unsure which drive letter your optical drives uses.

#If your CD/DVD is at D:\ in Windows

#If your CD/DVD is at E:\ in Windows

#Mount the CD-ROM Drives Using drvfs

#If your CD/DVD is at D:\ in Windows

#If your CD/DVD is at E:\ in Windows

 

#Part 2 is on it’s way. (Next Steps to configuring Ubuntu 24.04.x LTS in Windows 11 WSL)