Backing Up In Linux

by Yusuf Nagree

There are currently three main types of tape drives available for the PC (and hence Linux). There are those based on SCSI interfaces, those based on the floppy drive interface (QIC-40, QIC-80, QIC-117, QIC-3010 and QIC-3020), and QIC-02 type drives. A new breed of tape drives that attach to the IDE interface is coming, but at the moment, Linux support is minimal. There is no Linux support for drives that attach to the parallel port.

You cannot simply attach a tape drive to your machine and expect Linux to automatically recognize it. You need to tell the kernel about it, and this can involve recompiling the kernel. In addition, you need entries in your /dev directory so that programs under Linux can access the tape drives.

Below, I will describe how to set up the two most common types of tape drives.

Floppy Interface Tape Drives

Tape drives that connect to the floppy drive interface have the advantage that no separate interface card is required; they are, therefore, fairly cheap and reliable. Thus, this breed of tape drive has been very popular.

One of the first tape drives of this type was the Colorado Jumbo 250. The tape drive cable for these drives attaches to the floppy drive interface. The QIC-80 specification defines how to access these tape drives. Many other tape drives, including the Iomega 250, Conner C250MQ, Wangtek 304, and Colorado Jumbo 350 are QIC-80 compatible.

Tape drives that use the QIC-80 specification require a program (actually, a “Loadable Kernel Module”) called ftape, written by Bas Laarhoven and Kai Harrekilde-Petersen, which at the time of writing is at version 2.03b. QIC-117 and QIC-40 formats are also supported by ftape, as is QIC-3010 and QIC-3020 (i.e. QIC-WIDE) in an experimental form. A complete list of tape drives supported by ftape can be found in the vndors.h file in the ftape source distribution. Support for some enhanced controller boards is also provided—specifically Iomega Tape Accelerator, Colorado FC-10, and Mountain MACH-2. Support for the FC-15 and FC-20 high speed Colorado controller boards is not yet provided.

Most Linux distributions include ftape; if yours doesn't, you will have to download it (see Tape Resources sidebar). Unless you are using module version support in your kernel (if you don't understand what this means, you can assume that you are not using it), ftape will need to be recompiled each time you update your kernel.

Compiling ftape

First, go to your source directory and unpack the sources:

:$ cd /usr/local/src
$ tar xzf ftape-2.03b.tar.gz

You will end up with a directory ftape-2.03b; all the ftape source files will be in this directory along with some documentation files. You now need to compile ftape to end up with a file ftape.o:

$ cd ftape-2.03b
$ make clean
$ make dep
$ make all

Next, you need to make sure that your kernel has been compiled with ftape support built in. Recompiling the kernel is beyond the scope of this article (see the Kernel-HOWTO more details), but basically, do:

$ cd /usr/src/linux
$ make config

to accept all the default values for all options (unless, of course, you do want to change them), and when you get to the QIC-117 option, answer Y. Leave the NR_FTAPE_BUFFERS at the default value of 3. Then recompile the kernel (usually make clean dep; make zImage) and install the new kernel. Don't forget to re-run lilo if you use it.

If you are using very recent kernels (1.3.30 and above), you will have to use zftape. zftape (written by Claus Heine) is based on ftape but provides support for the dynamically loaded buffers provided by the later kernels. You compile it exactly the same way as ftape. Installing it is also done the same way as with ftape, except that you will use the name zftape instead of ftape. When configuring your kernel, you will not get asked any questions about QIC-117 options or NR_FTAPE_BUFFERS.

Even if you are not using recent kernels, zftape provides some very good enhancements over the basic ftape package, including software compression, and it is well worthwhile upgrading to get it.

Making The Devices

Next, you need to make sure that the /dev entries have been created correctly for ftape. Once again, if you have a Linux distribution, this will more than likely have been done, otherwise; you will have to create them manually. Do:

