Did you ever want to have a Linux environment easily accessible on your laptop? The most common way to achieve this, in the past, was to have a virtual machine running your preferred Linux distribution. Oracle VirtualBox being free, there wasn’t any extra licensing required, and fairly simple to set up.
This was the past…
Oracle did an extra step to make all this simple by publishing Oracle Linux images in the Windows Store.
Oracle Linux 7.9 is available already and Oracle Linux 8 is coming….
Windows 10 introduced WSL: Windows Subsystem for Linux
If you are running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11, you can now use Windows Subsystem for Linux to run your preferred Linux distribution in a fairly transparent way, also having full access from inside Linux to your Windows disk to easily share content and much more.
The official way is to enable WSL (have a look at the install steps directly on the Microsoft site) and then move to the Microsoft Store to download one of the available distributions (Ubuntu for example).
If you look for Oracle Linux you can keep searching for a while… I did find a fairly expensive product that announce it let you run Oracle Linux. Is this the only way? Doesn’t sound right to have to pay a 3rd party product to run a free OS.
One way would be to install a CentOS distribution (there is a GitHub repository providing them) and then switch CentOS to Oracle Linux: it does work. I did it in the past for my Oracle Linux 7 WSL distribution, my OL7 is still working fine right now.
The quicker way to get Oracle Linux in WSL: export a docker container filesystem
Today I wanted to add an Oracle Linux 8 distribution to WSL to start working on the newer version of Oracle Linux more often (so far I did always use Oracle Linux 7 in the last years). Instead of going through the conversion from CentOS to Oracle Linux, I did search for a faster way, and there is one!
If you have access to an environment with docker you will need only a few minutes.
First, you start by pulling the Oracle Linux image you need from the Docker Hub. I took the oraclelinux:8 image which is the latest Oracle Linux 8 available (8.5 at the time of writing). As the Docker Hub page suggests, you probably don’t want the 8-slim image as it’s a Docker image with a smaller footprint. For your WSL distribution, a lightweight image like the normal 8 release is just right.
Once the image is available you have to export the filesystem of a container based on that image in a tar archive. By using docker create you create a new container based on the image, you take the identifier of the container (the output of the create command) and call docker export to export the filesystem into a tar archive. Once done don’t forget to remove the container as you don’t need it in docker.
If you don’t need the docker Oracle Linux image you can now freely remove it (always remember to clean up behind you when doing these things to not fill up the disk with tons of random unneeded things).
Import a Linux filesystem tar archive as a WSL distribution
Move the tar archive to a location accessible by your Windows 10/11 running WSL. The location doesn’t matter and you will be able to delete the file at the end.
Before importing the Oracle Linux 8 distribution make sure you have a folder where to deploy the WSL distribution (I do use c:\wsl\<distribution_name> to store my distribution in an organized way).
It only takes one command to import the distribution: wsl –import <distribution name> <path where to deploy the distribution> <path to the tar archive>
You can test the import was successful by listing the available distributions and you can also directly start the newly imported distribution and test that you are really inside an Oracle Linux 8.5 environment.
Some final customization
The Oracle Linux docker images execute as the root user and no normal account exists by default. Not a problem as it’s just a Linux environment: with
useradd you can easily create a normal user account for daily usage, and WSL has some commands to define the default user to start a distribution with (can also be set in the Windows registry if needed, Google is your friend).
Everything else you would like to customize can be done as in any other Linux environment! If you aren’t happy with the default path where the distribution starts, you can add at the end of
cd ~ command to change the path to the user home directory, or any location of your choice. You can install any package you need by using DNF, the default package manager in Oracle Linux 8.
If you want to use Visual Studio Code to edit files inside your WSL distribution, you must only execute
code . . It will maybe complain that wget and tar aren’t available, use DNF to install them (remember the WSL distribution comes from a docker image that always tries to be just enough Linux for basic activities, everything else is up to you to install it).
Enjoy your Oracle Linux WSL distribution!