Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to be able to mount and read on the fly a compressed dd image. I think that cloop is what I need. But I don't see it in /lib/modules and, anyway, I'd like to know how it works first.

Anybody has already managed to mount a compressed image and read it on the fly via cloop?

share|improve this question
up vote 1 down vote accepted

Unfortunately Ubuntu 12.04 doesn't include the cloop.ko module needed to have a compressed loopback device. However, it's very easy to add it to the running kernel.

I found it on this page (not sure if it's the latest version but compiles and works well), so I wget'd and uncompressed this file. The configure seems to be already included inside the Makefile so running:


is enough to build the module correctly. The package also contains the advfs utility, the original name for the command create_compressed_fs whose synopsis can be found here.

I copied the modules in /lib/modules with:

sudo cp cloop.ko /lib/modules/`uname -r`

but this step is not mandatory. Then one can choose to use the advfs or install the ubuntu package cloop-utils that provides the same utility with another name. I chose the package option because it's cleaner (I also suggest to install pv to have a nice progress bar):

sudo aptitude install cloop-utils pv

Now the compressed image can be created through the create_compressed_fs utility, and can be subsequently assigned to the /dev/clooop0 device passing the filename as parameter to the module cloop.ko. Honestly I didn't find a better way to pass the filename to the cloop module and this poses a problem if one wants to mount multiple compressed images in different time frames. However, for the moment I don't have this problem, so this script has been more than adequate for my needs.

#/bin/sh -e

#COMPRESSIONLEVEL="-1" # for 7zip compression (untested)


insmod /lib/modules/`uname -r`/cloop.ko file="$OUTPUTFILE"

mount -o ro /dev/cloop0 /mnt/cloop

Some other information can be found on the Knoppix wiki about cloop devices, here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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