[Tutorial] Clearlinux on WSL2

swupd bundle-add clearlinux-on-wsl2

Introduction

This tutorial describes how to install, configure, and start Clear Linux on Windows WSL2.

Description

Welcome to this first tutorial talking about Clear Linux on WSL2.

This tutorial will describe how to install Clear Linux on WSL2 from the (Windows) console and few configuration tips that will make the Linux feeling even more authentic.

So if you want to test it out just for curiosity, or because you simply love Clear Linux and need to run Windows for work or specific tasks, then this tutorial is definitively for you.

NOTE: WSL2 is only available in the Windows 10 Insider Fast ring (read: beta).
This means that, while is quite stable, it is not suited, yet, for production environments.

Prerequisites

In order to have the best experience while reading this tutorial, the following prerequisites need to be checked:

Configuration: Windows side

Now that all prerequisites are gathered, it’s time to start the configuration.

In order to keep everything ordered, the first task will be to create a directory “structure”. This will help when very specific configurations need to be done (read: custom kernel):

  • Start a new Powershell session. TIP: press the keyboard keys WINDOWS+R to show the run popup and type powershell
    ps-windows-run
  • Create the top directory: PS> mkdir /mywsldistros
  • Create one sub-directory to store the inital rootfs: PS> mkdir /mywsldistros/sources
  • Copy (or move) the rootfs to the sources directory: PS> cp -v $HOME/Downloads/Clear_Linux_Server_WSL_rootfs_clean.tar.gz /mywsldistros/sources/
  • Register Clear Linux as a new WSL2 distro: wsl.exe --import clearlinux /mywsldistros/clearlinux /mywsldistros/sources/Clear_Linux_Server_WSL_rootfs_clean.tar.gz --version 2

    TIP: if the --version flag is omitted, the distro can be migrated using wsl.exe --set-version clearlinux 2

  • Ensure the distro has been imported correctly
    wsl-list-distro
  • Finally, login to the newly created distro
    wsl-login-distro

Configuration: Linux side

Once running Clear Linux on WSL, the only (current) limitation is, there’s no virtualization capabilities (read: no KVM or other hypervisor based technologies).

With that said, here is the 4 main tasks that should be performed after the first login:

  1. Update the system: swupd update
    wsl-update-distro
  2. Create a new user and assign a password:
    useradd -m -s /bin/bash clearuser
    passwd clearuser
    
    wsl-create-user
  3. Add basic bundles: swupd bundle-add sysadmin-basic sudo
    • The sudoers config has 2 predifined groups, add the user created to one of them as follow:
    # Requires password when using sudo <command>
    usermod -aG wheel clearuser
    # Does NOT require password when using sudo <command>
    usermod -aG wheelnopw clearuser
    
  4. Create the wsl.conf config file for optimal Interopability
    vi /etc/wsl.conf
    [automount]
    enabled = true
    options = "metadata,uid=1000,gid=1000,umask=22,fmask=11,case=off"
    mountFsTab = true
    crossDistro = true
    
    [network]
    generateHosts = true
    generateResolvConf = true
    
    [interop]
    enabled = true
    appendWindowsPath = true
    
    [user]
    default = clearuser
    

At this point, the initial configuration is finalised. Close the session, shutdown the WSL VM and start a new Clear Linux session:

exit
PS> wsl.exe --shutdown
PS> wsl.exe -d clearlinux
sudo swupd update

NOTE: the full settings are explained here: Automatically Configuring WSL - Windows Command Line

Conclusion

Congratulations, a new Clear Linux WSL distro is now up and running.

As seen during the system update or when adding new packages, there’s some errors. Do not sweat, these are not blocking the system.

Now you can enjoy all the incredible blog posts out there on how to use to the best WSL while running the distro we like the most, Clear Linux.

>>> Nunix out <<<

17 Likes

It took me 3 hours and 3 separate executions of swupd to fully update the OS, and I always get a warning from curl:
Warning: Curl - Unable to create a thread pool - downloading files synchronously

Is that just me or what?

Thanks for providing the tar, your gitlab link was the only place i could find it, docker won’t run window11 home. I’m usually not on windows, but Arch. But I wanted a different linux experience for a try. After three years I surprised the tar worked as well as it did, it’s been iteratively updating (probably catching up on three years one cycle at a time), we’ll see if it breaks :slight_smile:

Welcome back @Air_Dedman :wink:

For data analysis?

1 Like

Ya, Arch runs MSsql Server, and Anaconda really well when I need it for group projects. Honestly Arch really makes life easy for the end-user as far as getting apps set up quickly without having to jump through hoops. But it’s not my work computer anyway, it’s my personal laptop, and can’t beat the ease of Arch as far as personal computing goes. As long as I’m not doing anything too funky with the AUR, it’s a very stable system.

But I’m testing Clear through a WSL instance, just to see if it performs well in that environment. So far openSUSE has been a lot more performant. I like Clear on an older Thinkpad, but my kid took it over for his schooling needs.

Just in WSL or in general ?

1 Like

Just on WSL. Oh my good not otherwise.

Clear Linux is king of speed.

1 Like

Thing I appreciate so far, most the apps I need for WSL are gonna be a cargo or pip package away, if it’s not on swupd official repo.

Bringing anything close to my Linux setup over to Windows is nice. I blew WSL off after trying version 1, but it’s definitely a lot more nicely integrated these days.

And I was only hoping that clearlinux was available for it, so three years later this tutorial is relevant.

2 Likes

Have you tried Mamba in WSL to speed up conda ?

1 Like

Thx for your tutorial and explanations!
Wrote some automation for it: GitHub repo
Latest versions provided weekly.
Will appreciate if you visit, look through, test it yourself, esp. if you star or pin this message somehow :slight_smile:

2 Likes