Q. When I run tar command it fails with an error that read as follows:
tar: /dev/st0: Cannot write: Invalid argument
How do I fix this error under CentOS / Debian / Fedora / RHEL Linux HP server systems?
A. You need to specify the block factor size. If you try to write a large file on tape this error may occur.
The data in an archive is grouped into blocks, which are 512 bytes. Blocks are read and written in whole number multiples called records. The number of blocks in a record (i.e., the size of a record in units of 512 bytes) is called the blocking factor.
Archives with blocking factors larger than 20 cannot be read by very old versions of tar, or by some newer versions of tar running on old machines with small address spaces. With GNU tar, the blocking factor of an archive is limited only by the maximum record size of the device containing the archive, or by the amount of available virtual memory.
How do I fix this error?
Set blocking factor to 256 to avoid this error with the -b option. For example, use the following command to backup the /webroot directory and its content to /dev/st0 with 256 blocking factor:
# tar cvf -b 256 /dev/st0 /webroot