Yes, using the compression flags in the tar
command directly (eg, tar czf
) will reduce intermediate disk usage as it does not create any temporary uncompressed tar file, but rather uses pipes to pass the stdout of tar directly to stdin of the compression utility.
Depending on how pipes are implemented on your particular system, tar
might appear to be writing a file, but that file will actually be a FIFO queue with no appreciable space consumption.
Without the flag:
Files > tar = original files + .tar the same size
.tar > gzip = .tgz = original files + .tar + .tgz
Total disk usage just before deleting the .tar is 2-3x the original files depending on the compression ratio.
With the flag:
Files > tar > gzip = files + .tgz
Worst case usage is 2x the original files.