Rahul Sharma (Editor)

Cloop

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Original author(s)
  
Rusty Russell

Size
  
338K

License
  
GNU GPL v2

Developer(s)
  
Klaus Knopper

Type
  
Loadable kernel module

Stable release
  
2.637-1 / 12 January 2011; 6 years ago (2011-01-12)

The compressed loop device (cloop) is a module for the Linux kernel. It adds support for transparently decompressed, read-only block devices. It is not a compressed file system.

Contents

Cloop was originally written for the Levanta Bootable Business Card by Rusty Russell, but is now maintained by Klaus Knopper, the author of Knoppix. Cloop is mostly used as a convenient way to compress conventional file systems onto Live CDs.

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.

Design

cloop images contain:

  • A shell script (with mount commands for the image)
  • A header with the number of blocks and the uncompressed block size
  • A seek index with compressed and uncompressed block sizes in pairs
  • zlib-compressed data blocks, packed end-to-end
  • The data blocks are compressed separately; this makes it possible to seek to individual blocks without having to decompress the entire image from the start, but at the cost of slightly reducing the compression ratio. Live CD images typically use a block size of 256k as a compromise between decompression speed and space-efficiency.

    Apple uses a similar file format in the compressed variant of its DMG disk images.

    Limitations

    The design of the cloop driver requires that compressed blocks be read whole from disk. This makes cloop access inherently slower when there are many scattered reads, which can happen if the system is low on memory or when a large program with many shared libraries is starting. A big issue is the seek time for CD-ROM drives (~80 ms), which exceeds that of hard disks (~10 ms) by a large factor. On the other hand, because files are packed together, reading a compressed block may thus bring in more than one file into the cache. The effects of tail packing are known to improve seek times (cf. reiserfs, btrfs), especially for small files. Some performance tests related to cloop have been conducted.

    References

    Cloop Wikipedia