home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / gnu / tar.txt / tar-1.12 / doc / tar.info-7 (.txt) < prev    next >
GNU Info File  |  1997-04-25  |  47KB  |  777 lines

  1. This is Info file tar.info, produced by Makeinfo version 1.67 from the
  2. input file tar.texi.
  3. START-INFO-DIR-ENTRY
  4. * tar: (tar).            Making tape (or disk) archives.
  5. END-INFO-DIR-ENTRY
  6.    This file documents GNU `tar', a utility used to store, backup, and
  7. transport files.
  8.    Copyright (C) 1992, 1994, 1995, 1996, 1997 Free Software Foundation,
  9.    Permission is granted to make and distribute verbatim copies of this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided that
  14. the entire resulting derived work is distributed under the terms of a
  15. permission notice identical to this one.
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that this permission notice may be stated in a
  19. translation approved by the Foundation.
  20.    This file documents GNU `tar', which is a utility used to store,
  21. backup, and transport files.  `tar' is a tape (or disk) archiver.  This
  22. manual documents the release 1.12.
  23. File: tar.info,  Node: Blocking,  Next: Many,  Prev: Common Problems and Solutions,  Up: Media
  24. Blocking
  25. ========
  26.      *(This message will disappear, once this node revised.)*
  27.    "Block" and "record" terminology is rather confused, and it is also
  28. confusing to the expert reader.  On the other hand, readers who are new
  29. to the field have a fresh mind, and they may safely skip the next two
  30. paragraphs, as the remainder of this manual uses those two terms in a
  31. quite consistent way.
  32.    John Gilmore, the writer of the public domain `tar' from which GNU
  33. `tar' was originally derived, wrote (June 1995):
  34.      The nomenclature of tape drives comes from IBM, where I believe
  35.      they were invented for the IBM 650 or so.  On IBM mainframes, what
  36.      is recorded on tape are tape blocks.  The logical organization of
  37.      data is into records.  There are various ways of putting records
  38.      into blocks, including `F' (fixed sized records), `V' (variable
  39.      sized records), `FB' (fixed blocked: fixed size records, N to a
  40.      block), `VB' (variable size records, N to a block), `VSB'
  41.      (variable spanned blocked: variable sized records that can occupy
  42.      more than one block), etc.  The `JCL' `DD RECFORM=' parameter
  43.      specified this to the operating system.
  44.      The Unix man page on `tar' was totally confused about this.  When
  45.      I wrote `PD TAR', I used the historically correct terminology
  46.      (`tar' writes data records, which are grouped into blocks).  It
  47.      appears that the bogus terminology made it into POSIX (no surprise
  48.      here), and now Franc,ois has migrated that terminology back into
  49.      the source code too.
  50.    The term "physical block" means the basic transfer chunk from or to
  51. a device, after which reading or writing may stop without anything
  52. being lost.  In this manual, the term "block" usually refers to a disk
  53. physical block, *assuming* that each disk block is 512 bytes in length.
  54. It is true that some disk devices have different physical blocks, but
  55. `tar' ignore these differences in its own format, which is meant to be
  56. portable, so a `tar' block is always 512 bytes in length, and "block"
  57. always mean a `tar' block.  The term "logical block" often represents
  58. the basic chunk of allocation of many disk blocks as a single entity,
  59. which the operating system treats somewhat atomically; this concept is
  60. only barely used in GNU `tar'.
  61.    The term "physical record" is another way to speak of a physical
  62. block, those two terms are somewhat interchangeable.  In this manual,
  63. the term "record" usually refers to a tape physical block, *assuming*
  64. that the `tar' archive is kept on magnetic tape.  It is true that
  65. archives may be put on disk or used with pipes, but nevertheless, `tar'
  66. tries to read and write the archive one "record" at a time, whatever
  67. the medium in use.  One record is made up of an integral number of
  68. blocks, and this operation of putting many disk blocks into a single
  69. tape block is called "reblocking", or more simply, "blocking".  The
  70. term "logical record" refers to the logical organization of many
  71. characters into something meaningful to the application.  The term
  72. "unit record" describes a small set of characters which are transmitted
  73. whole to or by the application, and often refers to a line of text.
  74. Those two last terms are unrelated to what we call a "record" in GNU
  75. `tar'.
  76.    When writing to tapes, `tar' writes the contents of the archive in
  77. chunks known as "records".  To change the default blocking factor, use
  78. the `--blocking-factor=512-SIZE' (`-b 512-SIZE') option.  Each record
  79. will then be composed of 512-SIZE blocks.  (Each `tar' block is 512
  80. bytes.  *Note Standard::.)  Each file written to the archive uses at
  81. least one full record.  As a result, using a larger record size can
  82. result in more wasted space for small files.  On the other hand, a
  83. larger record size can often be read and written much more efficiently.
  84.    Further complicating the problem is that some tape drives ignore the
  85. blocking entirely.  For these, a larger record size can still improve
  86. performance (because the software layers above the tape drive still
  87. honor the blocking), but not as dramatically as on tape drives that
  88. honor blocking.
  89.    When reading an archive, `tar' can usually figure out the record
  90. size on itself.  When this is the case, and a non-standard record size
  91. was used when the archive was created, `tar' will print a message about
  92. a non-standard blocking factor, and then operate normally.  On some
  93. tape devices, however, `tar' cannot figure out the record size itself.
  94. On most of those, you can specify a blocking factor (with
  95. `--blocking-factor=512-SIZE' (`-b 512-SIZE')) larger than the actual
  96. blocking factor, and then use the `--read-full-records' (`-B') option.
  97. (If you specify a blocking factor with `--blocking-factor=512-SIZE'
  98. (`-b 512-SIZE') and don't use the `--read-full-records' (`-B') option,
  99. then `tar' will not attempt to figure out the recording size itself.)
  100. On some devices, you must always specify the record size exactly with
  101. `--blocking-factor=512-SIZE' (`-b 512-SIZE') when reading, because
  102. `tar' cannot figure it out.  In any case, use `--list' (`-t') before
  103. doing any extractions to see whether `tar' is reading the archive
  104. correctly.
  105.    `tar' blocks are all fixed size (512 bytes), and its scheme for
  106. putting them into records is to put a whole number of them (one or
  107. more) into each record.  `tar' records are all the same size; at the
  108. end of the file there's a block containing all zeros, which is how you
  109. tell that the remainder of the last record(s) are garbage.
  110.    In a standard `tar' file (no options), the block size is 512 and the
  111. record size is 10240, for a blocking factor of 20.  What the
  112. `--blocking-factor=512-SIZE' (`-b 512-SIZE') option does is sets the
  113. blocking factor, changing the record size while leaving the block size
  114. at 512 bytes.  20 was fine for ancient 800 or 1600 bpi reel-to-reel
  115. tape drives; most tape drives these days prefer much bigger records in
  116. order to stream and not waste tape.  When writing tapes for myself,
  117. some tend to use a factor of the order of 2048, say, giving a record
  118. size of around one megabyte.
  119.    If you use a blocking factor larger than 20, older `tar' programs
  120. might not be able to read the archive, so we recommend this as a limit
  121. to use in practice.  GNU `tar', however, will support arbitrarily large
  122. record sizes, limited only by the amount of virtual memory or the
  123. physical characteristics of the tape device.
  124. * Menu:
  125. * Format Variations::           Format Variations
  126. * Blocking Factor::             The Blocking Factor of an Archive
  127. File: tar.info,  Node: Format Variations,  Next: Blocking Factor,  Prev: Blocking,  Up: Blocking
  128. Format Variations
  129. -----------------
  130.      *(This message will disappear, once this node revised.)*
  131.    Format parameters specify how an archive is written on the archive
  132. media.  The best choice of format parameters will vary depending on the
  133. type and number of files being archived, and on the media used to store
  134. the archive.
  135.    To specify format parameters when accessing or creating an archive,
  136. you can use the options described in the following sections.  If you do
  137. not specify any format parameters, `tar' uses default parameters.  You
  138. cannot modify a compressed archive.  If you create an archive with the
  139. `--blocking-factor=512-SIZE' (`-b 512-SIZE') option specified
  140. (*note Blocking Factor::.), you must specify that blocking-factor when
  141. operating on the archive.  *Note Formats::, for other examples of
  142. format parameter considerations.
  143. File: tar.info,  Node: Blocking Factor,  Prev: Format Variations,  Up: Blocking
  144. The Blocking Factor of an Archive
  145. ---------------------------------
  146.      *(This message will disappear, once this node revised.)*
  147.    The data in an archive is grouped into blocks, which are 512 bytes.
  148. Blocks are read and written in whole number multiples called "records".
  149. The number of blocks in a record (ie. the size of a record in units of
  150. 512 bytes) is called the "blocking factor".  The
  151. `--blocking-factor=512-SIZE' (`-b 512-SIZE') option specifies the
  152. blocking factor of an archive.  The default blocking factor is
  153. typically 20 (ie.  10240 bytes), but can be specified at installation.
  154. To find out the blocking factor of an existing archive, use `tar --list
  155. --file=ARCHIVE-NAME'.  This may not work on some devices.
  156.    Records are separated by gaps, which waste space on the archive
  157. media.  If you are archiving on magnetic tape, using a larger blocking
  158. factor (and therefore larger records) provides faster throughput and
  159. allows you to fit more data on a tape (because there are fewer gaps).
  160. If you are archiving on cartridge, a very large blocking factor (say
  161. 126 or more) greatly increases performance. A smaller blocking factor,
  162. on the other hand, may be usefull when archiving small files, to avoid
  163. archiving lots of nulls as `tar' fills out the archive to the end of
  164. the record.  In general, the ideal record size depends on the size of
  165. the inter-record gaps on the tape you are using, and the average size
  166. of the files you are archiving.  *Note create::, for information on
  167. writing archives.
  168.    Archives with blocking factors larger than 20 cannot be read by very
  169. old versions of `tar', or by some newer versions of `tar' running on
  170. old machines with small address spaces.  With GNU `tar', the blocking
  171. factor of an archive is limited only by the maximum record size of the
  172. device containing the archive, or by the amount of available virtual
  173. memory.
  174.    Also, on some systems, not using adequate blocking factors, as
  175. sometimes imposed by the device drivers, may yield unexpected
  176. diagnostics.  For example, this has been reported:
  177.      Cannot write to /dev/dlt: Invalid argument
  178. In such cases, it sometimes happen that the `tar' bundled by the system
  179. is aware of block size idiosyncrasies, while GNU `tar' requires an
  180. explicit specification for the block size, which it cannot guess.  This
  181. yields some people to consider GNU `tar' is misbehaving, because by
  182. comparison, `the bundle `tar' works OK'.  Adding `-b 256', for example,
  183. might resolve the problem.
  184.    If you use a non-default blocking factor when you create an archive,
  185. you must specify the same blocking factor when you modify that archive.
  186. Some archive devices will also require you to specify the blocking
  187. factor when reading that archive, however this is not typically the
  188. case.  Usually, you can use `--list' (`-t') without specifying a
  189. blocking factor--`tar' reports a non-default record size and then lists
  190. the archive members as it would normally.  To extract files from an
  191. archive with a non-standard blocking factor (particularly if you're not
  192. sure what the blocking factor is), you can usually use the
  193. `--read-full-records' (`-B') option while specifying a blocking factor
  194. larger then the blocking factor of the archive (ie. `tar --extract
  195. --read-full-records --blocking-factor=300'.  *Note list::, for more
  196. information on the `--list' (`-t') operation.  *Note Reading::, for a
  197. more detailed explanation of that option.
  198. `--blocking-factor=NUMBER'
  199. `-b NUMBER'
  200.      Specifies the blocking factor of an archive.  Can be used with any
  201.      operation, but is usually not necessary with `--list' (`-t').
  202.    Device blocking
  203. `-b BLOCKS'
  204. `--blocking-factor=BLOCKS'
  205.      Set record size to BLOCKS * 512 bytes.
  206.      This option is used to specify a "blocking factor" for the archive.
  207.      When reading or writing the archive, `tar', will do reads and
  208.      writes of the archive in records of BLOCK*512 bytes.  This is true
  209.      even when the archive is compressed.  Some devices requires that
  210.      all write operations be a multiple of a certain size, and so, `tar'
  211.      pads the archive out to the next record boundary.
  212.      The default blocking factor is set when `tar' is compiled, and is
  213.      typically 20.  Blocking factors larger than 20 cannot be read by
  214.      very old versions of `tar', or by some newer versions of `tar'
  215.      running on old machines with small address spaces.
  216.      With a magnetic tape, larger records give faster throughput and fit
  217.      more data on a tape (because there are fewer inter-record gaps).
  218.      If the archive is in a disk file or a pipe, you may want to specify
  219.      a smaller blocking factor, since a large one will result in a large
  220.      number of null bytes at the end of the archive.
  221.      When writing cartridge or other streaming tapes, a much larger
  222.      blocking factor (say 126 or more) will greatly increase
  223.      performance.  However, you must specify the same blocking factor
  224.      when reading or updating the archive.
  225.      Apparently, Exabyte drives have a physical block size of 8K bytes.
  226.      If we choose our blocksize as a multiple of 8k bytes, then the
  227.      problem seems to dissapper.  Id est, we are using block size of
  228.      112 right now, and we haven't had the problem since we switched...
  229.      With GNU `tar' the blocking factor is limited only by the maximum
  230.      record size of the device containing the archive, or by the amount
  231.      of available virtual memory.
  232.      However, deblocking or reblocking is virtually avoided in a special
  233.      case which often occurs in practice, but which requires all the
  234.      following conditions to be simultaneously true:
  235.         * the archive is subject to a compression option,
  236.         * the archive is not handled through standard input or output,
  237.           nor redirected nor piped,
  238.         * the archive is directly handled to a local disk, instead of
  239.           any special device,
  240.         * `--blocking-factor=512-SIZE' (`-b 512-SIZE') is not
  241.           explicitely specified on the `tar' invocation.
  242.      In previous versions of GNU `tar', the `--compress-block' option
  243.      (or even older: `--block-compress') was necessary to reblock
  244.      compressed archives.  It is now a dummy option just asking not to
  245.      be used, and otherwise ignored.  If the output goes directly to a
  246.      local disk, and not through stdout, then the last write is not
  247.      extended to a full record size.  Otherwise, reblocking occurs.
  248.      Here are a few other remarks on this topic:
  249.         * `gzip' will complain about trailing garbage if asked to
  250.           uncompress a compressed archive on tape, there is an option
  251.           to turn the message off, but it breaks the regularity of
  252.           simply having to use `PROG -d' for decompression.  It would
  253.           be nice if gzip was silently ignoring any number of trailing
  254.           zeros.  I'll ask Jean-loup Gailly, by sending a copy of this
  255.           message to him.
  256.         * `compress' does not show this problem, but as Jean-loup
  257.           pointed out to Michael, `compress -d' silently adds garbage
  258.           after the result of decompression, which tar ignores because
  259.           it already recognized its end-of-file indicator.  So this bug
  260.           may be safely ignored.
  261.         * `gzip -d -q' will be silent about the trailing zeros indeed,
  262.           but will still return an exit status of 2 which tar reports
  263.           in turn.  `tar' might ignore the exit status returned, but I
  264.           hate doing that, as it weakens the protection `tar' offers
  265.           users against other possible problems at decompression time.
  266.           If `gzip' was silently skipping trailing zeros *and* also
  267.           avoiding setting the exit status in this innocuous case, that
  268.           would solve this situation.
  269.         * `tar' should become more solid at not stopping to read a pipe
  270.           at the first null block encountered.  This inelegantly breaks
  271.           the pipe.  `tar' should rather drain the pipe out before
  272.           exiting itself.
  273. `--ignore-zeros'
  274.      Ignore blocks of zeros in archive (means EOF).
  275.      The `--ignore-zeros' (`-i') option causes `tar' to ignore blocks
  276.      of zeros in the archive.  Normally a block of zeros indicates the
  277.      end of the archive, but when reading a damaged archive, or one
  278.      which was created by `cat'-ing several archives together, this
  279.      option allows `tar' to read the entire archive.  This option is
  280.      not on by default because many versions of `tar' write garbage
  281.      after the zeroed blocks.
  282.      Note that this option causes `tar' to read to the end of the
  283.      archive file, which may sometimes avoid problems when multiple
  284.      files are stored on a single physical tape.
  285. `--read-full-records'
  286.      Reblock as we read (for reading 4.2BSD pipes).
  287.      If `--read-full-records' (`-B') is used, `tar' will not panic if an
  288.      attempt to read a record from the archive does not return a full
  289.      record.  Instead, `tar' will keep reading until it has obtained a
  290.      full record.
  291.      This option is turned on by default when `tar' is reading an
  292.      archive from standard input, or from a remote machine.  This is
  293.      because on BSD Unix systems, a read of a pipe will return however
  294.      much happens to be in the pipe, even if it is less than `tar'
  295.      requested.  If this option was not used, `tar' would fail as soon
  296.      as it read an incomplete record from the pipe.
  297.      This option is also useful with the commands for updating an
  298.      archive.
  299.    Tape blocking
  300.    When handling various tapes or cartridges, you have to take care of
  301. selecting a proper blocking, that is, the number of disk blocks you put
  302. together as a single tape block on the tape, without intervening tape
  303. gaps.  A "tape gap" is a small landing area on the tape with no
  304. information on it, used for decelerating the tape to a full stop, and
  305. for later regaining the reading or writing speed.  When the tape driver
  306. starts reading a record, the record has to be read whole without
  307. stopping, as a tape gap is needed to stop the tape motion without
  308. loosing information.
  309.    Using higher blocking (putting more disk blocks per tape block) will
  310. use the tape more efficiently as there will be less tape gaps.  But
  311. reading such tapes may be more difficult for the system, as more memory
  312. will be required to receive at once the whole record.  Further, if
  313. there is a reading error on a huge record, this is less likely that the
  314. system will succeed in recovering the information.  So, blocking should
  315. not be too low, nor it should be too high.  `tar' uses by default a
  316. blocking of 20 for historical reasons, and it does not really matter
  317. when reading or writing to disk.  Current tape technology would easily
  318. accomodate higher blockings.  Sun recommends a blocking of 126 for
  319. Exabytes and 96 for DATs.  We were told that for some DLT drives, the
  320. blocking should be a multiple of 4Kb, preferably 64Kb (`-b 128') or 256
  321. for decent performance.  Other manufacturers may use different
  322. recommendations for the same tapes.  This might also depends of the
  323. buffering techniques used inside modern tape controllers.  Some imposes
  324. a minimum blocking, or a maximum blocking.  Others request blocking to
  325. be some exponent of two.
  326.    So, there is no fixed rule for blocking.  But blocking at read time
  327. should ideally be the same as blocking used at write time.  At one place
  328. I know, with a wide variety of equipment, they found it best to use a
  329. blocking of 32 to guarantee that their tapes are fully interchangeable.
  330.    I was also told that, for recycled tapes, prior erasure (by the same
  331. drive unit that will be used to create the archives) sometimes lowers
  332. the error rates observed at rewriting time.
  333.    I might also use `--number-blocks' instead of `--block-number', so
  334. `--block' will then expand to `--blocking-factor' unambiguously.
  335. File: tar.info,  Node: Many,  Next: Using Multiple Tapes,  Prev: Blocking,  Up: Media
  336. Many Archives on One Tape
  337. =========================
  338.    Most tape devices have two entries in the `/dev' directory, or
  339. entries that come in pairs, which differ only in the minor number for
  340. this device.  Let's take for example `/dev/tape', which often points to
  341. the only or usual tape device of a given system.  There might be a
  342. corresponding `/dev/nrtape' or `/dev/ntape'.  The simpler name is the
  343. *rewinding* version of the device, while the name having `nr' in it is
  344. the *no rewinding* version of the same device.
  345.    A rewinding tape device will bring back the tape to its beginning
  346. point automatically when this device is opened or closed.  Since `tar'
  347. opens the archive file before using it and closes it afterwards, this
  348. means that a simple:
  349.      $ tar cf /dev/tape DIRECTORY
  350. will reposition the tape to its beginning both prior and after saving
  351. DIRECTORY contents to it, thus erasing prior tape contents and making
  352. it so that any subsequent write operation will destroy what has just
  353. been saved.
  354.    So, a rewinding device is normally meant to hold one and only one
  355. file.  If you want to put more than one `tar' archive on a given tape,
  356. you will need to avoid using the rewinding version of the tape device.
  357. You will also have to pay special attention to tape positioning.
  358. Errors in positionning may overwrite the valuable data already on your
  359. tape.  Many people, burnt by past experiences, will only use rewinding
  360. devices and limit themselves to one file per tape, precisely to avoid
  361. the risk of such errors.  Be fully aware that writing at the wrong
  362. position on a tape loses all information past this point and most
  363. probably until the end of the tape, and this destroyed information
  364. *cannot* be recovered.
  365.    To save DIRECTORY-1 as a first archive at the beginning of a tape,
  366. and leave that tape ready for a second archive, you should use:
  367.      $ mt -f /dev/nrtape rewind
  368.      $ tar cf /dev/nrtape DIRECTORY-1
  369.    "Tape marks" are special magnetic patterns written on the tape
  370. media, which are later recognizable by the reading hardware.  These
  371. marks are used after each file, when there are many on a single tape.
  372. An empty file (that is to say, two tape marks in a row) signal the
  373. logical end of the tape, after which no file exist.  Usually,
  374. non-rewinding tape device drivers will react to the close request issued
  375. by `tar' by first writing two tape marks after your archive, and by
  376. backspacing over one of these.  So, if you remove the tape at that time
  377. from the tape drive, it is properly terminated.  But if you write
  378. another file at the current position, the second tape mark will be
  379. erased by the new information, leaving only one tape mark between files.
  380.    So, you may now save DIRECTORY-2 as a second archive after the first
  381. on the same tape by issuing the command:
  382.      $ tar cf /dev/nrtape DIRECTORY-2
  383. and so on for all the archives you want to put on the same tape.
  384.    Another usual case is that you do not write all the archives the same
  385. day, and you need to remove and store the tape between two archive
  386. sessions.  In general, you must remember how many files are already
  387. saved on your tape.  Suppose your tape already has 16 files on it, and
  388. that you are ready to write the 17th.  You have to take care of skipping
  389. the first 16 tape marks before saving DIRECTORY-17, say, by using these
  390. commands:
  391.      $ mt -f /dev/nrtape rewind
  392.      $ mt -f /dev/nrtape fsf 16
  393.      $ tar cf /dev/nrtape DIRECTORY-17
  394.    In all the previous examples, we put aside blocking considerations,
  395. but you should do the proper things for that as well.  *Note Blocking::.
  396. * Menu:
  397. * Tape Positioning::            Tape Positions and Tape Marks
  398. * mt::                          The `mt' Utility
  399. File: tar.info,  Node: Tape Positioning,  Next: mt,  Prev: Many,  Up: Many
  400. Tape Positions and Tape Marks
  401. -----------------------------
  402.      *(This message will disappear, once this node revised.)*
  403.    Just as archives can store more than one file from the file system,
  404. tapes can store more than one archive file.  To keep track of where
  405. archive files (or any other type of file stored on tape) begin and end,
  406. tape archive devices write magnetic "tape marks" on the archive media.
  407. Tape drives write one tape mark between files, two at the end of all
  408. the file entries.
  409.    If you think of data as a series of records "rrrr"'s, and tape marks
  410. as "*"'s, a tape might look like the following:
  411.      rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  412.    Tape devices read and write tapes using a read/write "tape head"--a
  413. physical part of the device which can only access one point on the tape
  414. at a time.  When you use `tar' to read or write archive data from a
  415. tape device, the device will begin reading or writing from wherever on
  416. the tape the tape head happens to be, regardless of which archive or
  417. what part of the archive the tape head is on.  Before writing an
  418. archive, you should make sure that no data on the tape will be
  419. overwritten (unless it is no longer needed).  Before reading an
  420. archive, you should make sure the tape head is at the beginning of the
  421. archive you want to read.  (The `restore' script will find the archive
  422. automatically.  .  ).  *Note mt::, for an explanation of the tape
  423. moving utility.
  424.    If you want to add new archive file entries to a tape, you should
  425. advance the tape to the end of the existing file entries, backspace
  426. over the last tape mark, and write the new archive file.  If you were
  427. to add two archives to the example above, the tape might look like the
  428. following:
  429.      rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  430. File: tar.info,  Node: mt,  Prev: Tape Positioning,  Up: Many
  431. The `mt' Utility
  432. ----------------
  433.      *(This message will disappear, once this node revised.)*
  434.    *Note Blocking Factor::.
  435.    You can use the `mt' utility to advance or rewind a tape past a
  436. specified number of archive files on the tape.  This will allow you to
  437. move to the beginning of an archive before extracting or reading it, or
  438. to the end of all the archives before writing a new one.
  439.    The syntax of the `mt' command is:
  440.      mt [-f TAPENAME] OPERATION [NUMBER]
  441.    where TAPENAME is the name of the tape device, NUMBER is the number
  442. of times an operation is performed (with a default of one), and
  443. OPERATION is one of the following:
  444. `eof'
  445. `weof'
  446.      Writes NUMBER tape marks at the current position on the tape.
  447. `fsf'
  448.      Moves tape position forward NUMBER files.
  449. `bsf'
  450.      Moves tape position back NUMBER files.
  451. `rewind'
  452.      Rewinds the tape. (Ignores NUMBER).
  453. `offline'
  454. `rewoff1'
  455.      Rewinds the tape and takes the tape device off-line. (Ignores
  456.      NUMBER).
  457. `status'
  458.      Prints status information about the tape unit.
  459.    If you don't specify a TAPENAME, `mt' uses the environment variable
  460. TAPE; if TAPE does not exist, `mt' uses the device `/dev/rmt12'.
  461.    `mt' returns a 0 exit status when the operation(s) were successful,
  462. 1 if the command was unrecognized, and 2 if an operation failed.
  463.    If you use `--extract' (`--get', `-x') with the
  464. `--label=ARCHIVE-LABEL' (`-V ARCHIVE-LABEL') option specified, `tar'
  465. will read an archive label (the tape head has to be positioned on it)
  466. and print an error if the archive label doesn't match the ARCHIVE-NAME
  467. specified.  ARCHIVE-NAME can be any regular expression.  If the labels
  468. match, `tar' extracts the archive.  *Note label::.  .   `tar --list
  469. --label' will cause `tar' to print the label.
  470. File: tar.info,  Node: Using Multiple Tapes,  Next: label,  Prev: Many,  Up: Media
  471. Using Multiple Tapes
  472. ====================
  473.      *(This message will disappear, once this node revised.)*
  474.    Often you might want to write a large archive, one larger than will
  475. fit on the actual tape you are using.  In such a case, you can run
  476. multiple `tar' commands, but this can be inconvenient, particularly if
  477. you are using options like `--exclude=PATTERN' or dumping entire
  478. filesystems.  Therefore, `tar' supports multiple tapes automatically.
  479.    Use `--multi-volume' (`-M') on the command line, and then `tar' will,
  480. when it reaches the end of the tape, prompt for another tape, and
  481. continue the archive.  Each tape will have an independent archive, and
  482. can be read without needing the other.  (As an exception to this, the
  483. file that `tar' was archiving when it ran out of tape will usually be
  484. split between the two archives; in this case you need to extract from
  485. the first archive, using `--multi-volume' (`-M'), and then put in the
  486. second tape when prompted, so `tar' can restore both halves of the
  487. file.)
  488.    GNU `tar' multi-volume archives do not use a truly portable format.
  489. You need GNU `tar' at both end to process them properly.
  490.    When prompting for a new tape, `tar' accepts any of the following
  491. responses:
  492.      Request `tar' to explain possible responses
  493.      Request `tar' to exit immediately.
  494. `n FILE NAME'
  495.      Request `tar' to write the next volume on the file FILE NAME.
  496.      Request `tar' to run a subshell.
  497.      Request `tar' to begin writing the next volume.
  498.    (You should only type `y' after you have changed the tape; otherwise
  499. `tar' will write over the volume it just finished.)
  500.    If you want more elaborate behavior than this, give `tar' the
  501. `--info-script=SCRIPT-NAME' (`--new-volume-script=SCRIPT-NAME', `-F
  502. SCRIPT-NAME') option.  The file SCRIPT-NAME is expected to be a program
  503. (or shell script) to be run instead of the normal prompting procedure.
  504. When the program finishes, `tar' will immediately begin writing the
  505. next volume.  The behavior of the `n' response to the normal
  506. tape-change prompt is not available if you use
  507. `--info-script=SCRIPT-NAME' (`--new-volume-script=SCRIPT-NAME', `-F
  508. SCRIPT-NAME').
  509.    The method `tar' uses to detect end of tape is not perfect, and
  510. fails on some operating systems or on some devices.  You can use the
  511. `--tape-length=1024-SIZE' (`-L 1024-SIZE') option if `tar' can't detect
  512. the end of the tape itself.  This option selects `--multi-volume'
  513. (`-M') automatically.  The SIZE argument should then be the usable size
  514. of the tape.  But for many devices, and floppy disks in particular,
  515. this option is never required for real, as far as we know.
  516.    The volume number used by `tar' in its tape-change prompt can be
  517. changed; if you give the `--volno-file=FILE-OF-NUMBER' option, then
  518. FILE-OF-NUMBER should be an unexisting file to be created, or else, a
  519. file already containing a decimal number.  That number will be used as
  520. the volume number of the first volume written.  When `tar' is finished,
  521. it will rewrite the file with the now-current volume number.  (This
  522. does not change the volume number written on a tape label, as per
  523. *Note label::, it *only* affects the number used in the prompt.)
  524.    If you want `tar' to cycle through a series of tape drives, then you
  525. can use the `n' response to the tape-change prompt.  This is error
  526. prone, however, and doesn't work at all with
  527. `--info-script=SCRIPT-NAME' (`--new-volume-script=SCRIPT-NAME', `-F
  528. SCRIPT-NAME').  Therefore, if you give `tar' multiple
  529. `--file=ARCHIVE-NAME' (`-f ARCHIVE-NAME') options, then the specified
  530. files will be used, in sequence, as the successive volumes of the
  531. archive.  Only when the first one in the sequence needs to be used
  532. again will `tar' prompt for a tape change (or run the info script).
  533.    Multi-volume archives
  534.    With `--multi-volume' (`-M'), `tar' will not abort when it cannot
  535. read or write any more data.  Instead, it will ask you to prepare a new
  536. volume.  If the archive is on a magnetic tape, you should change tapes
  537. now; if the archive is on a floppy disk, you should change disks, etc.
  538.    Each volume of a multi-volume archive is an independent `tar'
  539. archive, complete in itself.  For example, you can list or extract any
  540. volume alone; just don't specify `--multi-volume' (`-M').  However, if
  541. one file in the archive is split across volumes, the only way to extract
  542. it successfully is with a multi-volume extract command `--extract
  543. --multi-volume' (`-xM') starting on or before the volume where the file
  544. begins.
  545.    For example, let's presume someone has two tape drives on a system
  546. named `/dev/tape0' and `/dev/tape1'.  For having GNU `tar' to switch to
  547. the second drive when it needs to write the second tape, and then back
  548. to the first tape, etc., just do either of:
  549.      $ tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 FILES
  550.      $ tar cMff /dev/tape0 /dev/tape1 FILES
  551. * Menu:
  552. * Multi-Volume Archives::       Archives Longer than One Tape or Disk
  553. * Tape Files::                  Tape Files
  554. File: tar.info,  Node: Multi-Volume Archives,  Next: Tape Files,  Prev: Using Multiple Tapes,  Up: Using Multiple Tapes
  555. Archives Longer than One Tape or Disk
  556. -------------------------------------
  557.      *(This message will disappear, once this node revised.)*
  558.    To create an archive that is larger than will fit on a single unit of
  559. the media, use the `--multi-volume' (`-M') option in conjunction with
  560. the `--create' (`-c') option (*note create::.).  A "multi-volume"
  561. archive can be manipulated like any other archive (provided the
  562. `--multi-volume' (`-M') option is specified), but is stored on more
  563. than one tape or disk.
  564.    When you specify `--multi-volume' (`-M'), `tar' does not report an
  565. error when it comes to the end of an archive volume (when reading), or
  566. the end of the media (when writing).  Instead, it prompts you to load a
  567. new storage volume.  If the archive is on a magnetic tape, you should
  568. change tapes when you see the prompt; if the archive is on a floppy
  569. disk, you should change disks; etc.
  570.    You can read each individual volume of a multi-volume archive as if
  571. it were an archive by itself.  For example, to list the contents of one
  572. volume, use `--list' (`-t'), without `--multi-volume' (`-M') specified.
  573. To extract an archive member from one volume (assuming it is described
  574. that volume), use `--extract' (`--get', `-x'), again without
  575. `--multi-volume' (`-M').
  576.    If an archive member is split across volumes (ie. its entry begins on
  577. one volume of the media and ends on another), you need to specify
  578. `--multi-volume' (`-M') to extract it successfully.  In this case, you
  579. should load the volume where the archive member starts, and use `tar
  580. --extract --multi-volume'--`tar' will prompt for later volumes as it
  581. needs them.  *Note extracting archives::, for more information about
  582. extracting archives.
  583.    `--info-script=SCRIPT-NAME' (`--new-volume-script=SCRIPT-NAME', `-F
  584. SCRIPT-NAME') is like `--multi-volume' (`-M'), except that `tar' does
  585. not prompt you directly to change media volumes when a volume is
  586. full--instead, `tar' runs commands you have stored in SCRIPT-NAME.  For
  587. example, this option can be used to eject cassettes, or to broadcast
  588. messages such as `Someone please come change my tape' when performing
  589. unattended backups.  When SCRIPT-NAME is done, `tar' will assume that
  590. the media has been changed.
  591.    Multi-volume archives can be modified like any other archive.  To add
  592. files to a multi-volume archive, you need to only mount the last volume
  593. of the archive media (and new volumes, if needed).  For all other
  594. operations, you need to use the entire archive.
  595.    If a multi-volume archive was labeled using `--label=ARCHIVE-LABEL'
  596. (`-V ARCHIVE-LABEL') (*note label::.) when it was created, `tar' will
  597. not automatically label volumes which are added later.  To label
  598. subsequent volumes, specify `--label=ARCHIVE-LABEL' (`-V
  599. ARCHIVE-LABEL') again in conjunction with the `--append' (`-r'),
  600. `--update' (`-u') or `--concatenate' (`--catenate', `-A') operation.
  601. `--multi-volume'
  602.      Creates a multi-volume archive, when used in conjunction with
  603.      `--create' (`-c').  To perform any other operation on a
  604.      multi-volume archive, specify `--multi-volume' (`-M') in
  605.      conjunction with that operation.
  606. `--info-script=PROGRAM-FILE'
  607. `-F PROGRAM-FILE'
  608.      Creates a multi-volume archive via a script.  Used in conjunction
  609.      with `--create' (`-c').
  610.    Beware that there is *no* real standard about the proper way, for a
  611. `tar' archive, to span volume boundaries.  If you have a multi-volume
  612. created by some vendor's `tar', there is almost no chance you could
  613. read all the volumes with GNU `tar'.  The converse is also true: you
  614. may not expect multi-volume archives created by GNU `tar' to be fully
  615. recovered by vendor's `tar'.  Since there is little chance that, in
  616. mixed system configurations, some vendor's `tar' will work on another
  617. vendor's machine, and there is a great chance that GNU `tar' will work
  618. on most of them, your best bet is to install GNU `tar' on all machines
  619. between which you know exchange of files is possible.
  620. File: tar.info,  Node: Tape Files,  Prev: Multi-Volume Archives,  Up: Using Multiple Tapes
  621. Tape Files
  622. ----------
  623.      *(This message will disappear, once this node revised.)*
  624.    To give the archive a name which will be recorded in it, use the
  625. `--label=ARCHIVE-LABEL' (`-V ARCHIVE-LABEL') option.  This will write a
  626. special block identifying VOLUME-LABEL as the name of the archive to
  627. the front of the archive which will be displayed when the archive is
  628. listed with `--list' (`-t').  If you are creating a multi-volume
  629. archive with `--multi-volume' (`-M') (), then the volume label will have
  630. `Volume NNN' appended to the name you give, where NNN is the number of
  631. the volume of the archive.  (If you use the `--label=ARCHIVE-LABEL'
  632. (`-V ARCHIVE-LABEL') option when reading an archive, it checks to make
  633. sure the label on the tape matches the one you give.  *Note label::.
  634.    When `tar' writes an archive to tape, it creates a single tape file.
  635. If multiple archives are written to the same tape, one after the
  636. other, they each get written as separate tape files.  When extracting,
  637. it is necessary to position the tape at the right place before running
  638. `tar'.  To do this, use the `mt' command.  For more information on the
  639. `mt' command and on the organization of tapes into a sequence of tape
  640. files, see *Note mt::.
  641.    People seem to often do:
  642.      --label="SOME-PREFIX `date +SOME-FORMAT`"
  643.    or such, for pushing a common date in all volumes or an archive set.
  644. File: tar.info,  Node: label,  Next: verify,  Prev: Using Multiple Tapes,  Up: Media
  645. Including a Label in the Archive
  646. ================================
  647.      *(This message will disappear, once this node revised.)*
  648. `-V NAME'
  649. `--label=NAME'
  650.      Create archive with volume name NAME.
  651.    This option causes `tar' to write out a "volume header" at the
  652. beginning of the archive.  If `--multi-volume' (`-M') is used, each
  653. volume of the archive will have a volume header of `NAME Volume N',
  654. where N is 1 for the first volume, 2 for the next, and so on.
  655.    To avoid problems caused by misplaced paper labels on the archive
  656. media, you can include a "label" entry--an archive member which
  657. contains the name of the archive--in the archive itself.  Use the
  658. `--label=ARCHIVE-LABEL' (`-V ARCHIVE-LABEL') option in conjunction with
  659. the `--create' (`-c') operation to include a label entry in the archive
  660. as it is being created.
  661.    If you create an archive using both `--label=ARCHIVE-LABEL' (`-V
  662. ARCHIVE-LABEL') and `--multi-volume' (`-M'), each volume of the archive
  663. will have an archive label of the form `ARCHIVE-LABEL Volume N', where
  664. N is 1 for the first volume, 2 for the next, and so on.  , for
  665. information on creating multiple volume archives.
  666.    If you list or extract an archive using `--label=ARCHIVE-LABEL' (`-V
  667. ARCHIVE-LABEL'), `tar' will print an error if the archive label doesn't
  668. match the ARCHIVE-LABEL specified, and will then not list nor extract
  669. the archive.  In those cases, ARCHIVE-LABEL argument is interpreted as
  670. a globbing-style pattern which must match the actual magnetic volume
  671. label.  *Note exclude::, for a precise description of how match is
  672. attempted(1).  If the switch `--multi-volume' (`-M') is being used, the
  673. volume label matcher will also suffix ARCHIVE-LABEL by ` Volume [1-9]*'
  674. if the initial match fails, before giving up.  Since the volume
  675. numbering is automatically added in labels at creation time, it sounded
  676. logical to equally help the user taking care of it when the archive is
  677. being read.
  678.    The `--label=ARCHIVE-LABEL' (`-V ARCHIVE-LABEL') was once called
  679. `--volume', but is not available under that name anymore.
  680.    To find out an archive's label entry (or to find out if an archive
  681. has a label at all), use `tar --list --verbose'.  `tar' will print the
  682. label first, and then print archive member information, as in the
  683. example below:
  684.      $ tar --verbose --list --file=iamanarchive
  685.      V--------- 0 0        0 1992-03-07 12:01 iamalabel--Volume Header--
  686.      -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
  687. `--label=ARCHIVE-LABEL'
  688. `-V ARCHIVE-LABEL'
  689.      Includes an "archive-label" at the beginning of the archive when
  690.      the archive is being created, when used in conjunction with the
  691.      `--create' (`-c') option.  Checks to make sure the archive label
  692.      matches the one specified (when used in conjunction with the
  693.      `--extract' (`--get', `-x') option.
  694.    To get a common information on all tapes of a series, use the
  695. `--label=ARCHIVE-LABEL' (`-V ARCHIVE-LABEL') option.  For having this
  696. information different in each series created through a single script
  697. used on a regular basis, just manage to get some date string as part of
  698. the label.  For example:
  699.      $ tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"
  700.      $ tar --create --file=/dev/tape --multi-volume \
  701.           --volume="Daily backup for `date +%Y-%m-%d`"
  702.    Also note that each label has its own date and time, which
  703. corresponds to when GNU `tar' initially attempted to write it, often
  704. soon after the operator launches `tar' or types the carriage return
  705. telling that the next tape is ready.  Comparing date labels does give
  706. an idea of tape throughput only if the delays for rewinding tapes and
  707. the operator switching them were negligible, which is ususally not the
  708. case.
  709.    ---------- Footnotes ----------
  710.    (1)  Previous versions of `tar' used full regular expression
  711. matching, or before that, only exact string matching, instead of
  712. wildcard matchers.  We decided for the sake of simplicity to use a
  713. uniform matching device through `tar'.
  714. File: tar.info,  Node: verify,  Next: Write Protection,  Prev: label,  Up: Media
  715. Verifying Data as It is Stored
  716. ==============================
  717. `--verify'
  718.      Attempt to verify the archive after writing.
  719.    This option causes `tar' to verify the archive after writing it.
  720. Each volume is checked after it is written, and any discrepancies are
  721. recorded on the standard error output.
  722.    Verification requires that the archive be on a back-space-able
  723. medium.  This means pipes, some cartridge tape drives, and some other
  724. devices cannot be verified.
  725.    You can insure the accuracy of an archive by comparing files in the
  726. system with archive members.  `tar' can compare an archive to the file
  727. system as the archive is being written, to verify a write operation, or
  728. can compare a previously written archive, to insure that it is up to
  729. date.
  730.    To check for discrepancies in an archive immediately after it is
  731. written, use the `--verify' (`-W') option in conjunction with the
  732. `--create' (`-c') operation.  When this option is specified, `tar'
  733. checks archive members against their counterparts in the file system,
  734. and reports discrepancies on the standard error.  In multi-volume
  735. archives, each volume is verified after it is written, before the next
  736. volume is written.
  737.    To verify an archive, you must be able to read it from before the end
  738. of the last written entry.  This option is useful for detecting data
  739. errors on some tapes.  Archives written to pipes, some cartridge tape
  740. drives, and some other devices cannot be verified.
  741.    One can explicitely compare an already made archive with the file
  742. system by using the `--compare' (`--diff', `-d') option, instead of
  743. using the more automatic `--verify' (`-W') option.  *Note compare::.
  744.    Note that these two options have a slightly different intent.  The
  745. `--compare' (`--diff', `-d') option how identical are the logical
  746. contents of some archive with what is on your disks, while the
  747. `--verify' (`-W') option is really for checking if the physical
  748. contents agree and if the recording media itself is of dependable
  749. quality.  So, for the `--verify' (`-W') operation, `tar' tries to
  750. defeat all in-memory cache pertaining to the archive, while it lets the
  751. speed optimization undisturbed for the `--compare' (`--diff', `-d')
  752. option.  If you nevertheless use `--compare' (`--diff', `-d') for media
  753. verification, you may have to defeat the in-memory cache yourself,
  754. maybe by opening and reclosing the door latch of your recording unit,
  755. forcing some doubt in your operating system about the fact this is
  756. really the same volume as the one just written or read.
  757.    The `--verify' (`-W') option would not be necessary if drivers were
  758. indeed able to detect dependably all write failures.  This sometimes
  759. require many magnetic heads, some able to read after the writes
  760. occurred.  One would not say that drivers unable to detect all cases
  761. are necessarily flawed, as long as programming is concerned.
  762. File: tar.info,  Node: Write Protection,  Prev: verify,  Up: Media
  763. Write Protection
  764. ================
  765.    Almost all tapes and diskettes, and in a few rare cases, even disks
  766. can be "write protected", to protect data on them from being changed.
  767. Once an archive is written, you should write protect the media to
  768. prevent the archive from being accidently overwritten or deleted.
  769. (This will protect the archive from being changed with a tape or floppy
  770. drive--it will not protect it from magnet fields or other physical
  771. hazards).
  772.    The write protection device itself is usually an integral part of the
  773. physical media, and can be a two position (write enabled/write
  774. disabled) switch, a notch which can be popped out or covered, a ring
  775. which can be removed from the center of a tape reel, or some other
  776. changeable feature.
  777.