Are you facing the error 'tar /dev/st0 cannot write invalid argument'?
This guide will help you resolve it.
Recently, one of our customers approached us saying that he came across the error message "tar /dev/st0 cannot write invalid argument" while trying to take a backup using the tar command.
This error can occur while trying to write a large file on tape.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to resolve Linux command related errors.
In this context, we shall look into how to fix this Linux error.
As mentioned earlier, our customer ran the below command to take backup using the tar command:
# tar -cvf /dev/st0 /<directory>
As a result, he came across the below error message.
tar: /dev/st0: Cannot write: Invalid argument
tar: Error is not recoverable: exiting now.
While trying to write a large file on tape, this error can occur.
Here, the data in an archive is grouped into blocks, which are 512 bytes.
The 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.
Very old versions of tar cannot read the archives with blocking factors larger than.
Or some newer versions of tar running on old machines with small address spaces also can’t read them.
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.
Now let's take a look at how our Support Experts resolve this error message.
Here, we need to specify the block factor size.
So, we set the blocking factor to 256 to avoid this error with the -b option.
For example, use the following command to back up the /webroot directory and its content to /dev/st0 with 256 blocking factor:
# tar cvf -b 256 /dev/st0 /webroot
This article covers resolve errors relating to Linux commands. 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 to fix tar /dev/st0 cannot write invalid argument 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