0

I have a large disk image that I don't need to access now, but I might in the future. I'd like to compress it, but without needing to fully decompress it to read it. If I compress it with an algorithm that allows random access (like bzip2), could I then mount the compressed file to my file system such that it looks like the decompressed file, but reads from it actually use the contents of the compressed file?

I thought of creating a command-backed virtual file, to which the answer is either named pipes (which won't work because filesystem access is random) and a FUSE-based filesystem (which seems like too much complexity for this task).

Danya02
  • 111
  • 2
    Use squashfs. It does all this, and you can pick the compression algorithm with the best compression / speed trade off for your needs. – user10489 Aug 31 '22 at 11:16
  • (note that I agree with @user10489, you should either just put the image as the single file into a squashfs file system, mount that, then mount the image, or you could, and that makes more sense, use squashfs to store whatever is stored in your image.) – Marcus Müller Aug 31 '22 at 12:03
  • @MarcusMüller for this particular task I'd like to store the binary contents of the disk (because I might later need to do disk forensics on it) but I suppose that storing the files themselves instead might work better in most cases. – Danya02 Aug 31 '22 at 13:21
  • 1
    @Danya02 in that case, make a squashfs containing nothing but the image :) – Marcus Müller Aug 31 '22 at 13:42

0 Answers0