|
The device /dev/sda2 can be formatted as a filesystem and
populated with lots of data:
# mkfs /dev/sda2
# mount /dev/sda2 /mnt/myfs
# cp .... lotsofdata .... /mnt/myfs
# umount /dev/sda2
This filesystem can now be mounted several times via the cowloop driver
to obtain multiple writable instances of the same filesystem:
# modprobe cowloop
# cowdev -a /dev/sda2 /fsdir/inst0.cow
/dev/cow/0 # the command returns this name now
# cowdev -a /dev/sda2 /fsdir/inst1.cow
/dev/cow/1 # the command returns this name now
# cowdev -a /dev/sda2 /fsdir/inst2.cow
/dev/cow/2 # the command returns this name now
# cowdev -l
cowdevice read-only file copy-on-write file
---------------------------------------------------
/dev/cow/0 /dev/sda2 /fsdir/inst0.cow
/dev/cow/1 /dev/sda2 /fsdir/inst1.cow
/dev/cow/2 /dev/sda2 /fsdir/inst2.cow
# mount /dev/cow/0 /mnt/fs0
# mount /dev/cow/1 /mnt/fs1
# mount /dev/cow/2 /mnt/fs2
# df
Filesystem 1K-blocks Used Available Use% Mounted on
....
/dev/cow/0 2016044 1057832 855800 56% /mnt/fs0
/dev/cow/1 2016044 1057832 855800 56% /mnt/fs1
/dev/cow/2 2016044 1057832 855800 56% /mnt/fs2
Every instance can be modified independent of the other instances,
while the underlying filesystem on device /dev/sda2
will not be modified at all.
|