How can I compress dd images and work with them at the same time?
On Windows, I can mark it as compressed and work with it like a normal file.
I can't re-partition, but I can mount some drives (For example
You can mount these images in compressed state. Caveat: Read-Only. Also, you have to specifically create them, sda1.img.gz wont just mount.
In an nutshell:
# create_compressed_fs - blocksize < /dev/xyz > imageName.cloop # insmod cloop.ko file=/path/to/imageName.cloop # mount -o ro -t whatever /dev/cloop /mnt/compressed
You could convert an existing image with this as a first step:
# gunzip oldImg.gz |create_compressed_fs - blocksize > imageName.cloop
Attention: Make sure you have enough Virtual Memory. (see README)
About the achievable Compression ratio: https://en.wikipedia.org/wiki/Cloop:
A compression ratio of about 2.5:1 is common for software. The Knoppix cloop image, for example, is 700MB compressed and around 1.8GB uncompressed.
This module has seen multi-year production use, due to its use e.g. on the Knoppix Linux live Boot-Disk. Packaged/updated regularly since 2005. Software seems mature, e.g.
README was last modified 2008,
# mkdir empty-dir # mksquashfs empty-dir squash.img -p 'sda_backup.img f 444 root root dd if=/dev/sda bs=4M' # mount squash.img /mnt/compressed
I suppose that
dd image means a compressed copy of some partition that contained a filesystem.
In general, you can't mount such a compressed image, as it is not suitable for random access. You would need to decompress it, then you can mount it and access the filesystem.
If you want a filesystem which compresses data automatically (like the
Windows filesystem you mentioned) have a look at
BTRFS. But to use that, you need to create a partition, so it might not be an option for you.
To create a compressed image on the fly:
gzip < /path/to/inpurt >/path/to/image.gz
To read a compressed image on the fly:
zcat /path/to/image.gz > /path/to/output