Run Linux applications in Windows – a fantasy or a harsh reality?

The use of Linux or UNIX applications in Windows can be dictated by a mass of reasons – from the banal habit to some programs to the inability to run a separate machine from Linux. Someone wants to use native versions of the software for debugging, and someone hopes that this way you can make users smoothly migrate to a full-fledged distribution.

Before you plant a garden with emulators, it's best to look for ported versions or analogs of your favorite programs. The same GIMP, Audacity, Pidgin and many other utilities have native builds not only for Windows, but also for Mac OS X. To get any specific functionality, it often does not require a full-fledged analog of Linux software. For example, you automatically get used to Tab auto-completion in the bash shell very quickly, and at the command line Windows does not have it. To fix this and other annoying omissions help utility clink.

Standard console utilities, for example from the GNU Coreutils package, have long been sporting on Windows. There are quite old sets of GNUWin II and UnxUtils, as well as constantly updated UWIN (not recommended) and Gnuwin32. For the last one after the installation of the basic installer, you must run the download.bat and install.bat files sequentially, and then copy the gnuwin32 folder at will to any convenient location and run the update-links.bat file from it. After running the last script in the StartMenu subdirectory, there will be links to the launch of the command line with the GNU environment and the documentation for the utilities.

Owners of Windows Vista / 7 in the maximum and corporate versions, as well as server versions of Microsoft OS can not bother at all. For them, a subsystem is available for applications based on UNIX (Subsystem for UNIX-based Applications, SUA) or Microsoft Windows for UNIX (Microsoft Windows Services for UNIX, SFU) services. This set of basic utilities is present directly in the components of the system. Additional sets of programs can be downloaded here. Finally, the last in the list and the first popular solution for launching UNIX programs is Cygwin. This package is easy to install and contains not a small set of applications ported for Windows. It is recommended to use it.

Now you can talk about the strange – the launch of a non-native Windows system KDE. In fact, the KDE on Windows project has existed for many years, and it was simply impossible to use it at first because of regular falls that did not drive the unfortunate system into BSOD. However, the developers did not sit idly by, and in the current reincarnation of the project it can be safely installed – mistakes are quite rare, and those are uncritical. Everything immediately put a meaning, probably not, but some applications may like.

Unfortunately, ported applications do not always behave as they do in their home environment, or they may conflict with other programs. Therefore, the only way out, in addition to installing the "penguin" OS on bare metal, is to emulate Linux. For one-time use, you can apply a shell for QEMU called MobaLiveCD, which without unnecessary gestures will help run LiveCD / USB with various distributions. For permanent use, it's better to install Linux in a virtual machine: in VirtualBox or VMWare Player. Just do not forget to install guest add-ons for more comfortable work. An alternative is to use VDI solutions with the possibility of seamless integration in Windows Linux applications running on a separate host, which can also be virtualized.

The best option for running Linux applications is to use the coLinux environment. It, relatively speaking, starts the Linux kernel at the level of the Windows kernel and has access to all hardware resources of the machine, due to which there is practically no loss of performance. At the same time, it maintains full compatibility with Linux-applications, allowing them to run directly. On the basis of coLinux, there are ready-made systems for the quick launch of Portable Ubuntu Remix, Topologilinux (Slackware), SpeedLinux (various distributions) and andLinux (Ubuntu). The only unpleasant limitation of coLinux and all packages based on it is the need to use the 32-bit version of Windows 2k / XP / 2k3 / Vista / 7. As an example, let's take a look at the minimal configuration of Debian Squeeze. First of all, install the latest version of coLinux, refusing to load ready images and installing WinPcap in passing.

Now you need to download the disk image archive from Debian and unpack it to the folder into which coLinux was installed. The size of the rootfs_2gb.img disk can be increased if desired. The file squeeze.conf will have to be edited a little. The minimum changes are to increase the amount of RAM allocated (mem), to allow access to the C: drive via COFS and add the TAP network interface. Note that when using COFS, it is better not to simultaneously access the same files with folders from Linux and Windows.

 kernel = vmlinux
Cobd0 = "rootfs_2gb.img"
Cobd1 = "swap_128mb.img"
Root = / dev / cobd0
Ro
Cofs0 = "C: "
Initrd = initrd.gz
Mem = 512
Eth0 = slirp
Eth1 = tuntap

