Why can't backup file to the tape device with tar command?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5.x
  • IBM 43w8478 tape
  • 20/40G 4mm dds-150

Issue

When using tar command to backup file to a tape device, the system prompts "Cannot write: Input/output error"

    #tar cvf /dev/st0 ./install.log
    tar: /dev/st0: Cannot write: Input/output error
     tar: Error is not recoverable: exiting now
  • While trying to backup big files (>3GB) to the tape device, getting the following message:
tar: /dev/st0: Wrote only 8192 of 10240 bytes
tar: Error is not recoverable: exiting now

Resolution

  • Setting the block size before using the tar command.

For example:

    #mt -f /dev/st0 setblk  1024

Root Cause

The data writes to the tape is too much. The log in /var/log/message file:

    Jun 21 09:53:49 localhost kernel: aacraid: SCSI CMD Data Overrun
    Jun 21 09:53:49 localhost kernel: st0: Error 70000 (sugg. bt 0x0, driver bt 0x0, host bt 0x7).

The error message "SCSI CMD Data Overrun" means the data is too big to finish the I/O operation.

Check the result of strace command to confirm the real block size which is used to do the I/O operation.

    #strace -o /tmp/tar_in.strace -tt -f tar cvf/dev/st0 ./install.log
    13337 10:34:58.925977 getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM_INFINITY}) = 0  
    13337 10:34:58.936509 write(3, "install.log\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 10240) = -1 EIO (Input/output error)

From the above result, the block size is 1024.

Diagnostic Steps

1.Check the hardware of tape device.

2.Make sure open the write-protect mode.

3.Check the tape device's status.

For example:

    #mt -f /dev/st0 status
    SCSI 2 tape drive:
    File number=0, block number=0, partition=0.
    Tape block size 0 bytes. Density code 0x44 (no translation).  //Tape block size 为0 bytes
    Soft error count since last status=0
    General status bits on (41010000):

    BOT ONLINE IM_REP_EN

4.Using cpio command to confirm if the tape device works well.

For example:

#find install.log | cpio -ov -H newc > /dev/st0

5.Using strace command to track the backup process.

    #strace -o /tmp/tar_in.strace -tt -f tar cvf/dev/st0 ./install.log
    13337 10:34:58.925977 getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM_INFINITY}) = 0
    13337 10:34:58.936509 write(3, "install.log\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 10240) = -1 EIO (Input/output error)

6.Please see the log in /var/log/messages file.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.