Clear Linux for WSL (2)

Hi everybody!
I have read some topics of this forum (1, 2) about installation of OS in the WSL version 2.
I am interesting in the process to generate a WSL image (*.tar.gz) taking as a base the server/desktop Clear Linux distro. I do not have much knowledge about Linux image formats and file systems :cry:
Donā€™t know if it is possible starting with iso image of OS, extract the file system, and generate the WSL file

Thanks in advance! :slight_smile:

@nunixtech @Rucadi
Is there any advice you can share on this?

thank you @puneetse for the reference, I saw it and wanted to answer after WSLConf :slight_smile:

Please start here: [Tutorial] Clearlinux on WSL2

I will have to update it for showing how you can do the same from the Docker image.
If you have docker installed, here is a the commands (in a nutshell):

  1. docker run -it --name wslclear clearlinux
  2. [inside the container]
    2.1 swupd update
    2.2 useradd -m -s /bin/bash USERNAME # replace USERNAME by your own
    2.3 vi /etc/wsl.conf # edit it to add your user to be the default
    Windows Terminal

[automount]
enabled = true
options = ā€œmetadata,uid=1000,gid=1000,umask=22,fmask=11,case=offā€
mountFsTab = true
crossDistro = true

[network]
generateHosts = false
generateResolvConf = true

[interop]
enabled = true
appendWindowsPath = true

[user]
default = USERNAME
2.4 swupd install sudo
2.5 usermod -aG wheelnopw
2.6 exit

  1. docker export -o wslcleartemp.tar wslclear
  2. mkdir wslcleartemp
  3. sudo tar -xf wslcleartemp.tar --same-owner -C wslcleartemp
  4. cd wslcleartemp
  5. sudo tar -cf ā€¦/wslclear.tar --same-owner --hard-dereference *
  6. cd ā€¦
  7. mkdir /mnt/c/wsldistros
  8. mv wslclear.tar /mnt/c/wsldistros/
  9. [start Powershell]
  10. wsl.exe --import wslclear c:\wsldistros\wslclear c:\wsldistros\wslclear.tar

The issue (currently) is that WSL does not handle the hard links in the TAR files, so we need to extract and re-tar the content with the ā€œā€“harde-dereferenceā€

Hope this helps, and I will monitor this thread in case you have further questions or encounter any issues (hopefully not eheh)

Seems ok!

I made a tool that allowed to install docker images as wsl directly, itā€™s been unmaintained for a while.

I want to support it again adding the wsl.conf now that I can interact better with the subsystem.

I will pick some things from you if you donā€™t mind :slight_smile:

1 Like

haha at all, itā€™s all free knowledge and it will be my pleasure if you take some parts :+1:

looking forward to your solution, let me know when you updated it, Iā€™ll test it and tweet about it :slight_smile:

Hi!

Today I updated the program I was talking about, the changes done now are quite rushed, I plan to rewrite the tool a little.

However, right now, It allow to install ClearLinux images with a simple command:

.\wsld.exe -i clearlinux -d clearlinuxwsl

The documentation is on the github repo. Releases prior to the latest will fail to install clearlinux.

It has a lot of functionality, like being able to login to your docker account, upload wsl images into dockerhubā€¦ and basically, download any dockerhub image as an wsl one :slight_smile:

perfect, I will have a look tomorrow or this week-end. Great work, and I will PR some bits from my own discoveries (create user, chpasswd and sudoers)

However not all distros use the same tools, so it might not help for all, maybe keeping it ā€œoriginalā€ might be best.

Anyway, great job once again :slight_smile:

Thanks :slight_smile: I recently made a new Windows installation and found that if wsl default version is not set to 2 the first time you use the program, Itā€™ll fail to install any image (This is because the helper machine will install as WSL1 and it doesnā€™t support docker), in my next release Iā€™ll fix that.

(If it happened to you, just convert it to WSL2 or unregister it, set default to 2 and rerun the program)

Thank you very much for your help!! :grinning:
I will try to do it. I want to implement this solution in WSL2, but I will wait for including ā€œnativeā€ this version in a Windows stable release.