After running squeeze.bat, you will be taken to the Debian console. The login is by default root, and there is no password. Using nano, edit the network interface parameters in the / etc / network / interfaces file. Let's add a section for eth1. We use any IP address as long as there is no intersection with other local subnets. In Windows, in the IPv4 settings of the TAP-Win32 Adapter V8 (coLinux) network adapter, you must specify an address from the same subnet.

 auto eth1
Iface eth1 inet static
Address 192.168.100.2
Netmask 255.255.255.0

Exit nano with saving changes – F2, Y, Enter. Now create a folder where the C: … drive will be mounted …

 mkdir / mnt / windrvc

… add one line to the end of the / etc / fstab file and save it:

 / dev / cofs0 / mnt / windrvc cofs defaults 0 0

Now we are going to install the X server, but for now, for simplicity, we will write the export of the variable DISPLAY to the file ~ / .profile (this will have to be done for any other users). For the IP address, use the one that is specified for the TAP adapter in Windows. After that, you can reboot with the reboot command.

 export DISPLAY = 192.168.100.1: 0

It is not superfluous to install a set of fonts, including Cyrillic ones. Optionally, you can go through fonts catalogs, including C: Windows Fonts, mkfontdir and mkfontscale utilities from Cygwin. Now you're ready to install the Xming X server. Immediately after this procedure, add the IP address of the TAP interface in Debian to the file X0.hosts (in our example it is 192.168.100.2).

"Thanking" Windows for vigilance and in the standard firewall we will change all the rules concerning Xming, with forbidding permissions, otherwise the programs simply will not reach the X server. Now run the XLaunch utility, in which you can select the X-windows display mode and set additional parameters. For us, it's important to set up support for Russian and English layouts with switching over Alt + Shift and optionally set DPI. At the end, the configuration file must be saved as a name.xlaunch. In the future, by double-clicking on this file, the X server will be launched with the parameters set by us.

 -xkblayout us, en -xkbvariant basic, winkeys -xkboptions grp: alt_shift_toggle -dpi 96

In order not to be so boring, install the synaptic package manager for a more convenient installation of the software and some lightweight panel with the application menu, for example lxpanel. The latter for simplicity, we'll write to autostart at the entrance, adding the command lxpanel & to the end of the ~ / .profile.

 apt-get update
Apt-get upgrade
Apt-get install synaptic lxpanel

For the sake of completeness, let's add sound support. Download the archive from Pulseadio from here and unpack it into a directory where we create a text file default.pa. We fill this file with the following lines. Here 192.168.100.0/24 is our TAP-subnet.

 load-module module-native-protocol-tcp auth-ip-acl = 127.0.0.1; 192.168.100.0/24
Load-module module-esound-protocol-tcp auth-ip-acl = 127.0.0.1; 192.168.100.0/24
Load-module module-detect
Add-autoload-sink output module-waveout sink_name = output
Set-default-sink output

Run pulseaudio.exe and once again go to edit the permissions in the Windows Firewall. In the Debian console, install the necessary utilities and libraries.

 apt-get install libpulse0 libasound2-plugins alsa-utils

In the file /etc/pulse/client.conf, add the IP address of the host machine with the Pulseaudio server running – default-server = 192.168.100.1, and in /etc/asound.conf the following parameters:

 pcm.! Default {type pulse}
Ctl.! Default {type pulse}
Pcm.pulse {type pulse}
Ctl.pulse {type pulse}

You can try to play one of the test files to test the performance.

 aplay /usr/share/sounds/alsa/Front_Center.wav

Pulseaudio starts automatically when Debian starts, adding this command to the end of the configuration file squeeze.conf.

 exec0 = "X:  path  to  folder  pulseaudio  pulseaudio.exe"

This trick does not work for X-server. In principle, what has already been done is sufficient for work. However, it would be nice to add a new non-root user to Linux, set up an autogin with mingetty for it, install coLinux as a Windows service and assign Xming to autorun. For convenience, you can put the utility Desktops, which creates several virtual desktops in Windows, and run the X-server in full-screen mode on the second desktop.

In the end, we got a fast environment for almost natively running Linux applications in Windows. It can be used for writing and debugging web applications, cross-copying drivers and other tasks. That's only sane graphics acceleration for the work of heavy applications is not yet, yes, the 64-bit version was developed just a few months ago. Nevertheless, coLinux is perfectly suitable for everyday use. To further explore the features and settings of this system, refer to the project wiki. Well, we'll close this topic of the symbiotic relationship between Windows and Linux through different places. Have fun!

If you notice an error – select it with the mouse and press CTRL + ENTER.

Leave a Reply