Cow Script

From CSLabsWiki
Revision as of 23:58, 16 November 2016 by Northug (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Cow Script

This Script creates 8 Copy on write devices and sets up vblade servers hosting the devices. These devices are backed by the original image specified. If the system is shutdown, or interupted, the script can be run again and all changes will be preserved. To reset any changes, shut down the system, delete the file $FILE.cow.$loopnumber. and rerun the script. This script can be modified to iterate over a list of mac addresses and bind each vblade a specific mac address.

 modprobe dm_mod
 modprobe dm_mirror
 modprobe dm_snapshot


 img_loop_dev=`losetup -f`

 losetup -v -f $IMAGE_FILE

 cow_size=`blockdev --getsize $img_loop_dev`
 echo $cow_size


 for loopnumber in 0 1 2 3 4 5 6 7 
 dd if=/dev/zero of=$FILE.cow.$loopnumber bs=512 count=0 seek=$cow_size
 COWLOOPDEV=`losetup -f`
 losetup -v -f $FILE.cow.$loopnumber
 echo "0 $cow_size snapshot $img_loop_dev $COWLOOPDEV p $chunk_size" | dmsetup create $FILE.cow.$loopnumber

 vblade 0 $loopnumber eth0 /dev/mapper/$FILE.cow.$loopnumber &

 echo $COWLOOPDEV  is attached to $FILE.cow.$loopnumber

 losetup -a
 dmsetup table