Published on (
 See this if you're having trouble printing code examples

FreeBSD Basics

Running Windows Applications on FreeBSD


Also in FreeBSD Basics:

Fun with Xorg

Sharing Internet Connections

Building a Desktop Firewall

Using DesktopBSD

Using PC-BSD

In the last article, we looked at using VNC for accessing other desktops in a network. This week, I'd like to continue in this vein by looking at running Windows applications from within your FreeBSD system.

One of the neatest things about FreeBSD is that if it is running on a dual-boot computer, you don't have to exit FreeBSD to access data contained on the other operating system's partition. It is a simple matter to mount the other partition and to then read, write, or even delete the files contained on that partition. Ah, but what about running executable files, you may ask? If that other operating system is made by Microsoft and you're running the Windows emulator (Wine) on your FreeBSD system, it is possible to run many Windows applications from your FreeBSD system.

In today's article, I want to demonstrate building and using Wine. If things go well, I'll push my luck by also attempting to run some Windows applications on a computer totally dedicated to FreeBSD -- it does not contain a Microsoft partition anywhere on its hard drive.

I'll start by building the Wine port on two of the machines in my network. The first machine dual-boots Windows 98 and FreeBSD 4.3-Release. The second machine has been totally and dangerously dedicated to FreeBSD 4.3-Release. I'll become the superuser and start the port's build on each machine:

cd /usr/ports/emulators/wine
make install clean

Once the builds are finished, I need to check each machine's kernel configuration file to ensure it contains all of the options needed to run Wine. While still the superuser, I'll type:

cd /usr/src/sys/i386/conf

I'll then use my favorite text editor to open up WINE and ensure that the following options are listed:

options		USER_LDT
options		SYSVSHM
options		SYSVSEM
options		SYSVMSG

On my 4.3-Release, the three SYS* options were already there, I only had to add the USER_LDT option. If you have to add any options, save your changes and recompile the kernel like so:

/usr/sbin/config WINE
cd ../../compile/WINE
make depend && make && make install && reboot

With that last command, I'm actually invoking four separate commands; the && ensures that the next command will only be run if the previous command was successful. If you decide to include the reboot command, make sure that no other users are doing anything on your FreeBSD box as it will reboot once the kernel has been installed.

When the Wine port is built, documentation is installed into man 1 wine and /usr/local/share/doc/wine. I also found the how-to article to be very helpful in setting up Wine for the first time.

Let's start by trying to run Wine on the system that dual-boots FreeBSD 4.3-Release and Windows 98. To run Wine on this machine, I'll have to:

  1. Find and mount the Windows partition.

  2. Double-check Wine's configuration file.

  3. Test the configuration by seeing if I can run a Windows application.

It's been a while since I set up this computer, so I'll use sysinstall to double check my partitioning scheme. As the superuser:

spacebar ad0

and I see something that looks like this:

Offset		Size(ST)	End	Name	PType	Desc
       0              63         62        -       6   unused
      63         4176837    4176899    ad0s1       2      fat
 4176900         4016250    8193149    ad0s2       3  freebsd 

When I'm finished, I use q to quit this screen, and cancel my way out of sysinstall. It looks like Windows is on the fat partition known to FreeBSD as ad0s1. In order to mount this partition, I first have to create a mount point which I'll call dos:

mkdir /dos

I should also check the permissions of the mount point:

ls -l  / | grep dos
drwxr-xr-x  2 root  wheel   512 Aug 31 13:07 dos

This looks good as all users have "read" and "execute" permissions, but only the root user has "write" permission.

Before adding a permanent mount entry to /etc/fstab, I'll ensure that I can first manually mount that partition without any errors:

mount -t msdos /dev/ad0s1 /dos

Note that I specified the filesystem type with -t msdos, the partition's name with /dev/ad0s1 and the mount point with /dos. Because I just received my prompt back, the mount was successful -- I can verify this with the df command:

df -h
Filesystem   Size   Used  Avail  Capacity  Mounted on
/dev/ad0s2a   97M    36M    53M    40%     /
/dev/ad0s2f  1.7G   567M   1.0G    35%     /usr
/dev/ad0s2e   19M   2.0M    16M    11%     /var
procfs       4.0K   4.0K     0B   100%     /proc
/dev/ad0s1   2.0G   783M   1.2G    38%     /dos

I can also verify the contents of the mounted partition using ls; I'll include the F switch so I can tell the directories from the files as the directories will be followed by a /.

ls -F /dos

BOOT.INI*       CONFIG.SYS*     My Documents/   SETUPLOG.TXT*
bootsect.bsd*   IO.SYS*         Program Files/  RECYCLED/*   ntldr*

If you've never mounted another operating system's partition before, you may want to take a few minutes to get used to cd-ing and ls-ing the contents of that partition from your FreeBSD prompt. Take note that many of the files are in uppercase -- when you wish to access a file, type it in exactly as it appears as FreeBSD is case sensitive. Also, some files have spaces in them. To access these files, you can either start to type in the name and then use your tab key to auto-complete the name, or else use a backslash to escape the space like so:

cd Program\ Files

If you want to have your Windows partition mounted for you at boot time, carefully add the following line to your /etc/fstab file:

/dev/ad0s1	/dos	msdos	rw	0	0

Make sure that you use the right partition name as yours may not be ad0s1 like mine is. Double-check that you don't have any typos before saving your changes. I always like to ensure that my changes to /etc/fstab worked, so I'll test it by typing:

shutdown now
press enter when receive prompt back, then type

Once you've logged back in you can ensure that the partition is mounted by repeating the df -h command.

Now, let's edit the Wine configuration file. Use your favorite text editor to open up /usr/local/etc/wine.conf. Since the default configuration file usually doesn't require any changes to work, I've snipped most of the output to just show the bit you may have to change to match your configuration:

more /usr/local/etc/wine.conf
;; All keys relative to \\Machine\\Software\\Wine\\Wine\\Config
[Drive A]
"Path" = "/mnt/fd0"
"Type" = "floppy"
"Label" = "Floppy"
"Serial" = "87654321"
"Device" = "/dev/fd0"

[Drive C]
"Path" = "/c"
"Type" = "hd"
"Label" = "MS-DOS"
"Filesystem" = "win95"

Let's stop here as this is the part that needs to change. Replace the /c in the Path line with the name of your mount point. Since I called my mount point /dos, I changed this line to read:

"Path" = "/dos"

Save your change. I've found that this file needs to be copied to the user's home directory in order for Wine to work. Still as the superuser, I'll do the necessary changes in the user genisis' home directory:

mkdir ~genisis/.wine
chown genisis ~genisis/.wine
cp /usr/local/etc/wine.conf ~genisis/.wine/config

Note that I renamed the configuration file to config when I copied it into genisis' .wine directory. At this point, I'll exit the superuser account as my configurations are finished. As the user genisis, I'll fire up an XWindows session:


Once I'm in, I'll open up an xterm window and look for a Windows application to execute:

cd /dos/WINDOWS
ls | more

I notice PROGMAN.EXE and am intrigued as that is the Windows Program Manager. I'll see if I can get it to work from FreeBSD using Wine:

wine -winver win98 -managed PROGMAN.EXE

After a few seconds, I'm greeted by Program Manager. Clicking on the File menu, I select the "Run" option and then click on the Browse button. I'm greeted by a list of all of the programs running on my Windows partition.

Now the fun begins as I use trial and error to see which applications I can get to run. I'll start with Windows Calculator, so I'll click on CALC.EXE and press the Open button, then the OK button. And, voila, I'm using Windows Calculator. You could easily while away an afternoon testing each application to prove to yourself which ones work. Or, you could do a search at either of the following sites:

Wine Development HQ
CodeWeavers Wine Application Database

The first site currently has 2,704 applications which have been tested with Wine. The second site has a much more user-friendly layout, but is still a work-in-progress.

Now, let's try something a little more interesting. I'll become the superuser and see if I can build and then run a Windows application using Wine. To find an application, I'll head over to

I'll click on the link for the "most popular" games and Solsuite 2001 sounds promising: 282 unique solitaire games. I download the executable which is called solsuite.exe and save it to /dos.

Returning to an xterm:

cd /dos
wine -winver win98 -managed solsuite.exe

And I receive an error message about a missing .wine directory. Let's make that directory and copy over the configuration file for the superuser:

mkdir ~/.wine
cp /usr/local/etc/wine.conf ~/.wine/config

Now when I repeat the wine command, the installation wizard for the program begins. I follow through the prompts and watch as the files are copied over to their correct destinations. At the very end, the install appeared to hang, but it said that there was 0 minutes, 0 seconds remaining. I took my chances and used a ^c to end the install. Then I typed:

cd Program\ Files/SolSuite
wine -winver win98 -managed Solsuite.exe

And it's time to phone up the neighbors and show off. I've successfully installed and run a Windows application from FreeBSD and renewed my interest in card games in the process.

As a final test, I'll reboot this computer into Windows 98. I'll click on the Start menu, "Programs", and I see a new entry for "Solsuite-Solitaire Card Games," but it's empty. Not to be deterred, I go into Explorer and double-click on "Program Files" then "SolSuite" and I see all the executables which is a good sign. I then double-click on the Windows folder, Start Menu, "Programs", and "Solsuite", and use my right mouse button to drag SolSuite.exe into this folder. Doing this will give me a menu where I'll choose to "Create Shortcut Here".

I'll now return to my Start button, "Programs", "Solsuite", and "Shortcut to SolSuite", and I'm again prompted to choose my favorite card game. I'm impressed.

Now for the ultimate challenge. I'll move over to the computer that is totally dedicated to FreeBSD. Its hard drive is completely formatted with UFS and there are no Windows files on this computer. I'll start by becoming the superuser and creating some directories and empty files which Microsoft applications expect to see:

mkdir -p /usr/local/lib/win/windows
cd /usr/local/lib/win/windows
mkdir system
touch win.ini
cd system
touch shell.dll shell32.dll winsock.dll wsock32.dll

Remember how we had to change that one line in /usr/local/etc/wine.conf so it pointed to the mount point? I'll want to edit that line again, but this time I want it to point to my "fake" Windows directory structure like so:

[Drive C]
"Path" = "/usr/local/lib/win"

I'll then create the proper directories and copy over the configuration file for both the superuser and the user genisis;

mkdir ~/.wine
cp /usr/local/etc/wine.conf ~/.wine/config
mkdir ~genisis/.wine
chown genisis ~genisis/.wine
cp /usr/local/etc/wine.conf ~genisis/.wine/config

Still as the superuser, I'll go back to and download the executable for Solsuite 2001, this time saving it to /usr/local/lib/win. I'll then startup an XWindows session, open up an xterm window and type:

cd /usr/local/lib/win
wine -winver win95 -managed solsuite.exe

Again, the installation program does its thing. I receive an error message about not being able to find Explorer.exe, but I ignore it. When it's finished, I then type:

cd Program\ Files/SolSuite
wine -winver win95 -managed SolSuite.exe

It's a bit slow (but this is an older computer) and I have to tweak my display settings, but I'm playing a Windows card game on a box totally dedicated to FreeBSD. A person could get a bit giddy indulging in the Wine.

It looks like Wine is one of the FreeBSD ports that you could have a lot of fun with. If you experiment with it and find an application that works but isn't listed yet in the database, submit your entry to one of the sites I mentioned in this article.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.

Read more FreeBSD Basics columns.

Return to the BSD DevCenter.

Copyright © 2009 O'Reilly Media, Inc.