by Brad Rodriguez
Bruce Grey Linux Users Group, 11 February 2003
Win4Lin is a program that lets you run Microsoft Windows as a task under Linux. This allows you to run your Windows software on a Linux computer. Win4Lin is a commercial product from NeTraverse <http://www.netraverse.com/> and costs US$90. (A discount is available to BGLUG members.)
Win4Lin is not a replacement for Windows, or a Windows emulator like Wine. You still must own and install a copy of Microsoft Windows.
Furthermore, you must own a new copy of Windows (installation CD and boot floppy). You will have to install this copy of Windows under Win4Lin. Win4Lin will not use an installed Windows system that is already on your hard drive; you must do a fresh install. (For those of us whose old Windows systems have become unstable, this is actually a blessing.)
Win4Lin is probably closer in spirit to VMWare, which lets you run multiple operating systems on one PC. But it does not emulate a “virtual machine” like VMWare, nor are the operating systems independent. Instead, Windows is run as a task under Linux, and uses Linux services for console I/O, file I/O, network, and the like. If your Windows application or the Windows OS crashes, all you have to do is kill the task from Linux (which keeps running).
Win4Lin requires a Linux system with a 2.2.x or 2.4.x kernel. The 2.2.x kernel is deprecated and may not be supported in the future. Major Linux distributions, like Red Hat and Mandrake, are directly supported with easy-to-install packages, but if you like to compile your own kernels, you can still run Win4Lin. You do need to patch the kernel.
To install and use Win4Lin you will need a minimum of 64K of RAM on your Linux system (more is better). You will also need 60 to 150 MB of hard disk space, depending on the Windows you choose to install. If you intend to use the limited sound support of Win4Lin – see below -- you must have an OSS compatible sound card. See <http://www.netraverse.com/products/win4lin40/requirements.php>.
Only Windows 95, 98, or Me can be used with Win4Lin. At the present time, Windows NT, 2000, and XP are not supported.
A maximum of 128 MB of RAM will be available to your Windows application, regardless of how much RAM you have on your Linux system.
Only PCM output (.WAV files) is supported from Windows. In particular, MIDI playback and sound input are not supported. CD audio is also not supported.
DirectX is not supported under Win4Lin. At all. (Win4Lin is targeted at businesses trying to migrate their existing office and technical applications to a Linux environment. I suspect their attitude is that if you want to play games you should use Windows...or support Linux game vendors.)
I installed Win4Lin on a Pentium II 400 MHz system with 192 MB of RAM, running Red Hat 8.0. Win4Lin needs to modify the standard Linux kernel, and for this version of Red Hat (as well as several other distributions), an already-modified kernel is available from NeTraverse.
Because this was an evaluation copy I had to use direct Internet software distribution. I downloaded a small “installer” program, which then downloaded the rest of Win4Lin. As this amounts to several megabytes, it took quite a while with my dial-up connection, but it loaded without problems. (Dial-up customers may opt for the CD-ROM distribution of Win4Lin, available for an additional US$10 plus shipping.)
I found the installation instructions to be extremely clear. You are walked through the process, including any necessary shell commands, in such detail that even a newcomer to Linux should have no trouble installing Win4Lin.
I did run into one snag while installing, and it turned out to be my fault. You must install from a Windows CD-ROM and Windows boot floppy. I chose to install a copy of Windows 95 which I had sitting on the shelf. The Win4Lin installer repeatedly hung up halfway through the process. It turned out that my boot floppy was not in fact bootable, having been corrupted somehow, so I had to go to a working Windows 95 system and create a new boot floppy. Fortunately, the Win4Lin install leaves you the options of booting either your original Linux kernel or the modified kernel, so even when the installation was aborted, and their kernel wouldn't start, I could boot Linux and send email.
While troubleshooting this I had to go several rounds with the NeTraverse customer support team, and they are excellent. They were prompt, patient, and helpful, with suggestions for tests I could perform and send to them. (Evidently I had stumbled upon a problem that neither their installer nor their knowledge base had anticipated, so perhaps it wasn't a total waste of their time.)
After fixing this problem the installation went without a hitch. A new icon appeared on my desktop to launch Win4Lin. It can also be launched from an X terminal window with the command “win”.
One surprising feature of Win4Lin is that Windows uses the Linux file system. I had reserved a VFAT partition on my hard drive, and I found out this isn't necessary. Win4Lin will run entirely on a native Linux file system. It does this by mapping Windows “drives” to Linux directories. This is not storing an image of the Windows drive as a big Linux file. Each file under Windows appears as a file of the same name under Linux.
To be specific: the Windows drive C: is mapped to a directory “win” in your home user directory, i.e., ~/win. (In my case, this is /home/brad/win.) And all the subdirectories of C: appear as subdirectories of ~/win. For example, ~/win/windows and ~/win/windows/system. Note that each Linux user has his own “private” Windows installation. (This does mean that each additional user requires enough hard disk space for a full Windows installation.)
The Windows D: drive is mapped to a directory ~/mydata. This is useful if, like me, you are in the habit of keeping your personal and working files separate from “system” files so they can be more easily and frequently backed up. (More on this in a moment.)
Windows drive J: is a “shared” drive seen by all Win4Lin users, and is mapped to /var/tmp.
If this isn't enough for you, any Linux subdirectory can be mapped as a Windows drive. This is done through the Win4Lin setup program.
Furthermore, if you do have VFAT partitions on your hard drive, Win4Lin can map those directly as Windows drives. So although you have to install a fresh copy of Windows under Win4Lin, you can access the files on your old Windows drive. I have my original Windows drive installed as /dev/hda, and if I wish, I can mount this under Win4Lin as, say, drive E:.
However, I'm a perverse sort, and I need access to my old Windows files from Linux. So I was already mounting the VFAT partitions on the Linux file system, as directories named /C: /D: and /E:. And I figured that if Win4Lin is using the Linux file system, it should be able to read any file on the file system, and it should honor symbolic links.
Ages ago I used a separate partition, D:, for my personal files. When I installed Windows 9x, I let it make one big partition and I moved my personal files to a subdirectory d -- that is, C:/d under Windows, now mounted as /C:/d under Linux. So I tried making a symbolic link from ~/win/d to /C:/d. Sure enough, the subdirectory d now appears on the Win4Lin drive C: with all my original files. All my original directory paths are still correct. (I also do this with DOSEMU.)
This means that I'm in the ludicrous position of mapping a Windows drive to a Linux file system, and then mapping it back to a Windows drive. NeTraverse does not recommend this practice, nor do they guarantee the correct operation of symbolic links. They advise mounting a Windows partition directly on Win4Lin. But when you do this, you cannot simultaneously mount the partition as a Linux filesystem (a sensible restriction, to avoid disk caching problems).
Since I need to access my old files under Linux, I'm using this circuitous workaround. So far I've noticed only two problems. When editing a file under Linux, the Windows cache doesn't get updated...so if I use my Linux editor with a Windows compiler, sometimes my edits don't appear right away. I get around this by using a Windows editor when working in Win4Lin – but the second problem is, in the process of translating file names twice, they get converted to upper case. Windows applications don't mind this, but it's annoying under Linux.
Drive N: is the CD-ROM. Win4Lin takes care of mounting and unmounting the CD-ROM device; but this does require that you disable CD-ROM automounting in Linux. (They tell you how to do this.) The floppy disk is drive A:, of course, and this too is automatically mounted my Win4Lin. To the Windows user, the CD-ROM and floppy drive appear to function “normally.”
Normally the entire Windows desktop appears in a single X window on Linux. (And then your Windows applications appear within that.) What I do is maximize the Win4Lin window within one Gnome workspace. This means that I still have the Gnome toolbar at the bottom of the screen, and I can quickly switch workspaces to check my email, or open other Linux applications. The downside is that the Windows desktop is reduced in size by that amount (and also by the few pixels of the X window border).
In response to a question at the presentation: the mouse pointer moves smoothly between the Windows desktop and the Linux region “outside.” I gather that some Windows emulators have trouble with this transition. I've never had a problem with Win4Lin.
There is an alternative (launched with the “fwin” command) that will open Win4Lin using the full video screen. Then you use Ctrl-Alt-F7 and Ctrl-Alt-F8 to switch back and forth between Win4Lin and Linux. When I attempted to test this feature it failed to work, but since I prefer to operate “within” Gnome I haven't tried to debug it or report it to NeTraverse customer service. Others with “big” Windows applications might find this feature valuable.
Incidentally, Gnome is just the window manager I chose to use. It's not a requirement for Win4Lin. As far as I know, Win4Lin will work equally well under KDE.
Win4Lin offers two methods to support networking under Windows, called “Winsock” and “VNET.” So far I've only tested Winsock.
Winsock redirects Windows networking requests to the Linux TCP/IP functions. It emulates the TCP/IP drivers normally provided by the “Winsock” layer (hence the name). The advantage to this are that it's trivial to configure – assuming that you've already configured your Linux box, that is. Your Windows applications use the same IP address as Linux, and use the Linux drivers. The disadvantage is that this supports only TCP/IP networking.
VNET (virtual networking) performs the emulation one level lower, by providing Windows with a “virtual NIC” (Network Interface Card). Windows thinks it's actually talking to an Ethernet card, and it provides its own TCP/IP or other protocol stack. The main advantage of this is that it allows full support for Microsoft Networking -- Microsoft file and printer sharing, Network Neighborhood, and so on. The main disadvantages are that, first, because this appears to be a distinct computer on the network, it must be assigned its own IP address different from the Linux host. Second, of course, you need to go through the full Windows TCP/IP configuration process.
I've migrated all of my “networking” applications – email, web, etc. -- over to Linux, so I haven't experimented much with the Win4Lin networking support. I opted for a Winsock installation because it was easiest, and because I can always switch to VNET later.
I blush to admit that I still haven't tested printer support under Win4Lin.
Printers under Win4Lin use the Windows printer drivers, and then send their output to your printer to the Linux “default-raw” printer. This means that Linux is managing the print stream, so you should be able to share the printer between Windows and Linux applications without problem. But the actual translation to the printer command language is handled by the Windows drivers. While this ought to allow the use of “WinPrinters,” I don't know how closely those printers have to interact with the port hardware.
You can opt to enable access to other hardware devices, such as COM1: and LPT1: By default you do not have access to these ports. To enable this, you use the Win4Lin setup program (which runs under Linux). Here you can specify the ports you wish enabled, and also any desired mapping of the Windows drives. A convenient feature lets you save any setup as a named “configuration,” and then start that configuration with the +k option from the Linux command line.
For example, I enable COM1, COM2, LPT1, and some additional I/O ports for my embedded systems development tools. I've saved this configuration as “debug.” The command “win +kdebug” starts up Win4Lin in this “debug” configuration, all ready for my development tools. The command “win” uses the default (disabled) configuration.
Serial port. COM ports seem to be fully supported. Even some of my old DOS programs which directly access the port hardware work o.k. I've used Maxterm (DOS) and Hyperterminal (Windows) and had no problems.
Parallel port. LPT ports are also well supported. I have odd parallel-port devices such as EPROM emulators and JTAG interfaces that I use for embedded systems. So far all of these have worked without problems. The Win4Lin documentation says that bidirectional devices (e.g., dongles) are supported on the parallel port, but that DMA is not. (I've never had anything need DMA on the parallel port.)
Other ports. In my PC, I have a LeBurg EPROM emulator card that uses I/O ports 320-327. This is a truly nonstandard device! The Win4Lin setup program allowed me to add this device, by specifying the range of I/O ports, interrupts, DMA channels, and RAM locations that it uses. (In this case, only I/O ports.) This is a very welcome feature.
However, it doesn't work. There is no problem configuring the port, but when I load an application that attempts to use these ports, Win4Lin aborts and terminates the Windows session. (Note that this does not kill Linux, it just closes the Win4Lin window.) After several more prompt and courteous rounds with NeTraverse customer service, they've decided that this is a bona fide bug, and they've reported it to their development team. Pleasantly responsive, but it means that my device probably won't work until the next Win4Lin release.
My interest in Win4Lin was not to let me keep using all my old Windows software, but rather to let me use those specialized applications which aren't available (yet) under Linux. So, I haven't tested that many programs, and they've been a bit out of the ordinary.
Metrowerks CodeWarrior. I use this Integrated Development Environment daily for embedded programming on Motorola microcontrollers. I'm pleased to report that it works perfectly, including its use of the parallel port to communicate with the JTAG port on the Motorola chips for flash programming and debugging.
The CodeWarrior compiler has give me the only subjective judgment I have about Win4Lin's speed. I used to use CodeWarrior on a 166 Mhz Pentium with 64 MB of RAM running Windows 95. On my 400 Mhz Pentium II, with 192 MB of RAM, CodeWarrior under Win4Lin seems slightly slower. Roughly speaking, I'd estimate it's about the equivalent of a 100 Mhz Pentium running native Windows. This is quite acceptable to me, but others should be aware of this roughly 4:1 slowdown.
Adobe Acrobat 5.0. This works perfectly, although I haven't yet tested printing.
AMS EZ-Logic, EZ-Board, EZ-Symbol. I use these Computer Aided Design tools for electronics design and printed-circuit board layout. I've only tested them briefly, but they seem to work with no problem. The important test – printing – remains to be tried.
Ed For Windows (Ed4W). This is my preferred text editor for Windows, and it offers several features that I haven't seen yet in Linux editors. It works fairly well. One problem has appeared when the mouse is dragged “off the page” to select a range of text; the page scrolls down as expected, but when the mouse is moved back onto the page, the page keeps scrolling (and selecting more text). It seems that there is a lengthy time delay before it recognizes that the mouse is back on the page. So to select large blocks of text, I must use the keyboard functions (e.g. Shift-PageDown). Also, when I edit an existing file in Ed4W, it is re-saved with an all upper-case file name. But if I type a lower-case name in “Save As,” the case is preserved.
Maxterm. This is a DOS terminal emulator program that provides some additional downloading functions for some single-board computers I use. It works fine, although when the remote system generates a long text listing – such as when I dump a few hundred lines of memory – the Maxterm display freezes, and then suddenly blasts the whole text at full speed. I conjecture that there is some buffering going on, and that the DOS program is locked out while the buffer is filling. Certainly I don't have a similar problem with Hyperterminal.
Microsoft Word. I've just installed this, because I need to maintain someone else's Word documents and I don't entirely trust converting back and forth to OpenOffice. (Why do unnecessary document conversions?) It installed ok and seems to work ok, but I haven't had much time to try it out, and of course I haven't tried printing yet. But this is one of the “canonical” Windows applications that everyone uses as a benchmark, so I expect it has been thoroughly tested under Win4Lin.
I have been very favorably impressed with Win4Lin. The program installed easily and works well. The documentation is clear and the customer support is excellent. So far, I have found only one device that isn't supported under Win4Lin: an old EPROM emulator with a custom interface card, which is about the most unusual piece of hardware I've installed in any PC.