archivemount
allows you to mount tar archives without extracting them. You can then just compress the contained files as if they were laying around anywhere else. I've not used it many times. And I think its website went down quite a while ago, maybe not the best sign.
If you're not set on 7z but could use a similarly well-compressing tool, which on top of all also allows you to generate archives that retain all permissions, can be mounted by any modern Linux out of the box (i.e. without installing third-party userland filesystems like archivemount
):
mksquashfs my_new_compressed_archive.squash -comp zstd -tar < 100GB.tar
# | target archive name | |compressor| |read tar| |read from this file|
# | \______
# |use -comp lzma |
# |to use the same |
# |compressor as 7z.|
# |Usually, zstd is |
# |a good choice, as|
# |it's not as slow |
# |as LZMA/7z at |
# |reasonable com- |
# |pression ratios. |
# |Also, unlike LZMA|
# |zstd-compressed |
# |squashfs can be |
# |mounted by the |
# |Linux kernel. |
# \~~~~~~~~~~~~~~~~~/
You can then mount your freshly created archive even as normal user:
udiskctl loop-setup -f my_new_compressed_archive.squash
tar
archive withpixz
, beside getting better compression than7zip
, you can do random access to individual files. – Stéphane Chazelas Feb 01 '23 at 19:39