I guess that w/o compression extraction of a specific folder will be faster.
Sadly, that's impossible, due to the nature of compression and the tar file format. To know where a file is, you need to decompress the whole compressed file: everything before the file to know where it starts, and everything after the file, because tar
allows for keeping the same file around multiple times, so that you the "later" copy of the same file overwrites the earlier one. Only when you decompressed the last file you can be sure there's no further copies of the file.
So, the only thing you can do is decompress faster, using the parallel bzip2 implementation pbzip2
(you might need to install that first!)
pbzip2 -d -c large.tar.bz2 | tar xf - path/to/specific/folder
For future archiving: there's things that compress as well or nearly as well as bzip2
and allow for much faster decompression. So, if this problem occurs more often, it might make sense to re-archive the whole thing using something that allows for faster decompression, and for selective extraction without having to decompress the whole archive; something like
pbzip2 -d -c large.tar.bz2 | sqfstar -comp zstd -xattrs -Xcompression-level=8 large.sqsh
(In addition to pbzip
, you'll need sqfstar
, which on most systems (fedora-based, debian-based) is part of the squashfs-tools
package)
Bonus: these archives can directly be mounted, but you can also use a command line tool to get individual files from them.
udisksctl loop-setup -f large.sqsh # note the displayed block device name
udisksctl mount -b /dev/loop1234 # only if not automounted by previous command
tar
has no index up front. To find the part you want to decompress, you need to decompress the whole compressed file: everything befroe the file to know where it starts, and everything after the file, becausetar
allows for keeping the same file around multiple times, so that you the "later" copy of the same file overwrites the earlier one. Only when you decompressed the last file you can be sure there's no further copies of the file. – Marcus Müller Dec 27 '23 at 18:12bzcat foo.tar.bz2 | tar -xvf -
– Paige Thompson Dec 27 '23 at 22:41