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:
- Windows 10 Insider Fast 18917 or newer
- Windows Subsystem for Linux (WSL) installed
- [Optional] One Windows Store distro installed
- Clear Linux rootfs - This tutorial will use the
server rootfs
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 typepowershell
- 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 usingwsl.exe --set-version clearlinux 2
- Ensure the distro has been imported correctly
- Finally, login to the newly created 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:
- Update the system:
swupd update
- Create a new user and assign a password:
useradd -m -s /bin/bash clearuser passwd clearuser
- 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
- The
- Create the
wsl.conf
config file for optimal Interopabilityvi /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 <<<