I've been playing with device mapper, and it seems it is not only a dark
and arcane art, but documentation is lacking too. Shame because you can do some groovy things with it.
extract from www.archivum.info/linux.kernel/2006-03/msg01108.html
Say you have a read-only block-device (say a cd-rom) at /dev/hdc. And you have a small disk partition, /dev/hdb1, that you want to use for your "COW file".
Run: cow_size=`blockdev --getsize /dev/hdc` chunk_size=64 # Size of each copied-on-write chunk, in 512 byte sectors cow_name="my_cow_dev" echo "0 $cow_size snapshot /dev/hdc /dev/hdb1 p $chunk_size" | \ dmsetup create $cow_name his will give you a device called /dev/mapper/$cow_name. Presuming
/dev/hdc
has a filesystem on it, you can mount /dev/mapper/$cow_name and get a read-write version of the filesystem on /dev/hdc, where updates to the filesystem will be stored on /dev/hdb1. The size of /dev/hdb1 can be significantly smaller than /dev/hdc, depending on the amount of writes you expect to happen on /dev/mapper/$cow_name. While this device is active,
don't
try to mount /dev/hdc read-write (assuming that's possible), or it will corrupt the view of /dev/mapper/$cow_name. If you need read-write access
to
both devices simultaneously, you'll probably just want to use LVM or EVMS
and
create snapshot volumes, since manually activating that kind of setup with dmsetup is incredibly tricky. Use "dmsetup remove $cow_name" to deactivate the device.

Delicious
Digg
StumbleUpon