$ ls /dev/*rft* /dev/*tape*

and you should have at least the following files:


If you do not, create them (you will have to be root):

$ mknod -m 666 /dev/rft0 c 27 0
$ mknod -m 666 /dev/nrft0 c 27 4
$ ln -s /dev/rft0 /dev/ftape
$ ln -s /dev/nrft0 /dev/nftape

Alternatively, if you have a script called MAKEDEV in your /dev/ directory, you can simply run this to have your devices created correctly.

$ cd /dev
$ ./MAKEDEV ftape

If you are using the zftape package, there are certain other device names that you will require. They can be created from the zftape Makefile by:

$ make mknod
$ ln -s /dev/rft0 /dev/ftape
$ ln -s /dev/nrft0 /dev/nftape
$ ln -s /dev/qft0 /dev/qftape
$ ln -s /dev/nqft0 /dev/nqftape
Installing ftape

You next need to make sure that you have the module utilities. This set of utilities allows the ftape driver to be loaded so that the kernel can access it. You will need the program insmod which should be in /sbin. If you do not have it, obtain the latest version (see Tape Resources), compile it (which is quite easy), and install it.

$ tar xzf modules-xx.xx.tar.gz
$ cd modules-xx.xx
$ make clean
$ make
$ make install

Note that if you are using modules-1.1.87, you must replace insmod.c and insmod.h with the ones that come in the ftape distribution. To avoid these problems, obtain a copy of the latest modules, which contains many other bug fixes as well.

Before you can use the tape drive, you must load the ftape program. You will have to be root to do so.

$ insmod ftape.o

This must be done every time you boot up Linux. If you do a lot of tape drive work, it is a good idea to include this in your rc.local startup script so that every time you boot up the tape driver is automatically loaded.

Tape Preparation

There are two steps to using a new tape with Linux. The tape must be low-level formatted. You can actually buy pre-formatted tapes (and they are only a couple of extra dollars and well worth the money), but if you have bought an unformatted tape, you will have to format it yourself. There is no Linux program available to format tapes, so this must be done under DOS, OS/2 or WINDOWS. DOS programs known to format tapes correctly include Norton Backup, Colorado Systems Backup Program (shipped with Jumbo drives), and Conner Backup Basics.

Next, the tape has to be prepared for use by ftape which has to write headers and sector maps. You can use mt do this preparation (which is known as erasing a tape).

$ mt -f /dev/ftape erase

mt comes as part of the cpio package from GNU. See below for locations.

If you are using zftape, your device name is /dev/qftape and hence, you need to issue:

$ mt -f /dev/qftape erase
Common Problems
  • PCI motherboards Some PCI motherboards have problems using ftape. The difficulty seems to lie with the Guaranteed Access Timing (GAT) option in the BIOS. This option must be disabled for ftape to work correctly. Note that some of the later Intel boards (1.00.10AX1 and later) have this setting permanently disabled.

  • insmod says “wrong kernel version” As mentioned above, ftape will only work with the kernel that was running when it was compiled. Each time you change kernel versions, you will need to recompile ftape.

  • Unable to use floppy disk Because both the tape drive and the floppy disk use IRQ 6, it is impossible to concurrently use the tape drive and floppy disk drive. Therefore, if you try to use the floppy disk while ftape is installed, you will get an error message. Similarly, if you try to install ftape while you have a floppy disk mounted, you will get an error. This is a hardware limitation and has nothing to do with ftape.

  • ftape seems to hang after accessing tape Earlier versions of ftape had problems with retry errors. Updating to the latest ftape (currently v2.03) usually solves these.

  • No such device error When trying to use tar or some other program that accesses the tape drive, you get a “No such device error”. This is because you have not installed the ftape driver using insmod as described above.

  • No such file or directory When trying to use tar or some other program that accesses the tape drive, you get a No such file or directory error. This is because you do not have a /dev/ftape and /dev/rft0 entries in your /dev directories. Create them using MAKEDEV or using the method outlined above.

SCSI Tape Drives

SCSI tape drives can be difficult (or very easy) to get working but they are generally quicker, and more reliable, and there is no problem using floppies and tape drives simultaneously. The downside is that they are usually much more expensive than their floppy drive equivalents.

Compiling with SCSI Support

You have to ensure that the kernel you are running has support enabled for your SCSI adaptor. Change to the kernel directory and start the kernel configuration script:

$ cd /usr/src/linux
$ make config

Press ENTER for all the options to accept the default values, until you come to the question CONFIG_SCSI. Type Y for this option. Press ENTER until you come to the question CONFIG_CHR_DEV and type Y for this option. Continue pressing ENTER until you come to your SCSI adaptor and answer Y to this question. You then have to recompile the kernel, as mentioned above.

When you boot up, you should now get a message similar to this (the numbers, and details may, of course, vary):

Detected SCSI tape st0 at scsi0 id 4, lun 0
scsi: Detected 1 SCSI tape 1 SCSI disk total
Making Devices

Next, you need to make sure that the SCSI devices have been created in your /dev directory. Once again, if you have a Linux distribution, this will more than likely have been done. Otherwise, you will have to create them manually. Do:

$ ls /dev/*st*

and you should have at least the following files:


If you do not, create them (you will have to be root):

$ mknod -m 666 /dev/st0 c 9 0
$ mknod -m 666 /dev/nst0 c 9 128

Note, the above assumes that you are using the first tape on the SCSI bus. If you have two tapes, and you want to use the second one, change the device names to /dev/st1 and /dev/nst1 and create them:

$ mknod -m 666 /dev/st1 c 9 1
$ mknod -m 666 /dev/nst1 c 9 129

If you have a more recent distribution, chances are you will have the MAKEDEV script available in your /dev directory. You can create all the appropriate devices by simply running that script:

$ cd /dev
$ ./MAKEDEV st0
Tape Preparation

Unlike floppy tape drive tapes, SCSI tapes generally do not need formatting. They may, however, need erasing for use under Linux. To erase a tape, do:

$ mt -f /dev/st0 erase

DAT tapes, however, do not need erasing. The easiest way to find out if a particular tape needs erasing is to try using it without erasing first. If you can, well and good; if not, you will have to erase prior to use.

Device Names

Accessing a tape drive is very similar to accessing a file on the hard disk, except that a tape drive has two filenames. For ftape, these two names are generally /dev/ftape and /dev/nftape. If you use zftape, the two device names are generally /dev/qftape and /dev/nqftape. For SCSI, the names are /dev/st0 and /dev/nst0 for the first SCSI tape device, /dev/st1 and /dev/nst1 for the second SCSI tape device, and so on.

When the tape drive is accessed by the first filename (/dev/ftape, /dev/qftape, or /dev/st0), we are said to be accessing the rewinding device. When the tape drive is closed, the tape is automatically rewound to the beginning. When accessing the tape drive via the second filename (/dev/nftape, /dev/nqftape, or /dev/nst0), we are using the non-rewinding device and when the tape drive is closed, the tape is left where it is.

Some applications need to use both devices and you will need to specify the correct names.

Testing Using tar

Now that you have set up your system for a tape drive, you will want to test it. GNU tar is the de facto backup standard under Linux and comes will all distributions. If you do not have it, obtain it from a site near you.

In the examples below, I will use dev_name to indicate your device name. As mentioned above, this will probably be /dev/ftape if you use ftape, /dev/qftape if you use zftape, and /dev/st0 if you use a SCSI drive.

Put a freshly prepared tape into the tape drive and try to make a small backup:

$ tar cf dev_name /etc

This should backup your /etc directory. You can now check to see if the backup was made correctly by:

$ tar df dev_name

Note that if you use ftape, you cannot use the Ar options to tar because of limitations in the current driver. That is, you cannot append files to an archive. You will have to use mt to move the tape to the end of one archive and then create another archive.

A more detailed look at tar is provided in the Tar and Taper for Linux article.

Please note that the above sites are very busy. In the interests of preserving your sanity and minimizing network traffic, find a mirror (and there are many) near you and use that. Both tsx-11 and sunsite will print a list of mirrors if you try to log on when they are busy.

Further Information

The HOW-TOs are an invaluable source of information. There is a HOW-TO for both ftape and for SCSI.

Yusuf Nagree is a part time doctor and a full time Linux hacker (aargh—sorry, full time doctor and part time Linux hacker). He has been a computer buff since his dad bought him a ZX-80 in 1980 and has had various computers over the years. Bored with DOS, OS/2 and Windows, the aspect of Linux he finds most enjoyable is the community spirit and general willingness to help and share knowledge and experience.

Load Disqus comments