Adding Linux to a Windows 2000 (Win2K)- or Windows NT-based network can be a good idea. Linux provides an inexpensive way to implement basic Internet services (e.g., DNS servers, vanilla Internet mail servers, Web servers) on low-power hardware. Linux also offers excellent uptime and reliability, although at the cost of increased administrative complexity. (For information about the differences between administering NT and Linux, see "NT vs. Linux," March 2000, and "Linux: The Bad News," April 2000.)
But adding a new OS to any existing network can bring a fresh set of headaches in the form of interoperability questions. For example, you might wonder
- Can I run my Win32 applications on a Linux box?
- How do I keep Win2K or NT and Linux user accounts in sync?
- How do I transfer data between Win2K or NT servers and Linux workstations?
This month, I look at a tool that answers the third question. (In case you're wondering, the answer to the first question is yes: WINE, a free tool that ships with most copies of Linux, lets you run Windows programs under Linux. Regarding the second question, I've heard that some NT-Linux directory synchronization tools exist, but I don't know much about them yet.)
What You Need to Know
To help a Linux box access Microsoft file shares, you need to know three things. First, you need to know how to use the command-line commands smbmount and smbumount. Second, you must know how to create a new directory on your Linux system's hard disk. Finally, you'll make your life a bit easier if you also know how to create and use the configuration file smb.conf.
Smbmount, which is essentially the Linux version of Win2K and NT's Net Use command, connects your Linux box to a Microsoft file server. Smbumount breaks a connection to a Microsoft file server. Smbmount and smbumount started life as programs that someone (the documentation doesn't say who) created to let Linux boxes connect to Server Message Block (SMB)-based servers. (SMB is a message format that Win2K, NT, Windows 9x, NT LAN Manager—NTLM—and Windows for Workgroups—WFW—file servers use.) Since the commands' creation, they've become part of a large package named Samba, whose main task is to let you use a Linux box to mimic an SMB server—Linux in NT's clothing, you might say.
In this column, I assume that you're a Linux tyro (I know I am), so I include some basic instructions for navigating around a Linux box. (Experienced Linux or UNIX users whom I bore with the basics have my apologies.)
Smbmount needs a mount point, a local directory that smbmount can map the Win2K or NT network share to so that Linux knows how to refer to the share. Net Use, the command-line command to connect to a Win2K or NT share, maps a network share (e.g., \\myserver\myshare) to a drive letter (e.g., P). The benefit of calling a network share by a drive letter is to unify the look of the data that your Win2K, NT, or Windows system sees: All your data, even network shares, looks like local directories on your hard disk.
The Linux folks also want to provide a common look and feel for your data, whether it's sitting on a local hard disk or on a machine elsewhere on the network. But because Linux doesn't use drive letters, it needs some other method to blend network shares into the local-disk paradigm. Using a mount point is the means to that end. First, you create a new directory (a directory in which you don't actually store anything) on your Linux hard disk. Then, you tell smbmount to "glue" (mount) the network share onto that directory. From that point on, to access files on the share, you issue commands to access that directory.
To create a directory on a Linux box, you use the mkdir command. I created a directory on my system with the command mkdir /myntshare.
After you have a mount point, you use the smbmount command to connect to the Win2K or NT share. Suppose I want to access a share named data on an NT server named \\alnilam. Of course, I need an NT user ID and password so that I can access data. Let's say the username is usermark and the password is swordfish. I also need to know the server's IP address. We'll assume the address is 184.108.40.206. I can then map \\alnilam\data to the /myntshare directory with the command
smbmount //alnilam/data /myntshare U usermark I 220.127.116.11
(When you enter a Linux command, type the entire command on one line.) Notice that you use slashes (/), rather than using the customary backslashes (\), when you type the share's Uniform Naming Convention (UNC) name. Linux also uses slashes to separate parts of a file's location.
After I enter the command, the system displays a couple of lines of messages and requests my password. I simply type the password and press Enter, and I'm in. From this point on, I access the /myntshare directory to access files on the server. For example, to copy the abc.txt file from the NT server's share to the /localstuff directory on the Linux box, I'd type
cp /myntshare/abc.txt /localstuff
This syntax should look familiar—cp is Linux's Copy command.
The smbmount command has an extensive set of options, but in general, it looks like
smbmount <UNC> <mountpoint> U <username> I <ipaddress>
where UNC is the UNC name of the share you want to connect to, mountpoint is the directory you want to attach the share to, and username is the NT user account name. The options are case sensitive: You must use uppercase I and U, and you must type the command and parameters in lower case.
The -I option is important because smbmount doesn't seem to know how to find the NT server by doing NetBIOS name broadcasts. As I explain later, smbmount can use a WINS server to look up a server's address, but if you haven't told smbmount about WINS and don't specify an IP address, smbmount will not only fail but won't let you use the mount point until you reboot the Linux box.
Configuration File Smb.conf
To tell smbmount about the WINS server, you must create an ASCII file called smb.conf. Linux usually stores this file in the /etc/ directory (if you want to sound like a Linux expert, pronounce /etc/ as ET-see). Some Linux implementations modify that storage location. For example, I verified everything in this column on systems running Red Hat Linux 6.1, Linux Mafia's Slackware Linux 7.0, Caldera Systems' OpenLinux 2.3, and Corel LINUX. (A fifth distribution, SuSE Linux 6.3, didn't activate the Ethernet card for some reason, so I couldn't test that distribution.) Red Hat Linux and Slackware put smb.conf in /etc/, OpenLinux puts the file in /etc/samba.d/, and Corel LINUX puts it in /etc/samba. Red Hat Linux and Corel LINUX install a basic smb.conf file when you put the distribution on your computer; Slackware and OpenLinux do not, installing instead a file named smb.conf.sample that you must modify and rename to smb.conf.
You need only two lines in smb.conf:
\[global\] wins server = <ipaddress>
Because smbmount reads smb.conf every time you invoke the command, you don't need to restart services or reboot. If alnilam's local WINS server's IP address is 18.104.22.168, I'd put the following lines into smb.conf on the Linux box, probably in /etc/:
\[global\] wins server = 22.214.171.124
Then, to connect, I'd type the command
smbmount //alnilam/data /myntshare U usermark
After I enter my password at the prompt, I can access the share. Alternatively, I can follow the username with a percent sign and the password so that the command doesn't need to prompt for a password:
smbmount //alnilam/data /myntshare U usermark%swordfish
If you're not comfortable using Linux's workhorse text editor vi to create smb.conf, you can either create the file with one of the GUI editors that ship with Linux or use the following variation of an old DOS trick. First, type
cp /dev/tty /etc/smb.conf
and press Enter. This command tells Linux to copy data that you enter at the keyboard—the stuff you're about to type—to a file named /etc/smb.conf. After you carry out that command, everything you type goes into the /etc/smb.conf file; Linux doesn't try to interpret what you type. To tell Linux that you're finished, you press Ctrl+D. Although you can't edit a mistake on a previous line when you use this trick, it gives you a quick-and-dirty way to create a new file.
To see the file you just created, type
(The cat command is Linux's Type command.) Conveniently, you don't have to create smb.conf if you're running Corel LINUX. If the Corel box gets its IP information from a DHCP server, Corel LINUX automatically puts your WINS server's address into smb.conf.
After you've finished working with a share, you disconnect it with the command smbumount mountpoint. So, I'd type
Here are a few notes you'll find useful. First, as I mentioned, you'll see variations between different Linux distributions. Red Hat Linux and Corel LINUX's smbmount commands were the easiest to set up, and OpenLinux's smbmount command was the second easiest. But I couldn't make Slackware's smbmount command work, even after I reformatted the hard disk and reinstalled Slackware and every feature it offered. Linux vendors update their distributions so often, however, that by the time you read this column, the versions of Corel LINUX, Red Hat Linux, and OpenLinux that I used might be broken and Slackware might be the hero of the moment.
Additionally, smbmount seems unable to handle the soft disconnects that NT typically performs after 15 minutes of inactivity: Walk away from a Linux system connected to an NT box for a while, and when you come back and try to access the NT share, you might get a broken-pipe message and be unable to unmount the share. So, you might want to unmount connections that will be inactive for any time at all.
Smbmount and smbumount have many other options (as is often the case with Linux and UNIX commands). To see the options for smbmount or smbumount, go to a Linux command prompt and type