How to split tar archive into multiple blocks of a specific size - LinuxConfig.org

Tar archives can be split into multiple archives of a certain size, which is handy if you need to put a lot of content onto discs. It's also useful if you have a huge archive that you need to upload, but would rather do it in chunks. In this guide, we'll show you the commands you need in order to split tar archives into multiple blocks on a Linux system.

This will work regardless of what type of compression (or lack thereof) that you use.


This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-split-tar-archive-into-multiple-blocks-of-a-specific-size

Is there a way to split a tar archive into multiple blocks without corrupting any of the blocks? Your method failed for me on Ubuntu 18 and Ubuntu 22.

I followed instructions to create a split tarball from a directory:
tar cvzf - my_dir/ | split --bytes=200MB - my_chunk_files.tar.gz.

Restore fails:
cat my_chunk_files.tar.gz.*| tar xvfz -
throws:
gzip: stdin: not in gzip format
tar: Child died with signal 13
tar: Error is not recoverable: exiting now

  1. I checked with md5sum that no chunk was corrupted during transfer.
  2. I tried restoring on the same machine where the split was done: same “not in gzip format” error.
  3. I tried listing all the chunk files explicitly after ‘cat …’ in order. Still same error.
  4. I first did the cat, and then tried to gunzip: same error. I tried to omit the ‘z’ option and got: “tar: This does not look like a tar archive; tar: Skipping to next header”

Any suggestions?

Hi Isaphan,

Welcome to our forums.

I have tested this on Ubuntu 20.04 and works like a charm. Can you show us the list of the generated blocks on the target side? I’m thinking of ls -al or similar list.