Up one level
How to run Microsoft Windows applications in Linux using Win4Lin
Spencer Stirling

Update April 2006: I am revoking my recommendation for Win4Lin. I attempted to install the latest Win4Lin 5 (available on the website), for which I have a valid license. This thing didn't even get CLOSE to installing. It wouldn't even load my Windows CD properly. I messed with it for hours. I don't have my old version of Win4Lin (it hasn't been on my machine for a year or so), so I'm out of luck. If it were OpenSource software then I'd be more forgiving, but this is supposed to be professional. I highly recommend going with VMWARE server. I installed it on a Kubuntu machine and it works like a charm (don't forget to set up the VMWARE Tools in each virtual machine, otherwise the video is low-quality and the mouse doesn't work well!!!). Oh yeah... it's free as well. You can also try Xen for those CPUs that support virtualization. VirtualBox is another one to try - I have no experience with it.

So you want to run Microsoft Windows applications under Linux? There are several ways to do this. First, you can try a Windows emulator. If this is the route that you want to take, then you should check out the "Wine Project". The advantages of this project are: 1) it's free, 2) you don't need a version of Windows since "wine" is a Windows emulator, and 3) you are not supporting Microsoft directly. The disadvantages are: 1) it's slow, and 2) really only somewhat simple or common applications will run.

If you are willing to pay some money, then the company CodeWeavers has a product called CrossOver which tweaks wine so that it is easy to install and will run many of your most common applications (they specialize in Office it seems).

On the other hand, if you are going to run Windows applications, then you probably already have a version of Windows hanging around (hopefully in your back closet somewhere). In that case - if you are willing to fork over some cash - then the product Win4Lin by NeTraverse is a good option. BASICALLY, Win4Lin allows you to run the entire Windows operating system ON TOP of Linux. This has several distinct advantages: 1) It is fast - no emulation occurs, 2) Almost everything will work (except programs that play directly with the hardware... they are tougher), and 3) Did I mention that it is fast? Since Windows can take advantage of Linux's superior memory-management and X Windowing system, you will see Microsoft Windows actually boot up in about 3-5 seconds!!! If you need to restart your machine, it takes seconds instead of 30 seconds. I have used several emulators (Wine/Codeweavers), and this is (so-far) the solution that works best.

Unfortunately, this is NON-FREE software. If you are working for somebody who absolutely needs Windows software, then you might want to suggest this. Obviously, I never use Windows software, but some of the computer geeks that I play with need it.

Patching and recompiling the kernel
Getting this system to work is a bit of a pain. First, you will need to download some kernel patches and recompile your kernel. These can be obtained for free from the NeTraverse website. In my case, I am using a Debian 2.6.11 kernel. Assuming that you have the kernel source located in "/usr/src/kernel-source-2.6.11", you need to download the patches

Kernel-Win4Lin3-2.6.11.5.patch
mki-adapter26_1_3_12.patch

into the "/usr/src/kernel-source-2.6.11" directory. From that directory, you can patch the kernel by running

patch -p1 < Kernel-Win4Lin3-2.6.11.5.patch
patch -p1 < mki-adapter26_1_3_12.patch

Although these patches are meant for stock kernels, it still seemed to work on the Debian kernel (2.6.11). (Update: after looking at a plain vanilla kernel, it seems that these patches are ALREADY put into the stock kernel. So you will only need to patch the kernel if you are using a Debian kernel - I have no idea why they bothered to actually TAKE OUT Win4Lin).

Double update March 2006: it seems that the stock vanilla kernels have removed the Win4Lin patches, too (at least for kernel 2.6.15.6 - and probably earlier). So now you MUST apply the patches as above, but you'll run into a couple of problems. If you are using gcc 4 then your kernel WON'T compile. The problem is in the "mki-adapter" patch file. In there you should replace any of the assembly language commands "movl" with "movw" - see this forum for further discussion.

Furthermore, I can report that I have successfully compiled the patch intended for kernel 2.6.14.3 on kernel 2.6.15.6, but ONLY AFTER I fixed the patches as outlined in this forum, although you should read further in there because I haven't actually seen if it WORKS (I merely compiled and run the kernel - I haven't worked with Win4Lin on it)!!!

Next, you will need to configure your kernel and recompile it. You should use the Debian method, in which case you will need to have the packages "kernel-package" and "libnurses5-dev" installed (the latter package is so that you can configure the kernel using the ncurses method. There ARE other methods). To configure the kernel (using ncurses), type

make menuconfig

