Maximum number of files you can store in a tar archive under Solaris 11

gnulimitsolaristarzfs

I need to store a large number of files (> 100,000) in a tar archive and have run into the error: /bin/sh: /bin/tar: cannot execute [Arg list too long].

Are there limits with UNIX Solaris tar or GNU tar? Or, is this a ZFS issue? I am running Solaris 11.3 with ZFS.

Best Answer

This is not a limitation of tar. You are exceeding the maximum size of arguments that can be passed to a program. If the list of file names is available in a file, then you can use GNU tar's -T option:

tar -c -f output.tar -T filelist.txt

Tar can also receive the file list from standard input by using - as the file name. For example, if you want to create an archive containing all files and subdirectories of mydir, you can pass the output of find to tar:

find mydir | tar -c -f output.tar -T -
Related Question