When I use tar
to archive a directory and then compress it separately using e.g. xz
, there will be a point where I have three files on my system - dir
, dir.tar
and dir.tar.xz
. As soon as the compression is completed, dir.tar
is deleted, but it seems like I must still make sure I have enough free disk space to accommodate all three files in this setup.
When using the compression flag with tar directly, there compressed file is created without an observable .tar
intermediate and it appears I only need free space equal to the directory and the compressed file.
I was initially hypothesizing that maybe the tar archive was created and deleted bit by bit as it was compressed, but at the same time, I remember reading somewhere that the entire tar archive needs to be created before compression. I can't observe any temporary tar file, hidden or not.
Does using tar with a compression flag, actually need less free disk space than when first using tar followed by a compression utility? Why/why not (maybe a step by step of what tar+compression flag does)?