Import Rocky Linux to WSL with WSL and rinse¶
- A Windows 10 PC with WSL 2 enabled. (*see note below).
- Ubuntu, or any debian-based distribution, installed and running on WSL. This guide was tested using Ubuntu 20.04 LTS from the Microsoft store.
This guide is for Windows users who would like to run Rocky Linux (RL) in the Windows Subsystem for Linux (WSL). It assumes the reader is familiar with the command line and has WSL enabled and running in their Windows 10 PC.
The process uses
rinse, a perl script for creating images of distributions that use the package manager YUM.
Please keep in mind that WSL has significant limitations and quirks, and the resulting distribution may or may not work as you expect it. It may be too slow, or be unpredictable for some applications. With computers, as with life, there are no guarantees.
Launch your Ubuntu distribution in WSL, update the package manager and install
$ sudo apt-get update $ sudo apt-get install rinse
rinseis not aware of RL, so we need to modify its configuration to add the package repositories and so on.
Copy the CentOS 8 packages file and prepare it for RL
$ sudo cp -p /etc/rinse/centos-8.packages /etc/rinse/rocky-8.packages
- Edit the new file and change all the entries for 'centos' to 'rocky'. Next, add the following lines to it. The order in the file is not important, the entries can be added anywhere. Here you can also add any other packages that you may want to have in your image (servers, utilities like
glibc-langpack-en libmodulemd libzstd passwd sudo cracklib-dicts openssh-clients python3-dbus dbus-glib
- Edit the
rinseconfig file at
/etc/rinse/rinse.confand add the following lines, which are the entry for RL mirrors. As of this writing, we have a direct download, but this will be changed to a mirror as soon as available.
# Rocky Linux 8 [rocky-8] mirror.amd64 = http://dl.rockylinux.org/pub/rocky/8/BaseOS/x86_64/os/Packages/
- Copy the post-install script for CentOS so it can be modified for RL
$ sudo cp -pR /usr/lib/rinse/centos-8 /usr/lib/rinse/rocky-8
/usr/lib/rinse/rocky-8/post-install.shand add the following lines at line 14. This is needed to make sure TLS/SSL works as expected for YUM and dnf.
echo " Extracting CA certs..." $CH /usr/bin/update-ca-trust
- Edit the
/usr/sbin/rinse, and at line 1248 remove the text
--extract-over-symlinks. This option was deprecated in the program called and breaks the script. Don't close the file yet.
- On the same file, go to line 1249 and replace 'centos' for 'rocky'. Save and close the file.
- Make a directory to hold the new RL filesystem (any name is fine).
$ mkdir rocky_rc
rinsewith the following command
$ sudo rinse --arch amd64 --directory ./rocky_rc --distribution rocky-8
- After the script completes downloading and extracting all the packages, you will have a full Rocky Linux file system in the directory you created. Now it's time to package it to pass it to Windows for importing into a new WSL distro. Use this command, creating the tar file in a Windows folder (starting with
/mnt/c/or similar to have it readily available for the next step).
$ sudo tar --numeric-owner -c -C ./rocky_rc . -f <path to new tar file>
- Close your WSL session with Ctrl+D or by typing
- Open a PowerShell prompt (does not need to be admin), and create a folder to hold your new RL distro.
Import the tar file with this command:Note: Default location of WSL is
wsl --import rocky_rc <path to folder from step 9> <path to tar file>
e.g. for Ubuntu - C:\Users\tahder\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhks2fndhsd\LocalState\rootfs\home\txunil\rocky_rc
In the PowerShell prompt, launch your new distro with:
wsl -d rocky_rc
- You are now root in your new RL distro. Run these commands to finish setting everything up:
yum update yum reinstall passwd sudo cracklib-dicts -y newUsername=<your new username> adduser -G wheel $newUsername echo -e "[user]\ndefault=$newUsername" >> /etc/wsl.conf passwd $newUsername
- Exit the bash prompt (Ctrl+D or type
- Back in PowerShell, shutdown WSL and relaunch your new distro.
wsl --shutdown wsl -d rocky_rc
- Test and enjoy!
All the downloaded packages are still stored in the debian distro you used at the beginning of the process. You can remove the files from
/var/cache/rinse, and you can also delete all the files from the
rocky_rc directory. Next time you want to create a new, updated or modified image, simply make your changes and run the commands from step 10 on.
There are some quirky things that result from extracting packages, rather than installing them. Running
yum reinstall in some packages fixes the issues, as is the case for
rinse script simply extracts the packages and does not execute post-install commands (although it is capable of doing so). Please leave comments for other users if you run into problems and know how to fix them, so that others can benefit from your experience.
Most of the
rinse script runs under WSL 1, but the very last part, where
dnf is invoked, runs into memory issues and corrupts the
rpm database. This ruins the distro, and repair attempts fail, even under WSL. If you know how to get
dnf to work under WSL 1, please let us know, but there are lots of BDB issues related to WSL 1 on different forums on the web. WSL 2 solved those issues with the native Linux kernel.