How to install Linux next to Windows 10: instructions for Ubuntu, Mint, Kali, Kubuntu, Rosa, Archlinux

WSL. Six months later

As I already said, over the past six months, the WSL developers have managed to thoroughly refine this subsystem, which simplifies its installation and configuration. And Microsoft itself managed to become a “platinum” member of the Linux Foundation. Fifteen years ago this could not even be dreamed of. In its new capacity, Microsoft has pledged to support all of the Linux Foundation's open source and Linux initiatives and contribute $500,000 annually to the foundation. This is definitely a great achievement. First of all, for the entire FOSS (free/libre and open-source software) community. Fifteen years after Steve Ballmer called Linux a cancer, Microsoft's new leadership is far more forward-thinking and intelligent.

But let's return to Windows Subsystem for Linux. Installing Windows 10 itself is quick and easy (almost like installing Ubuntu), and there is no need to describe it to our reader. You can choose either to update from a previous version of Windows 10, which will take many times more time and effort, or to uninstall the previous version and install the system from scratch (which is what I did, and not out of laziness, but the purity of the experiment so that the system was what called virgin-pure). The author of these lines has been a beta tester of Windows 10 for more than a year now, and new versions are available to him for free (from the word absolutely). If you are also a beta tester, then you must have a license for the new Windows 10 beta releases.

In the latest version of Windows, Anniversary Update 1607 - the “anniversary update” (it’s not clear what MS’s anniversary is), WSL is enabled by default. You just need to activate “Developer Mode” in the “Update and Security” section, wait until the system downloads the so-called developer package, and restart the computer. Then run the “Turn Windows components on or off” tool, where select “Linux Subsystem for Windows...”. And restart the computer again.


In the Russian version of Windows 10, everything is a little different, but the general meaning is the same

Other articles in the issue:

Xakep #216. Digging BitLocker

  • Contents of the issue
  • Subscription to "Hacker"

Installing bash in WSL goes without problems (although not as quickly as we would like). I was unable to install Unity the first time: the installer constantly complained about broken packages. As it turned out, first it was necessary to update the system through the standard Ubuntu package manager - APT. After receiving the updates, the installation went like clockwork and... lasted about nine and a half hours on my test Dell Inspiron (not the oldest laptop, although not a top-end one). Why - this mystery is unknown to me. However, I noticed that each Ubuntu package took three to four times longer to install than in “pure” Ubuntu.

Installing bash is reduced to one command in the Windows 10 console

Starting installation via BIOS

BIOS is most likely installed on every second person reading this article. In general, it is already considered a relic; it was UEFI that replaced it. But since there are still a lot of people with BIOS, it’s worth touching on the topic of installing Ubuntu through it.

After the OS image has been written to the USB flash drive, the installation of Ubuntu 16.04 begins next to Windows 10. To do this, restart your computer and press the Del or F2 key while it starts. This will take you to the computer's BIOS. Here we are only interested in one tab. Use the directional arrows on your keyboard to navigate to the BOOT tab. It is here that we need to select a priority device when starting the computer. We need to select a flash drive.

Important! On each computer, the BIOS may be different, and the choice of priority device may vary, so there will be no specifics.

If you have trouble understanding a foreign language, then pay attention to the fields where Hard, Disk and Priority are written. Opposite these fields will be written the name of your hard drive, often it starts with SATA, it is SATA that needs to be changed to a USB Flash Card.

We hope this abstract representation will help you choose the right settings, but even if a mistake was made, don’t be afraid, it won’t lead to anything bad.

After selecting the priority device, go to the Exit column and select the first item - “Exit while saving changed settings.”

Your PC will now reboot and the Ubuntu installer will launch.

X Window, Unity and everything, everything, everything

Installing bash is only half the battle. Then the fun begins - installing and configuring the X server on Windows and launching graphical applications, including Unity.

Canonical and Microsoft initially added the ability to run Ubuntu on top of Windows 10 to give system administrators and developers the ability to use bash and other Linux tools and utilities such as make, gawk and grep directly on Windows. Linux users, like true hackers (in a good sense of the word), did not take long to wait and immediately began working on running graphical desktop environments in WSL. And guess what? They did it. A Guatemalan programmer registered on GitHub under the username Guerra24 was able to (quote) “run Unity (the default desktop environment in Ubuntu) inside WSL. This suggests that Microsoft’s layer is, in principle, quite capable of running any desktop environment.”

