For every cowdevice the combination of a read-only file and a cowfile
should be assigned.
This assignment can be made dynamically (while the cowloop module is loaded)
with the command
this command can also be used to deactivate a cowdevice again.
For the first cowdevice an assigment can be made already during
of the cowloop module by specifying one read-only file
and one cowfile as parameters for the
Every combination of a read-only file and corresponding cowfile is made
available as a new cowdevice
(e.g. two independent cowdevices
/dev/cow/1 in the figure below).
The cowloop driver accesses the read-only file as a sequence of 1 Kb blocks.
Concerning the example of cowdevice
/dev/cow/0 in the
Initially every block read from this device is retrieved from the
read-only file (e.g. block 3).
When a block is written to the cowdevice, the cowloop driver writes
the block to the copy-on-write file.
On reading, the cowloop driver first examines the cowfile
to see whether a modified version of the requested block is present.
Hence modified blocks are retrieved from the cowfile (e.g. block 1),
otherwise the original block is retrieved from the read-only file
(e.g. block 2).
Suppose that the underlying read-only file contains a filesystem,
it can be mounted read-write with the command
mount /dev/cow/0 /mnt/fs0
All modifications on data-blocks and metadata-blocks of the filesystem are
written to the copy-on-write file. After the filesystem has been unmounted
and the cowdevice deactivated,
the read-only file still contains the original (untouched) filesystem.
However when it is used in combination with the cowfile via the
cowloop driver, the modified filesystem appears again.