Take some time and make sure that your kernel is configured properly. This is rather detailed, so you will have to look elsewhere for hints. The important option now is "Enable Win4Lin" - make sure that you do enable it.

Open up "Makefile" and change the "EXTRAVERSION" to be "-1-k7+win4lin" or something. Now just make the Debian kernel package by running EXACTLY the command "make-kpkg kernel_image". This will compile (takes a long time) and when it is done you will have a Debian package "kernel-image-2.6.11-1-k7+win4lin.deb" in your /usr/src directory. Install it by typing "dpkg -i kernel-image-2.6.11-1-k7+win4lin.deb".

Now you will need to create a so-called initrd.img file for this kernel (this is a ramdisk that the kernel boots before it boots your real disk). This can be accomplished by first changed to the /boot directory. Then run " mkinitrd -o initrd.img-2.6.11-1-k7+win4lin 2.6.11-1-k7+win4lin".

Note that you will need to modify your bootloader (such as grub or LILO) to use this kernel and initrd image. In my case, when I installed the new Debian kernel package, it automatically updated the "/boot/grub/menu.lst" file. Unfortunately, I had to manually add the line (to the proper kernel section in there) "initrd=/boot/initrd.img-2.6.11-1-k7+win4lin".

Now reboot and check out your new kernel (with Win4Lin support).

Installing Win4Lin
Now you will need to install the actual Win4Lin software. This part is the annoying bit where you will have to deal with NeTraverse. First, download the "Win4Lin Workstation 5.0" installer. This will require you to become a member (registration is free). The installer is worthless, however, without a license - this you will need to purchase from Win4Lin.

In my case, however, I already have a license. In fact, I am just upgrading my system. Hence, I happen to know that the license file (on my old installation) is located at

/var/win4lin/install/license.lic

I just copied this over into the same location on my new system. This keeps Win4Lin from asking for licensing information. Please remember that this license.lic file must be readable by everybody!

Now you can unzip the win4lin tarball "netraverse_installer5.tgz" and run the installer "win4lin-install" found in the directory. This part should be pretty self-explanatory.

Installing Microsoft Windows System-Wide
Now comes the part where you really need to desecrate your machine. First, make sure that you have the Windows installation (*.CAB) files handy. Most of you might have this on CD, but I transferred this to the hard drive long ago (CDs suck and scratch easily). Obviously you need to have your Windows registration codes handy. I hate Windows.

Also, it will be VERY important to have a Windows startup disk handy (one that matches the version of Microsoft Windows that you are installing). You will NOT be able to install without this startup disk (it's stupid, I know).

Now, you will need to login as root. It will be best if you completely logout and then login as root running X Windows. In fact, I couldn't get it to work otherwise. In order to load the Microsoft Windows operating system, type the command "win4linadmin" at a command prompt.

IMPORTANT NOTE: the original documentation says to install the Windows operating system using the command "winsetup". When I do, however, I get the error "Can't startup xterm".

This "installs" the Windows operating system for the entire computer. However, I should say that, in fact, each user will install his/her own copy of Windows in his/her own HOME directory. I guess this really just "sets up for further installation."

Now it will be useful for the Administrator (you) to set up some system-wide settings that everybody can enjoy. For example, you might want everybody to have access to a COM port or an LPT port or something. Enter the command "winsetup" and go into "System-Wide Administration". Under "View/Create/Modify Device Definitions" you can modify COM/LPT port mappings.

Installing Microsoft Windows for each user
Each user will now be forced to install his/her own separate installation of Windows. Login as the user and from a command prompt run the command "winsetup". Choose the "Personal Windows Setup" option - this will be a very self-explanatory installation of Windows.

There is one interesting option in this setup: you can choose to either use Winsock networking (pretty basic, probably good enough for most installations) or VNC. Basically, Winsock will probably be good enough UNLESS you need Windows Networking (in Network Neighborhood). If you install using VNC, remember to give your computer a different network name than what is already being used by the Linux host. For example, in Linux my computer is named "blah" - this is the name that shows up on the network. In Win4Lin I named it "blah-win4lin". Essentially this makes your computer look like two different computers on the network... one Windows computer and one Linux computer (both running at the same time, obviously). This actually works pretty well, surprisingly.

When you are through with the annoying Windows installation, you might want to configure your personal system a little better. Again, type "winsetup" (make sure that you are out of Microsoft Windows) and go into "Personal Session Configuration: win". This allows you to add/remove drives, configure your own COM/LPT ports, etc.

That's IT!!! Try to enjoy your new Windows system...

This page has been visited   times since January 13, 2005