This task is not trivial, and what you end up with can hardly be called a full-fledged Linux desktop, but this is just the beginning. If you want to use the Ubuntu desktop on Windows 10 for practical purposes, then it is better to use any of the currently available virtual machines, such as VirtualBox from Oracle. But if you just want to have fun and improve your desktop programming skills, you can try running “native” Linux directly on Windows 10. To run Unity in WSL, you first need to install (by any available method, preferably legal!) a version of Windows 10 Anniversary Update number 1607. And not the “home” version, but the most “professional”, or even “corporate” version. After installation, be sure to update the system and move on.

After two (sometimes three) reboots during the update process, in order to install bash, you need to launch the Windows command line (Win + R, enter cmd - and you will be happy in the form of a Windows “console”) and enter... yes, that’s right: bash. You will be asked to agree to the terms of service (be sure to accept them, you have no choice!) and download Ubuntu. At this stage, you just need to press the Y key. The size of the downloaded files will not be much more than one gigabyte. So, if you have slow internet (yes, that can happen), be prepared to wait. Then the installation will begin, which, in turn, will also take some time, depending on the performance of the computer. And at the end of it all, you'll end up in the userspace (user environment) of Ubuntu 14.04 running on top of WSL.

Technically, you won't be running Linux. It may look like Linux, but it is not Linux. The fact is that the user environment (that same bash and others) does not work on top of the Linux kernel, but inside the WSL layer. WSL uses a special API and set of instructions to make everything look like Linux, but it's still not the same. At the heart of it all is still the Windows NT kernel. This is important to understand in order to understand how Unity starts and works in WSL.

After installing Ubuntu, be sure to update it by entering the standard commands for this:

# apt-get update # apt-get upgrade

VcXsrv - X server for Windows

Next, you need to return to Windows 10 again and install an X server compatible with it. VcXsrv is ideal for our experiment. It’s better not to use its brother Xming, because, for some reason unknown to me, a problem arises with it: when you try to launch any graphical application for Linux, everything just crashes, including the Windows console. But that's not all. You need to tell Ubuntu that you should use the VcXsrv X server. To do this, enter the command in bash

# DISPLAY =: 0.0

Now any Linux graphical application will run on Windows 10. But only until bash is closed. To make WSL work with Linux graphics all the time, automatically selecting the X server needed to work, simply add the following line to the end of the bash configuration file (~/.bashrc):

# echo "export DISPLAY=:0.0" >> ~/.bashrc

VcXsrv - X-clock on Windows. Magic!

Firefox for Ubutnu works great, almost no lag!

After this, you will be able to run any graphical Linux applications, such as Firefox or any DE. However, they will not work the same as on Linux, crashing every minute, and some, such as Unity, will not start at all. The problem here is that WSL does not contain code to support sockets (the universal concept of data exchange between processes in UNIX-like systems, details here).

To implement the socket concept, Linux graphical environments use the D-bus messaging system by default. Most Linux graphical applications won't even start, let alone run, without D-bus. But WSL, fortunately, supports the TCP network protocol, which prompted Reddit.com user under the nickname ShaRose to find a way to force D-bus to use the TCP protocol instead of sockets. The solution is not perfect, but it works. To “attach” D-bus to TCP, enter in bash:

# sed -i 's/.*/tcp:host=localhost,port=0/' /etc/dbus-1/session.conf

The most important thing is to specify the display correctly!

With this command you will change the D-bus configuration file so that from now on it uses TCP instead of sockets. The good old sed stream editor will help you with this. What's the result? Applications that require D-bus to operate can now run in WSL. The next step is to install Linux graphical applications. First, do this in the WSL console:

# apt-get install ubuntu-desktop # apt-get install unity # apt-get install compiz-core # apt-get install compizconfig-settings-manager

Long installation of Unity...

The first command will install the basic graphical components of Ubuntu, including end-user programs such as LibreOffice. The following command installs the Unity desktop. The other two teams will deliver the composite window manager Compiz, which uses OpenGL, and the graphical frontend for it. It is this that will need to be configured correctly at the next stage.

Before you can start using the Unity desktop environment on Windows 10, you need to properly configure the CompizConfig Settings Manager (CCSM). After installing all these applications, launch CCSM from the bash interface and activate the following plugins in it (everything should be EXACTLY as in the screenshot!):

Compiz Settings

  1. In the General section:
    • Commands
    • Composite

  2. Copy to texture
  3. OpenGL
  4. In the Desktop section:
    • Ubuntu Unity Plugin
  5. In the Utility section:
    • Compiz Library Toolbox
  6. In the Window Management section:
    • Place Windows
    • Resize Window

  7. Scale
  8. Snapping Windows
  9. In the Image Loading section:
      PNG

Next, to make everything finally work, close CCSM and run Compiz from bash with the command

$compiz

In about a minute you will see the Unity shell running.

Unity at its best

