by Swapnil Bhartiya

How to install openSUSE Leap bash shell in Windows 10

How-To
Jan 18, 2017
Cloud ComputingLinuxOpen Source

This tutorial will help you in running openSUSE Leap (command line) within Windows.

It’s no longer a Windows vs Linux world. It’s a Windows and Linux World. And when it comes to the cloud, Linux rules.

That creates a unique challenge for Microsoft. Windows doesn’t have tools and utilities to manage Linux servers. This has meant that developers running Windows on their local machines have had to either dual boot with Linux or run Linux in a virtual machine (VM). Neither was an ideal situation.

Microsoft tried to bring Linux capabilities to PowerShell, but that was going to be a daunting task, so they came up with a clever solution. They created a subsystem for Linux so admins and developers can run Linux utilities natively on Windows without having the overhead of a VM and without leaving the Windows environment, which means they can develop and deploy for both platforms.

As expected, Microsoft chose Ubuntu as the base for its Linux layer. The reason was purely technical and market driven. Ubuntu is the most popular cloud OS for obvious reasons. Ubuntu is available free of cost, unlike RHEL and SUSE, so you can run thousands of Ubuntu instances without paying a dime, and if you do need commercial support you can easily get it through Canonical.

But what if you are an openSUSE user or you run SUSE Linux Enterprise Server on Azure? How will you get access to SLES/openSUSE specific tools and commands? 

There is good news for such users: openSUSE/SUSE engineers have come up with a solution that lets users replace Ubuntu with openSUSE Leap on Windows 10.

If you want to run openSUSE on your Windows 10 system, here is how you do it:

Prepare Windows 10 for Linux

You need to become a Windows Insider to get early access to the experimental Windows Subsystem for Linux (Beta) feature. Go to Settings and under ‘Update and Security’, find the “For Developers’ option and enable ‘Developer Mode’. Then go to Windows Updates setting and click on Advanced Options, click on ‘Get Started’ under Get Insider Preview Builds option. You will need to log into your Microsoft account. Once logged in, choose the ‘Fast’ level for Insider program. Windows may now install some updates. If no updates are available, search for ‘turn windows features on or off’ in the search bar of settings. A new window will open, scroll down and enable ‘Windows Subsystem for Linux (Beta)’. Click OK and close settings.

Open the Command Prompt from the Start menu and type ‘bash’. Windows will start downloading Ubuntu for Windows. I know, it’s Ubuntu and not openSUSE. Don’t panic. We do need the base Ubuntu layer, once we have that, we can use any Linux distribution on it. After successful installation, it will ask you to create a username and password. Once done, open the Ubuntu bash shell in Windows by typing ‘bash’ in the Start menu of Windows and it will open a Linux terminal.

Now it’s time to turn Ubuntu against itself. First run system updates to make sure all packages on Ubuntu are up to date.

sudo apt-get update
sudo apt-get dist-upgrade

Once it’s fully updated, download openSUSE Docker image:

wget -O openSUSE-42.2.tar.xz https://github.com/openSUSE/docker-containers-build/blob/openSUSE-42.2/docker/openSUSE-42.2.tar.xz?raw=true

Now create ‘rootfs’ directory, extract openSUSE image and exit by running these commands, one by one:

sudo mkdir rootfs
sudo tar -C rootfs -Jxf openSUSE-42.2.tar.xz
exit

Open Windows command Prompt and make a backup of Ubuntu, by running these commands, one by one:

cd %localappdata%lxss
rename rootfs rootfs.ubuntu
move .homerootfs .

(Note: exchange ‘ubuntu_user’ with the name of the user that you created for Ubuntu).

For now, we will just use ‘root’ as the user on our openSUSE install, so set root as the default user, from the Command Prompt of Windows 10:

lxrun /setdefaultuser root

Close the command prompt and open ‘bash’ from the start menu. To check if you are running openSUSE and not Ubuntu, run the following command:

cat /etc/os-release

You will feel immense joy to see ‘openSUSE Leap. Eureka! You have openSUSE running on Windows 10. Go ahead and run ‘zypper up’ to run system updates and then start using openSUSE Leap on Windows 10.