|
|
|
Sharing FloppiesCopyright © 1999 Sue BlakeIn a previous month we looked at the normal way to use floppy disks, by mounting them. Now we're going to get really fancy. Don't worry, it's fun, and we'll be cheating all the way. This month's column is largely aimed at new *BSD users who have at least a little background in another PC or Macintosh operating system, maybe still use that system occasionally, or exchange files with poor cousins whose OtherOS computers are not networked. It also offers some backup methods using floppy disks for small amounts of data. These methods should not be seen as a substitute for normal backups, but as an additional convenience in some situations. We're going to cheat by using mtools to avoid the mounting and unmounting ritual, by using Info-ZIP's free zip and unzip programs to make archives that almost anyone can extract, and by getting either mtools or Info-ZIP programs to convert text files between Unix format (line feed only) and DOS format (carriage return and line feed) with almost no extra effort. If you want to work through this as we go, start by installing mtools, zip, and unzip from the packages collection. This week I had to prepare four floppy disks:
Diskette 1We'll see later how zip can be used to make exchanging files easier, but right now my poor cousin running Windows95 hasn't got the zip programs or any way to get them except on a floppy in the post. I had to download the files and transfer them to floppy disk for him. Then I noticed that one of the files had to be converted to DOS text so that he could read it easily, and mtools was the obvious choice. mtools lets you access a floppy disk using commands that
are similar to ordinary DOS commands:
What I did in this case was to start from the directory where the files had been downloaded, and type: # ls
The first file copies over with a command almost the same as in DOS, except for the little 'm' at the beginning. I changed the name of the second file, gave it a .TXT extension, because that might increase the chances of Windows seeing the file and recognising it as readable. I suspect he'll try to use his word processor, so I made a second copy with a .DOC extension so that the disk would not appear blank from within Word. Notice the -t in the last two commands? That tells mtools that the file is to be treated as a text file. When copying to a floppy, mtools will change each line ending from a line feed to a carriage return and line feed pair. When copying text files off a floppy, the -t will cause mtools to remove carriage returns, leaving just the line feeds, making it a normal unix text file. To check that the files are safely transferred, it's the almost-familiar command: mdir a: Diskette 2There's no point asking mtools to convert text files to DOS text for a Macintosh, since both file types are equally wrong for them. Mac users can cope with seeing a strange blob at the end of each line of text as well as anyone can, but it only takes a few seconds to make their README pleasant to read: # tr '\n' '\r' <README >Readme
Then it's simply a matter of copying the whole directory (both files) to the DOS-formatted floppy disk with mtools. # mcopy * a:
Most Macintoshes, even old ones, come with software to read DOS floppies. Be aware, though, that the most ancient Macs might have a floppy drive that can't read 1.44MB disks, and some recent Macintoshes have no floppy drive at all. Diskette 3Here I just want to put a whole lot of text files on a floppy for someone who I exchange files with frequently. He uses an early version of DOS and WordPerfect 5.1 because they serve his purposes well, and he is used to handling DOS text files and zip archives. When it's just a few files, I could put them in a directory and do:
mtools stores long filenames so that recent MS-Windows systems see the full name, while DOS before version 7 sees the old 12 character (8.3 style) names, often appending ~1 to truncated names. The files will be quite accessible like this, just not real pretty. There are a few reasons why it might be better to make a zip archive of the files before placing them on the disk. The obvious reason is that it takes less space. It is less well known that Info-ZIP can change text file formats and filenames while it is compressing or extracting archives. The basic command to create an archive (the same for DOS or Unix) is zip archivename.zip filenames, so to archive all files in the current directory to a zip file on floppy it would go: $ zip jokes.zip *
Of course the zip archive is a binary file, and the text files inside it are stored as Unix text files. A floppy disk prepared this way could be sent to someone using a different operating system who was willing, able, and equipped to list the contents and extract the files with the right commandline switches to convert the text files. Generally it is safer and more friendly to do any text conversions at the packing end, which we'll look at below. This kind of floppy could be kept as a backup of a small number of personal text and/or binary files, in a format that could also be accessed on a Microsoft (or other) system in case of emergency. The archives could be transferred to the other system's hard disk for convenient storage, keeping the diskette as a second backup, as we'll see for Diskette 4 below. For this DOS user's diskette, let's get zip to convert the text files
as it packs them, so that the recipient only needs to type
$ zip -kl jokes.zip *.txt *.html
The first command creates the zip archive called jokes.zip and adds all of the
files ending with .txt or .html in the current directory. At the same time it
converts those files from Unix text to DOS text (-l) and makes their filenames
more reasonable for a DOS user (-k). This floppy disk and zip archive would be suitable for users of many other systems, including MS-Windows, Macintosh, Linux, and OS/2. Diskette 4The last diskette is going to be an easy job: making an extra backup of the /etc directory in a less platform dependent form, suitable for study and reference. All this needs to be is a plain zip file on a floppy disk. Most of the files that need extra careful backing up are in the /etc directory. A fairly common way to take a quick additional backup of /etc at the time of system changes is to tar and gzip the directory to a floppy disk, and/or store that archive on another machine. What happens, though, if you need to use another operating system to access the backed up files? Perhaps you'll need to use another machine in order to print some of the files, or maybe your *BSD system isn't up and you need to check some old settings. If you hunt around you can probably find tar and gzip for other platforms, but how often would the machine owners use it? Zip, on the other hand, is more likely to be installed or appreciated. I keep a copy of the DOS executable of unzip on my FreeBSD system, and copy it to these floppies whenever there's free space. You can get carried away if you're not careful. It's surprising how many small things can fit on a DOS floppy. The zip and unzip programs fit comfortably on a bootable DOS floppy disk along with a zip archive containing the contents of /etc and and all of its subdirectories, plus a couple of small DOS utilities to read and edit files and a tiny DOS modem communications program (RBComm). This makes a nice pocket sized travelling companion for remote access and peace of mind. Here's how to make and copy the zip file:
# zip -r etc-r.zip /etc
The first command makes a zip archive of all the files in /etc and in its subdirectories, including the directories. When this file is unzipped, by default it will create a directory called ./etc, and its subdirectories, and fill them with the restored files. Note that the text files are not changed, just stored. They could be converted during unzipping if that were ever necessary. The second command tests the zip archive. It's easy to do, and a wise precaution for all zip files, not just important ones. The last three commands simply copy the files to the floppy disk and list the disk's contents, as we've seen before. Note that here the zip file is prepared as root, which is not necessarily a good idea. If you do it from a normal user login, zip will report that it cannot read some files but will put most of them into the archive. The advantage of being root is that you get all the files, but the disadvantage is that you end up with an archive that almost anyone can read which contains files which nobody except root should ever see. I might do it this way immediately before an upgrade, for example, make two copies of the diskette, keep it away from any networked machines, and either destroy the backup archive afterwards or keep it on the hard disk with root-only permissions. A simple zip archive to floppy disk has other uses. Recently I was using *BSD tools to edit a three megabyte RTF file which held years of work of a research team. As well as using RCS and normal system backups, I made a zip file and copied it to a new floppy disk each day. Some of these disks were kept in another room, some were mailed to head office, and some sent as zip files attached to an email. The zipped archive was only a few hundred kilobytes, and though the floppy disks are not reliable enough for the sole means of backup, they are cheap and easy to store and transport. These DOS formatted diskettes could be accessed by almost anyone anywhere, because DOS diskettes are widely understood and the archives were made using "the third most portable program in the world". This month we've looked at mtools for easy copying of files to DOS formatted floppy disks, and Info-ZIP for archives which can be used on almost any platform. We've also seen how each of these programs can be used to help transform text files for easy exchange between different operating systems, and how all of these can be combined for additional backups and convenient storage and sharing of data. More about the softwareIt's always best to install the package or port that has been prepared for your *BSD version. We should see new versions of Zip and Unzip coming out around the time of this article. Don't worry too much. The older versions have been working well since 1997 and will continue doing their job well into the future. A single GUI program does zipping and unzipping for Win32 (called "WiZ"), and Macintosh (late beta at time of writing), but for other platforms zip and unzip are two distinct programs with different version numbers. The URLs below offer downloads and more information about the software mentioned. Also look for man pages, Info documents, and especially FAQs. Type zip or unzip alone at the commandline (Unix, DOS or OS/2) for a quick list of the most important options.
Sue Blake, sue@welearn.com.au
|
||