Linux tar: /dev/st0: Cannot write: Invalid argument error and solution

Q. When I run tar command it fails with an error that read as follows:

ADVERTISEMENTS

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

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • nery gurl Jan 11, 2010 @ 17:03

    hi! I just want to ask how could I restore Linux OS to my netbook. I encountered a problem when I change my OS to WXP (NTLDR error) so I try to recover it back to linux but then when Im trying to do it has an error “invalid argument” I hope that you would somehow help me solve my problem.

    • Yang Oct 13, 2015 @ 11:05

      Have u got your problem resovled ?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.