2

I have an Operating system image of size 2.5G.

I have a device with a limited size. Thus I was looking for the best possible solution for providing the compression.

Below are the commands and results of their compression:

1.tar with gzip:

tar c Os.img | gzip --best > Os.tar.gz

This command returned an image of 1.3G.

2.Xz only:

xz -z -v -k Os.img

This command returned an image of 1021M.

3.Xz with -9:

xz -z -v -9 -k Os.img

This command returned an image of 950M.

4.tar with Xz and -9:

tar cv Os.img | xz -9 -k > Os.tar.xz

This command returned an image of 950M.

5.tar with Xz -9 and -e:

xz -z -v -9 -k -e Os.img

This command returned an image of 949M.

6.lrzip:

lrzip -z -v Os.img

This command returned an image of 729M.

Is there any other possible best solution or command line tool ( preferable ) for the compression?

  • 2
    Using tar will not make much difference as it's a single file. The tar utility will not compress the file differently from what you would do if you first created the tar archive and then compressed it, in two steps. – Kusalananda Mar 12 at 14:55
  • 1
    What portability do you need? The methods with highest compression need more RAM also for extraction (decompression). – sudodus Mar 12 at 15:32
  • See here (which is still valid... no groundbreaking algorithms have appeared since). – xenoid Mar 12 at 15:48
2

You may try out zstandard:

Highest "standard" compression option: zstd -19 -c Os.img >Os.img.zstd

Highest ultra compression option: zstd -22 --ultra -c Os.img >Os.img.zstd

Your mileage may vary, but if compression time is not important, but size matters, than zstd is your friend.

  • 1
    adding --long=31 to that list might improve things even more, if there is some long distance deduplication available within the image. – Cyan Mar 14 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.