According to this page, one can let tar create a tar archive "split" into 100 Mb files:

tar -c -M --tape-length=102400 --file=disk1.tar largefile.tgz

The problem is that this command will require you to interactively give a new filename for the next file, after the first file is filled.

Anybody knows of a way to skip this interactive step, and let tar do the "splitting" automatically?

link|improve this question
feedback

migrated from serverfault.com May 31 '11 at 13:51

This question came from our site for system administrators and desktop support professionals.

2 Answers

up vote 4 down vote accepted

Take a look at the --new-volume-script option, which lets you replace the prompting mechanism with a different mechanism or with a generated filename. ((tar.info)Multi-Volume Archives in the tar info page.) The problem with split is that you need to cat the pieces back together to do anything, whereas a multivolume archive should be a bit more flexible.

link|improve this answer
That's true, of course. – Eduardo I. May 31 '11 at 14:00
Thanks, this is what I was looking for! I now found out that there is actually some instructions (incl. example) available here: gnu.org/software/tar/manual/tar.html#Using-Multiple-Tapes – Samuel Lampa Jun 1 '11 at 9:17
feedback

You can use split for this:

tar czpvf - /path/to/archive | split -d -b 100M - tardisk

This tells tar to send the data to stdout, and split to pick it from stdin - additionally using a numeric prefix (-d), a chunk size (-b) of 100M and using 'disk' as the base for the resulting filenames (tardisk00, tardisk01, etc.).

To extract the data afterwards you can use this:

cat tardisk* | tar xzpvf -
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.