Compressing an ISO File?

I made an ISO file of my entire disk using dd before making a lot of partition changes to my hard drive. The file is about 1TB downstairs on my server, but the file size is too large to keep around.

Is there any way to compress this file (a lot of it is empty space as only about 450GB was actual data on the HDDs at the time of copy)

Is there any way to compress this file so that it is a bit more manageable for storage?

Bash answers are as ok as software GUI answers :smiley:

In theory, you can compress any file ─ provided that it wasn’t already compressed to the limit earlier ─ and thus you can indeed compress that .iso file, but ─ and here it comes ─ doing so would not make it readable anymore, because an .iso file is a filesystem image, and therefore also needs to be read as a filesystem. Compressing the file will completely distort its internal filesystem organization.

:man_shrugging:

Ok, got it thanks :smiley:

1 Like

What you could do ─ if it fits your intended purpose ─ is mount the .iso file via loopback, and then make a proper backup of the contents of the .iso on your server by way of a regular backup and/or archiving tool, which will be able to compress things.

The most common/portable UNIX method would be to create a .tar.bz2 or .tar.xz archive. The tool you need for that is GNU tar ─ with the correct options, it’ll invoke gzip2 or xz ─ which already exists on your system because it’s part of the GNU coreutils package.

See… :arrow_down:

man tar

… for details. :wink:

1 Like

You could make use of https://wiki.archlinux.org/index.php/Sparse_file#Making_existing_files_sparse (fallocate -d) :wink: