Pre-liminary investigation into cowloop

Alexander E. Patrakov patrakov at
Mon Sep 5 20:55:57 PDT 2005

Jeremy Huntwork wrote:
> Hey all,
> Playing around with cowloop a little bit. Not quite sure the best way to 
> set it up. But I did manage to hack the kernel a bit so that we can 
> build it right into the kernel instead of as a module. (If you don't 
> know cowloop - it does the same thing as unionfs.)
> Attached, for anyone that wants to play with it.

I think we should say "no" to cowloop. The maintainer doesn't answer 
support requests (about sleeping with the spinlock). The same 
functionality is available from device-mapper. Shell example (needs 
full-blown device-mapper in the kernel, or the "dm-mod", "dm-linear", 
"dm-zero" and "dm-snapshot" drivers loaded):

1. Prepare the read-only 1GB ext2 image:

dd if=/dev/null of=read-only.img bs=1M seek=1024
mke2fs read-only.img
mount -o loop read-only.img /mnt/image
cp -a /junk /mnt/image
umount /mnt/image
e2fsck -f read-only.img

2. Use it:

# Create device-mapper nodes:
dmsetup mknodes

# Create loop device with 1 GB of ext2
losetup /dev/loop0 read-only.img

# Add 1GB of zeroes (optional).
# The wanted amount of added space depends on the RAM size.
dmsetup create extended-img <<"EOF"
0 2097152 linear /dev/loop0 0
2097152 2097152 zero

# Create a 2G sparse file on tmpfs and a loop for it
dd if=/dev/null of=back.img bs=1M seek=2048
losetup /dev/loop1 back.img

# Create a snapshot volume
dmsetup create read-write <<"EOF"
0 4194304 snapshot /dev/mapper/extended-img /dev/loop1 p 8

# Now use the read-write volume, e.g. by resizing the ext2 fs to 2GB...
resize2fs /dev/mapper/read-write

# and copying more files:
mount /dev/mapper/read-write /mnt/image
cp -a /junk2 /mnt/image

BTW we can use cloop instead of /dev/loop0 for compression at the second 

Alexander E. Patrakov

More information about the livecd mailing list