Add a WSL definition and config snippets

This introduces the beginnings of an image definition for Windows
Subsystem for Linux (WSL).

The package list is based on the core and standard grouplists. Some
packages, like the kernel, dracut, and so on, are omitted as they are
unnecessary. Others, like audit, don't work in the environment. Finally,
many packages are omitted since I thought "people probably won't want
that", so the package list is completely up for debate. This is just a
reasonable starting point that works.

Build/test instructions:

To build the tarball:

  $ ./kiwi-build --image-profile=WSL-Base --image-type=tbz --output-dir=./build/

Get it to a Windows host with WSL installed. To boot it with cgroupsv2,
add the following to `.wslconfig` in the Windows host home folder:

[wsl2]
kernelCommandLine=systemd.unified_cgroup_hierarchhy=1 cgroup_no_v1=all

This assumes the latest WSL release is installed, at least version 2.4.4:

  $ wsl --install --from-file .\path\to\the\fedora.tar.xz

Alternatively, if you're using something prior to version 2.4.4:

  $ wsl --import --version=2 Fedora C:\path\to\storage\Fedora\ .\path\to\the\fedora.tar.xz

Finally, run it with:

  $ wsl -d Fedora

If you are using 2.4.4+, you will be prompted for a username and then
dropped into an interactive shell with that user and passwordless sudo
access.

If you're using an older version, you need to do:

  $ wsl -d Fedora -u root
  # /usr/libexec/wsl/oobe.sh

Signed-off-by: Jeremy Cline <jeremycline@linux.microsoft.com>
This commit is contained in:
Jeremy Cline
2025-01-31 10:52:54 -05:00
committed by Jeremy Cline
parent 90f4f3a820
commit 4b4a83b33f
4 changed files with 80 additions and 2 deletions
+1
View File
@@ -38,6 +38,7 @@
<include from="this://./teams/cloud/cloud.xml"/> <include from="this://./teams/cloud/cloud.xml"/>
<include from="this://./teams/cloud/container.xml"/> <include from="this://./teams/cloud/container.xml"/>
<include from="this://./teams/cloud/vagrant.xml"/> <include from="this://./teams/cloud/vagrant.xml"/>
<include from="this://./teams/cloud/wsl.xml"/>
<include from="this://./teams/server.xml"/> <include from="this://./teams/server.xml"/>
<include from="this://./teams/workstation.xml"/> <include from="this://./teams/workstation.xml"/>
<include from="this://./teams/kde.xml"/> <include from="this://./teams/kde.xml"/>
+2 -2
View File
@@ -33,7 +33,7 @@ rm -f /var/lib/systemd/random-seed
#====================================== #======================================
# Configure grub correctly # Configure grub correctly
#-------------------------------------- #--------------------------------------
if [[ "$kiwi_profiles" != *"Container"* ]] && [[ "$kiwi_profiles" != *"FEX"* ]]; then if [[ "$kiwi_profiles" != *"Container"* ]] && [[ "$kiwi_profiles" != *"FEX"* ]] && [[ "$kiwi_profiles" != *"WSL"* ]]; then
## Works around issues with grub-bls ## Works around issues with grub-bls
## See: https://github.com/OSInside/kiwi/issues/2198 ## See: https://github.com/OSInside/kiwi/issues/2198
echo "GRUB_DEFAULT=saved" >> /etc/default/grub echo "GRUB_DEFAULT=saved" >> /etc/default/grub
@@ -58,7 +58,7 @@ fi
#====================================== #======================================
# Delete & lock the root user password # Delete & lock the root user password
#-------------------------------------- #--------------------------------------
if [[ "$kiwi_profiles" == *"Cloud"* ]] || [[ "$kiwi_profiles" == *"Disk"* ]] || [[ "$kiwi_profiles" == *"Live"* ]]; then if [[ "$kiwi_profiles" == *"Cloud"* ]] || [[ "$kiwi_profiles" == *"Disk"* ]] || [[ "$kiwi_profiles" == *"Live"* ]] || [[ "$kiwi_profiles" == *"WSL"* ]]; then
passwd -d root passwd -d root
passwd -l root passwd -l root
fi fi
+68
View File
@@ -0,0 +1,68 @@
<image>
<profiles>
<profile name="WSL-Base" description="Windows Subsystem for Linux Base"/>
</profiles>
<preferences profiles="WSL-Base">
<type image="tbz"/>
<timezone>Etc/UTC</timezone>
<locale>en_US</locale>
<rpm-locale-filtering>false</rpm-locale-filtering>
<rpm-excludedocs>false</rpm-excludedocs>
</preferences>
<packages type="bootstrap" profiles="WSL-Base">
<package name="bash"/>
<package name="coreutils"/>
<package name="dnf5"/>
<package name="dnf5-plugins"/>
<package name="fedora-release-wsl"/>
<package name="policycoreutils"/>
<package name="rpm"/>
<package name="selinux-policy-targeted"/>
</packages>
<packages type="image" patternType="plusRecommended" profiles="WSL-Base">
<package name="attr"/>
<package name="acl"/>
<package name="bash-color-prompt"/>
<package name="bash-completion"/>
<package name="bind-utils"/>
<package name="bzip2"/>
<package name="curl"/>
<package name="dbus"/>
<package name="default-editor"/>
<package name="file"/>
<package name="glibc-langpack-en"/>
<package name="gnupg2"/>
<package name="iproute"/>
<package name="iputils"/>
<package name="less"/>
<package name="lsof"/>
<package name="man-db"/>
<package name="man-pages"/>
<package name="NetworkManager"/>
<package name="nmap-ncat"/>
<package name="openssh-clients"/>
<package name="passwd"/>
<package name="pciutils"/>
<package name="procps-ng"/>
<package name="rsync"/>
<package name="shadow-utils"/>
<package name="sudo"/>
<package name="symlinks"/>
<package name="systemd-udev"/>
<package name="systemd-resolved"/>
<package name="tar"/>
<package name="tcpdump"/>
<package name="time"/>
<package name="traceroute"/>
<package name="tree"/>
<package name="unzip"/>
<package name="usbutils"/>
<package name="util-linux"/>
<package name="vim-minimal"/>
<package name="which"/>
<package name="whois"/>
<package name="wsl-setup"/>
<package name="zip"/>
<package name="zram-generator-defaults"/>
</packages>
</image>
+9
View File
@@ -0,0 +1,9 @@
summary: Build the Windows Subsystem for Linux image
discover:
how: fmf
environment:
image_type: tbz
image_profile: WSL-Base
kiwi_file: Fedora.kiwi
execute:
how: tmt