tar: Many

1 
1 9.5 Many Archives on One Tape
1 =============================
1 
1 Most tape devices have two entries in the '/dev' directory, or entries
1 that come in pairs, which differ only in the minor number for this
1 device.  Let's take for example '/dev/tape', which often points to the
1 only or usual tape device of a given system.  There might be a
1 corresponding '/dev/nrtape' or '/dev/ntape'.  The simpler name is the
1 _rewinding_ version of the device, while the name having 'nr' in it is
1 the _no rewinding_ version of the same device.
1 
1    A rewinding tape device will bring back the tape to its beginning
1 point automatically when this device is opened or closed.  Since 'tar'
1 opens the archive file before using it and closes it afterwards, this
1 means that a simple:
1 
1      $ tar cf /dev/tape DIRECTORY
1 
1 will reposition the tape to its beginning both prior and after saving
1 DIRECTORY contents to it, thus erasing prior tape contents and making it
1 so that any subsequent write operation will destroy what has just been
1 saved.
1 
1    So, a rewinding device is normally meant to hold one and only one
1 file.  If you want to put more than one 'tar' archive on a given tape,
1 you will need to avoid using the rewinding version of the tape device.
1 You will also have to pay special attention to tape positioning.  Errors
1 in positioning may overwrite the valuable data already on your tape.
1 Many people, burnt by past experiences, will only use rewinding devices
1 and limit themselves to one file per tape, precisely to avoid the risk
1 of such errors.  Be fully aware that writing at the wrong position on a
1 tape loses all information past this point and most probably until the
1 end of the tape, and this destroyed information _cannot_ be recovered.
1 
1    To save DIRECTORY-1 as a first archive at the beginning of a tape,
1 and leave that tape ready for a second archive, you should use:
1 
1      $ mt -f /dev/nrtape rewind
1      $ tar cf /dev/nrtape DIRECTORY-1
1 
1    "Tape marks" are special magnetic patterns written on the tape media,
1 which are later recognizable by the reading hardware.  These marks are
1 used after each file, when there are many on a single tape.  An empty
1 file (that is to say, two tape marks in a row) signal the logical end of
1 the tape, after which no file exist.  Usually, non-rewinding tape device
1 drivers will react to the close request issued by 'tar' by first writing
1 two tape marks after your archive, and by backspacing over one of these.
1 So, if you remove the tape at that time from the tape drive, it is
1 properly terminated.  But if you write another file at the current
1 position, the second tape mark will be erased by the new information,
1 leaving only one tape mark between files.
1 
1    So, you may now save DIRECTORY-2 as a second archive after the first
1 on the same tape by issuing the command:
1 
1      $ tar cf /dev/nrtape DIRECTORY-2
1 
1 and so on for all the archives you want to put on the same tape.
1 
1    Another usual case is that you do not write all the archives the same
1 day, and you need to remove and store the tape between two archive
1 sessions.  In general, you must remember how many files are already
1 saved on your tape.  Suppose your tape already has 16 files on it, and
1 that you are ready to write the 17th.  You have to take care of skipping
1 the first 16 tape marks before saving DIRECTORY-17, say, by using these
1 commands:
1 
1      $ mt -f /dev/nrtape rewind
1      $ mt -f /dev/nrtape fsf 16
1      $ tar cf /dev/nrtape DIRECTORY-17
1 
1    In all the previous examples, we put aside blocking considerations,
1 but you should do the proper things for that as well.  ⇒Blocking.
1 

Menu