Let me note a few key points:

  1. If you really want to run X applications in WSL, install VcXsrv as the X server, not Xming. It has been empirically proven that Xming does not want to work properly with WSL.
  2. After installing CCSM, you need to configure it exactly as shown in the picture (that is, turn on what is checked and turn off everything else). Only then will Unity start creakingly, not on the first try.
  3. It's best not to install proprietary ATI drivers for Ubuntu inside WSL. This leads to a complete freeze of the entire system (including Windows 10) and entails a total reinstallation of WSL with all that it entails.
  4. I’ll disappoint you: you shouldn’t place high hopes on the resulting crutch. THIS will not work normally. But on my test machine, Unity inside WSL worked quite well. Subjectively, it’s a little slower than native Linux. Perhaps in the future someone will bring this whole matter to fruition. And Unity in WSL will still be useful.

What will happen in the end, after so much torment? And in the end (theoretically, since in practice it’s just an interesting experimental way to run Unity and other DE inside WSL) we will get an environment for testing Linux applications directly inside Windows. And Unity running on top of Windows. Of course, the speed and responsiveness are not the same as on real hardware, but still faster than in a virtual machine. Many applications, such as Google Chrome or Pidgin, simply won't launch. But Firefox, the file manager, the application store and other Ubuntu system utilities work with a bang (a little slower than in “real” Ubuntu, but they work!).

Working with disk space using Ubuntu LiveDisk tools

One of the few advantages of Linux over Windows is distributions in LiveDisk format. It's much more than Windows Recovery Environment. So, LiveDisk with Ubuntu is almost a full-fledged operating system. Such a system is limited by the inability to apply settings and the low speed of the bootable media, which is unlikely to have significant significance in emergency situations. Among the standard tools of Ubuntu LiveDisk is a utility for working with the disk bias GParted.

When starting LiveDisk, select the Russian language and click “Run Ubuntu”.

Next, click the Dash launch button (analogous to the “Start” menu in Windows), and enter the first letters of the query “GParted” in the search field. And launch the GParted utility.

In its window we will see the same partition structure as in the Windows utility diskmgmt.msc, but in a different interface and with different data notations. Connected hard drives are displayed in the upper right corner as “/dev/ sda”, where “dev” is the term “device” (short for device), and “sda” is a specific HDD, SSD, flash drive or other media. Media are designated by replacing the last letter in alphabetical perspective - “sdb”, “sdc”, “sdd”, etc. Disk partitions are displayed as “/dev/ sda1” and are distinguished by the last digit – numerical perspective. In such conditions, it is necessary to focus on the sizes of disks and partitions.

Ours has 15 GB of unallocated space; it needs to be partitioned for Ubuntu - for the system itself and its swap file. But on computers with BIOS Legacy (regular BIOS, not UEFI), you first need to create one common partition - an extended partition, a container for forming logical partitions. The three existing partitions – “Reserved by the system”, drives C and D – were created during the installation of the system and during the operation of Windows using its standard tools. This means that by default they were assigned the type of main partitions, of which there should be no more than 4 on the disk. Therefore, in order to be able to further create disk partitions, the fourth partition must be created with an extended type, and logical partitions must be formed within it.

If the Ubuntu partition has already been created, but it was previously assigned the primary type, and this is the last of four such possible ones, the partition must be deleted. In the GParted window on the unallocated space, call up the context menu and select “Delete”. To create a partition on unallocated space, select “New” in the context menu.

In the window that appears to create a new partition, in the “Create as” column, select “Extended partition.” Click “Add”.

On the unallocated space, call the context menu again and select “New”. First, let's create a Linux swap partition. Even on modern computers with 4 GB or more of RAM, a swap partition is needed to unload data from RAM when entering sleep mode. In the window for creating a new partition, in the “New size” column, indicate a size equal to the amount of RAM on the computer. In the “Create as” column, select “Logical partition”, and in the “File system” column – “Linux-swap”. Click “Add” at the bottom.

On the remaining unallocated space, call the context menu again and select “New” again. In the “New size” column, in our case, we leave all the remaining space for the Ubuntu partition, in the “Create as” column, again, select “Logical partition”, and in the “File system” column we put “ext4”. Click “Add”.

All these operations to mark up disk space are only planned for now. They appear at the bottom of the GParted window and can be deselected if necessary. To use them, you need to press the green check mark button on the panel at the top.

Next, we confirm the actions,

We wait for the completion of applying the operations and close the GParted utility.

A story of hate and love

Microsoft has long had a special love for Linux in particular and the FOSS world in general. And these feelings, it must be said, as a rule, were not the warmest - starting with the famous “Open Letter to Amateurs” by Bill Gates, written back in 1976 (details on Wiki), where the author accused users of personal computers (which in those prehistoric times were users, programmers, and hackers!) almost in the theft of his intellectual property (that very BASIC), and ending with Steve Ballmer’s angry statements in 2001 about Linux: “Linux is a cancer that devours all intellectual property, which he touches. According to the license rules, if you use any components of open source software, you must open source all the software you own."

