Red Hat Linux 7 Unleashed

Red Hat Linux 7 Unleashed

By William Ball

Using Samba as a Linux Migration Tool

Some computer users want to migrate completely to Linux, leaving Windows behind. For such users, Samba is an indispensable migration tool. This discussion assumes the user has separate Windows and Linux boxes, network connected, and the Linux box is running Samba.

The first step is to decide the structure of your data tree on the Linux box. For backup and tracking purposes, many consider it best to have all real data in the data tree, leaving the home directory for temporary work. An excellent plan is to put all data under a directory called /d, and place all data accessed exclusively with Windows-based programs in subdirectory /d/w.

The next step, and it's absolutely vital to do this before transferring any files, is to have a working backup system for the /d tree. See Chapter 22, "Backup and Restore."

Creating the Data Directory Share

Now the first step of the transition is simply moving data files to directories under the /d/w directory, and accessing them via Samba with the same Windows programs as always. The Samba share for /d looks like this, assuming it's to be used only by user myuid:

[d]
comment=Linux Data Directory
path=/d
writeable=yes
valid users=myuid

Naturally, in the preceding example the /d directory should be owned by myuid, and the file mode of /d should be 0700. Slightly more complex is the situation in which several people need to access and modify the files. In such a case, add all such people in a group (let's call it hometeam). Make /d owned by root with group hometeam and make the file mode for /d 770. Now anyone from group hometeam has total access to the directory. Next, create the [d] share as follows:

[d]
comment=Linux Data Directory
path=/d
writeable=yes
valid users=@hometeam
force group=hometeam
create mode=660
directory mode=770
oplocks=no

In the preceding share definition, anyone in group hometeam, but nobody else, can access the share through Samba. The force group=hometeam statement sets the group to hometeam for files newly created through Samba. Otherwise, each file's group would be set to the primary group of the user that created the file. Thus, the force group= hometeam line enables different users to edit each other's files.

The create mode=660 sets the mode on files created through Samba to 660 so anyone in the file's group (which of course was set to hometeam by the force group=) can read and write the file. The directory mode=770 is done for similar reasons.

Finally, the oplocks=no prevents on-client caching. This is desirable if and only if files are expected to be edited on both the server and the client, because doing so with on-client caching would create corruption. In a Windows-to-Linux transition, it's very likely that files will be edited on both sides.

The Early Transition

The earliest part of the transition is simply moving data from the Windows hard disk to the /d/w directory, and accessing it using the same programs as always. This data migration needn't be done in a single step, as long as there's an organized method to keep track of what has and hasn't been moved. It might be tempting to leave copies of the original files in the original Windows directory, but this practice would lead to a version control nightmare. Instead, keep Windows copies under something like a c:\moved directory. Once you're confident that the files on the Linux side are correct and are being regularly backed up, you can delete their Windows hard disk counterparts with confidence.

The next step is to edit the data with Linux programs. For instance, you might use Gimp instead of Paint Shop Pro to edit .jpg files. Once you start editing some of a directory's files using Linux-based software, it's best to move it to an appropriate directory under /d, rather than /d/w.

Eliminating Those Pesky DOS Carriage Returns from Text Files

In text files, DOS and Windows delineate lines with a carriage return line feed combination (CRLF). Linux (and all UNIX and UNIX workalikes) use only a line feed (LF). Before working on a text file on the Linux box, you should convert it to the Linux line feed–only format. The following is a simple script to convert DOS format files to UNIX format:

#!/bin/sh
while [ $1 ]; do {
        echo Converting $1
        cp $1 $1.dos
        touch -r $1 $1.dos
        cat $1.dos | sed s/^M$//g > $1
        touch -r $1.dos $1
        shift
}
done

The preceding script works on single files and on wildcards. It converts each file from DOS to UNIX file format, keeping a backup (which gets overwritten the next time the script runs) as a .dos file, and retains the original file date and time due to the touch commands.

The Migration Endgame

Once you've begun using Linux programs to edit your data, you might notice that it's inconvenient to continually move from one computer to the other. VNC to the rescue. VNC is a GUI-aware remote access program similar to PC-Anywhere, except that it works on Windows, Linux, UNIX, and most UNIX workalikes.

By running VNC server (WinVNC.exe) on your Windows box and vncviewer on your Linux box, you can operate your Windows box from your Linux box, and never need to switch chairs (unless you need to insert a CD, power down, and the like). The vncviewer program comes ready to run on your Linux box, and you can download the Windows VNC server from http://www.uk.research.att.com/vnc/index.html. Install the Windows VNC server per the downloaded instructions, and then to access the Windows box from your Linux box, simply execute the following command in a GUI terminal on the Linux box:


   $ vncviewer 192.168.100.5:0

The preceding command assumes the Windows box is at 192.168.100.5. You're asked to enter the same password you configured on the VNC server on the Windows box, after which your Linux box appears to "turn into" a Windows box. Be sure to use the F8 key to view the popup menu, from which you can toggle full screen mode, send an F8 character to the Windows app, send a Ctrl+Alt+Delete to the Windows machine, and other handy tricks.

There's more information on setting up VNC in Chapter 28, "Emulators, Tools, and Window Clients," and at http://www.troubleshooters.com/tpromag/200006/200006.htm#_vnc, and detailed VNC information at http://www.uk.research.att.com/vnc/index.html.

Share ThisShare This

Informit Network