The mt Command Magnetic Tape Devices and Special Device Files

Set both input and output block size, superseding ibs and obs cbs=n Conversi on buffer size skip=n Skip n input records before starting copy files=n Copy n input files before terminating makes sense only when the input is a magnetic tape or similar device seek=n Seek n records from beginning of output file before copying. This option generally only works with magnetic tapes and raw disk files and is otherwise usually useless if the explicit output file was named with the of option count=nCopy only n input records conv=…Specify a conversion EBCDIC, ASCII, etc. After completion, dd reports the number of whole and partial input and output blocks. A few examples are: To read an EBCDIC tape, with blocked ten 80−byte EBCDIC card images per record, into the ASCII file filename: dd if=devrmt0 of = filename ibs=800 cbs=80 conv=ascii, lcase • To write the file filename to a 3.5−inch floppy and read from the floppy into a file filename, respectively: dd if= filename of=devrfd0c bs=9k dd if=devrfd0c of= filename bs=9k • This command can be used to figure out the actual size of a raw disk partition or a logical volume, for example: dd if=devvg00lvol5 of=devnull bs=2k 51200+0 records in 51200+0 records out • In this example, the complete logical volume lvol5 was copied into null device nowhere; the reported number of input and output records for the defined block size of 2K determines the total raw volume size of 102.4 MB. Be careful in using this command, because a reverse selection of the input and output file would have a completely different meaning: it will erase the contents of the volume.

12.2.4 The mt Command

The mt command controls a magnetic tape drive. It can be used to position a tape at a particular place, so it is very useful when multiple filesystemsfiles are archived on a single tape. The command syntax is: mt [ −t tapename] command…[count] Or on some UNIX platforms like Solaris 2.x: mt [ −f tapename ] command…[ count ] If tapename is not specified, the environment variable TAPE is used. If TAPE does not exist, mt 278 mt supports the following internal commands: eof Write count EOF marks at the current position on the tape, weof. fsf Forward space over count EOF marks. The tape is positioned on the first block of the file. fsr Forward space count records. bsf Back space over count EOF marks. The tape is positioned on the beginning−of−tape side of the EOF mark. bsr Back space count records. nbsf Back space count files. The tape is positioned on the first block of the file; this is equivalent to { count +1 } bsf s followed by one fsf. asf Absolute space to count file number; this is equivalent to a rewind followed by a fsf count. For the eom commands, count is ignored. eom Space to the end of recorded media on the tape. This is useful for appending files onto previously written tapes. rewind Rewind the tape. offline Rewind the tape and take the drive unit off−line by unloading the tape, rewoffl. status Print status information about the tape unit. retention Rewind the cartridge tape completely, then wind it forward to the end of the reel and back to beginning−of−tape to smooth out tape tension. erase Erase the entire tape.

12.2.5 Magnetic Tape Devices and Special Device Files

All tape−related commands deal with magnetic tape drives via corresponding special device files. The command specifies the device file, which then provides the requested operation with the tape drive. Once the operation is completed, the tape is usually rewound. To properly understand tape device files, a bit of history can be instructive. In the past, only low density and small capacity tapes were available, so it was necessary to use a number of tape volumes to backup a complete system. A multivolume backup also included the rewinding of the tape volumes once the desired transaction was completed. The easiest way to provide this unavoidable rewinding was to delegate this task to the device file; rewinding was performed automatically before the device file was closed. The new technology brought new demands. High density and large capacity tapes enable the archival of many files, directories, andor filesystems on a single tape, so there is no need for a multivolume backup. In fact, today the opposite exists; often, multiple filesystems must be archived on the same medium. The fact that a tape was rewound automatically when the archiving was completed became an obstacle; a new command always started from the beginning of the tape, so everything previously stored was overwritten. That is why modified, nonrewinding device files have been introduced; they provide everything contained in the original device files except for the rewinding at the end, and usually they carry an additional n in their names as a prefix or a suffix. The permanent improvements in tape density were addressed in a similar way — new, modified 279 Let us see what this means in practice. On Solaris 2.x which is System V−like, all tape device files reside in the subdirectory devrmt. ls −C devrmt 0 0bn 0cb 0cn 0hb 0hn 0lb 0ln 0mb 0mn 0u 0ubn 0b 0c 0cbn 0h 0hbn 0l 0lbn 0m 0mbn 0n 0ub 0un This is an example from the SunSparc20 workstation with a single 4mm DDS2 tape drive. Each device file is identified by: devrmt unit number [density][BSD behavior][norewind] where density Is identified by the letters l, m, h, u, and c for low, medium, high, ultra, and compressed, respectively BSD behavior By the letter b norewind By the letter n Tape device files can be identified in a similar way on other systems.

12.3 Backing Up a UNIX Filesystem