Chapter 12. Windows Compatibility and Samba
Linux is a remarkably effective operating system, which in many cases can completely replace MS-DOS/Windows. However, there are always those of us who want to continue to use other operating systems as well as Linux, or at least to exchange files directly with them. Linux satisfies such yearnings with internal enhancements that allow it to access foreign filesystems and act on their files. It can mount DOS/Windows partitions on the system's hard disk, or access files and printers shared by Windows servers on the network. Linux can also run DOS and Windows applications, using compatibility utilities that allow it to invoke MS-DOS or Windows.
We use the terms MS-DOS and Windows somewhat generically in this chapter to refer to any of the DOS-based operating systems coming from Microsoft or those compatible with them. These include MS-DOS, PC-DOS, and DR-DOS/Novell DOS (all with or without Windows 3.x running on top of them), as well as the various Windows versions themselves, no matter whether they build upon a separate DOS installation, such as Windows 3.x, or whether they have a DOS kernel built in, such as Windows 95/98/ME. Windows NT/2000/XP are different, and some of the things described here will not work with them, or will work differently.
One of the most common reasons for needing to run Windows is that it often has better support for new hardware products. If you have installed Windows because you need to use a piece of hardware that is supported by Windows, but for which there is no Linux driver, do not despair. Although you may have to wait a while for it, most mainstream hardware devices that are supported by Windows will eventually be supported by Linux, too. For example, Linux drivers for USB devices used to be rare and flaky, but now many common USB devices work just fine on Linux. You can get updated information about which USB devices work on Linux at http://www.linux-usb.org.
You may also need to run Windows in order to use "standard" applications, such as Photoshop or Microsoft Office. In both of these cases, there are free, Open Source applications (namely, The Gimp, KOffice and OpenOffice) that can match or even outdo their proprietary, closed-source equivalents. However, it is still sometimes necessary to run Windows to obtain access to software products that have no Linux equivalent, or for which the Linux counterpart is not fully compatible.
There are essentially four ways in which Linux and Windows can cooperate:
When Windows and Linux are running on separate hardware, and the systems are not networked, a floppy disk or CD (either CD-R or CD-RW) can be written on one system and read on the other. Both Windows and Linux have the capability to read and write CDs in industry standard, ISO9660 format. The cdrecord program, which runs on Linux and other Unix flavors, can create CDs using Microsoft's Joliet extensions to the ISO9660 standard, making Windows feel right at home with the disc format.
Although floppy disks hold much less data than CDs, they can be useful when just a few small files need to be transferred. Data can be shared between Linux and Windows on MS-DOS formatted floppy disks using the MTools utilities described later in this chapter.
A more cost-effective approach is to install both Windows and Linux on the same computer, each in their own disk partitions. At boot time, the user is given the choice of which operating system to run. Section 5.2 in Chapter 5, tells you how to configure a multiboot system.
MTools can be used to access files on the Windows partition while running Linux, but a much more convenient method is to mount the Windows partition directly onto the Linux file system. Then Windows files can be accessed similarly to regular Unix files.
For networked computers, the most outstanding tool for getting Linux and Windows to cooperate is Samba, an Open Source software suite that lets you access Unix files and printers from Windows. Linux servers running Samba can — depending on the circumstances — serve Windows computers even faster than Windows servers can! In addition, Samba has proven to be very stable and reliable.
The Samba package also includes programs that work with the smbfs filesystem supported by Linux, which allows directories shared by Windows to be mounted onto the Linux file system. We'll discuss the smbfs filesystem and Samba in enough depth to help you mount shared directories and get a basic, functional server running.
Finally, there are methods that can be used to directly run Windows applications under Linux, or even run Windows itself. Wine is an Open Source project with the goal of directly supporting Windows applications, without needing to install Windows. Another approach is used by the commercial VMware application, which is able to concurrently run a number of installations of Windows, Linux, FreeBSD or some other operating systems. When running Windows under VMware, data is shared with the Linux host using the Samba tools.
You should be a little skeptical of some claims of compatibility. You might find, for example, that you need twice the disk storage in order to support two operating systems and their associated files and applications programs, plus file conversion and graphic-format conversion tools, and so on. You may find that hardware tuned for one OS won't be tuned for the other, or that even when you've installed and correctly configured all the necessary software, small unresolvable compatibility issues remain.
12.1. Sharing Disks with MTools
The MTools package is a collection of commands that let you manipulate files and directories on one or more MS-DOS disks. The commands work similarly to commonly-used MS-DOS commands, although there are significant differences that take a little getting used to.
The file /etc/mtools.conf is used to conjure MTools, and you will probably find it already set up to identify your primary and secondary floppy disks as the MS-DOS A: and B: drives:
drive a: file="/dev/fd0" exclusive 1.44m mformat_only drive b: file="/dev/fd1" exclusive 1.44m mformat_only
drive c: file="/dev/hda1"
When adding this line, use the filename corresponding to your MS-DOS partition instead of /dev/hda1. Be very careful to use the correct partition of your disk. If you make a mistake, you could very easily destroy an entire Linux partition, or other valuable data.
Occasionally, you will encounter a floppy disk that is not MS-DOS formatted. To use the floppy, you will first need to low-level format it using the fdformat command, which is not part of MTools. Then, you can use the MTools mformat command to put a FAT and directory structure on the floppy:
$ fdformat /dev/fd0 Double-sided, 80 tracks, 18 sec/track. Total capacity 1440 kB. Formatting ... done Verifying ... done $ mformat a:
$ mdir a: Volume in drive A has no label Volume Serial Number is 4077-6090 Directory for A:/ No files 1 457 664 bytes free
$ mcopy /etc/hosts a: $ mdir Volume in drive A has no label Volume Serial Number is 4077-6090 Directory for A:/ hosts 948 10-02-2002 19:28 hosts 1 file 948 bytes 1 456 640 bytes free
The file on the floppy can be read by any MS-DOS or Windows system. The above examples give you a basic idea of how the MTools utilities work. The mcopy command is typical in that it can accept either MS-DOS or Linux filenames as arguments, and performs the copy operation accordingly. Some other useful MTools commands are mmd, to create a directory, and mcd, to change directories. When you use mcd to change your working directory on an MS-DOS disk, the MTools utilities keep track of the working directory, to simulate the normal MS-DOS behavior. For example, consider the following command sequence:
$ mmd a:dir1 $ mcd a:dir1 $ copy c:file1 a: $ mdir a: Volume in drive A has no label Volume Serial Number is 4077-6090 Directory for A:/dir1 . <DIR> 10-02-2002 19:42 .. <DIR> 10-02-2002 19:42 file1 TXT 948 10-02-2002 19:50 file1.txt 3 files 948 bytes 1 454 080 bytes free
The result is that file1.txt on the C: drive is copied to the dir1 directory on the A: drive, and the mdir command shows the contents of A:\dir1. If you are not used to using the MS-DOS/Windows command shells, be careful of this, because it is different from standard Unix behavior.
Notice in the above directory listing that the directory name is printed as A:/dir1, using a forward slash instead of a backslash. This is your clue that when using MTools utilities, you must use a slash do specify directory paths, such as:
$ mdel c:/dir1/dir2/readme.txt
Also, the MTools commands use a dash instead of a slash to specify options. For example, to print a concise listing of the A: drive, we can use the following command:
$ mdir -b a: A:/hosts A:/dir1/ A:/file1
Copyright © 2003 O'Reilly & Associates. All rights reserved.