IBM

Depending on the server configuration, you may see highlighted words. You may even see <hyperlinks> surrounding the highlighted words. The hyperlinks take you to the next or previous highlighted word.


Database Record DA74


ABSTRACT: Determining <Tape> <Block> <Size> and Format

 ABOUT THIS DOCUMENT

       The AIX Operating System supports <tape> devices with various
       <block> <sizes>.  <Tapes> written at one particular  physical
       <block> <size> may not be readable unless the <tape> device is
       reconfigured for that same <block> <size>.  This document
       describes how to determine the correct physical <block> <size>
       and how to determine the <tape> format (such as tar or
       backup/restore) in all versions of AIX.

  <BLOCK> <SIZE> DETERMINATION

       You can find the <tape> <block> <size> by configuring the device
       to accept a very large <block>, performing a single read, and
       determining the <size> of the read <block>, as in the following
       steps:

       1.  Begin by configuring the device for variable <block> <size>
           data:

              chdev -a block_size=0 -l <<tape>>

           where <<tape>> is the device, such as rmt0 or rmt1.

       2.  Next, read a single <block> from the device and write the
           <block> to disk.  This will allow you to see exactly how
           large the <block> is and what data is contained on the
           <tape>.

              dd if=/dev/<<tape>> of=/tmp/block bs=128k count=1

       3.  The data from the <tape> <block> will be in the file
           /tmp/block.  You can determine the <block> <size> by looking
           at the byte count with

              wc -c /tmp/block

           The <size> in bytes is the <size> of the physical <blocks> on
           the <tape>, assuming the <tape> was written with a single
           physical <block> <size>.

       4.  You can then use this <size> in the chdev command given
           above to configure the <tape> drive for the loaded <tape>.

      Please Note:  If you only need to determine the blocksize of
      the archive and want to avoid creating the temporary file,
      you can issue the following command:

      dd if=/dv/<<tape>> bs=128k count=1 | wc -c

  FORMAT DETERMINATION

       The "file" command can be used on the <block> of data that was
       read from the <tape> in the previous section (the /tmp/block
       file) to determine the format type of data on the <tape>.

          file /tmp/block

       The file command attempts to match header information in the
       file against known header types described in the /etc/magic
       file.  After a change to the /etc/magic file (described
       below), the file command will recognize tar, cpio, and
       backup/restore formats.

       However, on AIX versions previous to 4.1 and later, the file
       command will not recognize format types that do not have
       header information, such as dd and back-by-inode.  For
       example, if you used dd to put a compressed file on a <tape>
       and then followed the procedures in this document, the
       format would be recognized as compressed.

  Updating the /etc/magic file (not necessary for AIX 4.1 and later)

       To update the /etc/magic file so that tar and backup/restore
       formats can be recognized by the file command, do the fol-
       lowing:

       1.  Become the root user.

       2.  Make a backup copy of the /etc/magic file by running

              cp /etc/magic /etc/magic.backup

       3.  Add the following two lines to the bottom of the
           /etc/magic file.  Note that each line must start in the
           first column.

              257   string    0x7573746172   tar format file
              0     long      0x09006bea     backup/restore by name format file

  SHELL SCRIPT TO AUTOMATE <BLOCK> <SIZE> DETERMINATION

       This shell script provides a means of performing the <block>-
       <size> determination steps automatically.

       #!/bin/ksh
       #
       #        lstape -- List a <tape>'s <block> <size>
       #
       if [ $# -ne 1 ] ; then
               /usr/bin/echo 'usage: lstape device'
               exit 1
       fi
       #
       #        Check the name and put it in a standard format
       #
       if [[ "$1" = /dev/* ]]; then
               <TAPE>=${1##/dev/}
       else
               <TAPE>=$1
       fi
       #
       #        Set the <block> <size> to variable
       #
       /usr/sbin/chdev -l ${<TAPE>} -a block_size=0 >/dev/null
       if [ $? -ne 0 ]; then
               exit 1
       fi
       #
       #        Read a single <block> and write to /tmp
       #
       /usr/bin/dd if=/dev/${<TAPE>} bs=128k of=/tmp/lst$$ count=1
       if [ $? -ne 0 ]; then
               /usr/bin/rm -f /tmp/lst$$
               exit 1
       fi
       #
       #        Get the <block> <size> of the resultant file
       #
       /usr/bin/wc -c /tmp/lst$$ | read <SIZE> FILE
       /usr/bin/echo "$<TAPE>:        ${<SIZE>} bytes per <block>."
       if [ -x /usr/bin/file ] ; then
               /usr/bin/file /tmp/lst$$ | sed -e "s!/tmp/lst$$!/dev/${<TAPE>}!"
       fi
       #
       #        Set <tape> drive to correct physical <block> <size>
       #
       /usr/sbin/chdev -l ${<TAPE>} -a block_size=${<SIZE>} >/dev/null
       /usr/bin/rm -f /tmp/lst$$
       exit 0



  SPECIAL NOTICES

       Please use this information with care.  IBM will not be
       responsible for damages of any kind resulting from its use.
       The use of this information is the sole responsibility of
       the customer and depends on the customer's ability to eval-
       uate and integrate this information into the customer's
       operational environment.