Fifteen years later, however, Steve has softened his position: in March 2020, the former Microsoft CEO said he was glad to see that the company's new head, Satya Nadella, had decided to become more active in supporting the open source community, and was "loved" to watch announcement of MS SQL Sever for Linux. In many ways, this turnaround of the former software industry giant is the merit of the FOSS community. Those thousands and thousands of programmers, designers, maintainers, FOSS activists and simply caring people who have been “sharpening stone like water” for years.

Back in the mid-2000s, MS began to change its position regarding FOSS. And these are not empty words, but deeds. For nothing, Microsoft recently received the status of a “platinum” member of the Linux Foundation, the main organization overseeing the development of Linux, and has expressed its commitment to the development ideas of the FOSS community. Well, the very existence of the WSL is proof of this. More than forty years later, we see how once irreconcilable ideological (and not only ideological) opponents began to work side by side, jointly making the world a better place. Or at least try.

Fifteen years later, Steve Ballmer has essentially admitted he was wrong.

The same letter from Bill Gates in defense of copyright

At the moment, Windows Subsystem for Linux can be considered the apogee of such symbiosis. Yes, the layer is still far from perfect. But the direction has been chosen correctly. Both sides.

"Give her a chance!"

“Give Windows Subsystem for Linux a chance and you will be amazed,” says Microsoft. Microsoft has finally recognized the potential of the FOSS world in general and Linux in particular. And each event becomes a lesson for Microsoft, allowing it to evaluate its capabilities and expand its activities in this area of ​​programming.

Most recently, on November 16 last year, a post appeared on Microsoft's developer site with a video titled "Improvements to bash on Windows and the Windows console," in which Microsoft senior programmer Rich Turner encourages Linux developers to take a look at what Windows 10 can do for them. offer. “Install a copy of the Windows 10 Developer Build (Windows 10 Insider Preview Build) and run your code, use the tools you know, host your sites on Apache, access your MySQL databases directly from your Java code,” says Turner.

Microsoft's Friendly New Face: Rich Turner

Turner emphasized that WSL was created specifically for developers with the goal of providing them with all the necessary development tools for Linux. And all this, he says, without losing the innovation and benefits of Windows 10. “No matter what tools you usually use on Linux to create applications, be it Go, Erlang or C, give WSL a chance, and most importantly, send us bug reports. These reports truly make our lives a lot easier, allowing us to create a product that we can all use to be more productive,” he continued.

Of course, Microsoft itself is interested in improving WSL, and Turner says the ultimate goal is to make it fully compatible with all Linux development tools. And, they say, anyone who switches to Windows 10 will feel just as comfortable as they did on Linux. And this, in turn, will provide Microsoft with an influx of new users. “We are just at the very beginning. We have a long way to go. At this point, we can't say that this thing is truly fully compatible with Linux tools and ready for you to fully use," he said. This announcement came as a surprise to many people. However, as already mentioned, Satya Nadella, the current head of the software giant, will take a different approach to FOSS and Linux, viewing open and free code as a source of income and new opportunities.

Separately, I note that Rich Turner in his speech does not call on developers to abandon Linux and does not in any way diminish the advantages of this OS, but only asks to give WSL a chance.

Examples of using Ubuntu Shell on Windows

First, let me note that the author is not an expert on bash, Linux or development, and the examples below are simply a demonstration that on Windows 10 bash works with expected results for those who understand it.

Linux Applications

Applications in Windows 10 Bash can be installed, uninstalled and updated using apt-get (sudo apt-get) from the Ubuntu repository.

Using text-based applications is no different than on Ubuntu; for example, you can install Git in Bash and use it as you normally would.

Subtotals

What would you like to say in connection with all this? First of all, Microsoft is not the same anymore. Not that monstrous evil corporation. Every year the company's profits from software sales are falling, the mobile device market is essentially left to Google and Apple, and users (both corporate and home) are increasingly trying to save money on buying software. And the company has to adapt to new conditions. Even MS’s “sworn friend” Apple opens the source codes of its products one after another. Secondly, this is all very good. First of all, for us, ordinary users.

In the next article about Windows Subsystem for Linux, we will conduct several performance tests and finally try WSL in practice by installing the Apache web server on it and running local hosting of the site. In the meantime, we can briefly summarize that the experiment was a success.

Rating
( 1 rating, average 5 out of 5 )
Did you like the article? Share with friends:
For any suggestions regarding the site: [email protected]
Для любых предложений по сайту: [email protected]