Copy on Write Vblade Server

If you want to support a lot of aoe clients, then using a copy on write device may be the answer for you. I've written a small script that will setup your loop device and device mapper configration for you. It will also run vblade and link the approite cow block device with a aoe instance.

For more information on how copy on write works goto http://en.wikipedia.org/wiki/Copy_on_write

Here's a Diagram of how the scripts set things up (showing 4 cow devices) Dash Disks represent Virtual Device, Solid disk represent sparse files on disk.

:holycow.png

#Copy on write for vblade server v0.5
#toxicnaan guess what goes here gmail.com
#this uses raw device mapper commands, if your using either LVM,LVM2,DM,LOOP
#then run it at your own risk!
#This will be like crossing the streams, it will be bad, very bad.
#don't run this if you don't understand whats going on
#if this script murders your dog/cat, deletes your server, or causes a war
#you can't blame me.
 
#useage makecow.sh 'image file name'
#image file name is an image that you want booted over aoe.
 
#takes a current imagefile, and makes 8 cow devices using loop and devicemapper
#it uses sparse files to cut down on diskspace
#using this script allows for many machines booting over aoe to use
#the same primary disk image.
#all writes your clients with go into the cow files.
 
#you need to be root to run this.
#for extra fun, try placing your cow files on a suitable large ram disk
#like /dev/shm for extra speeeeeeeeeeeeeed!
#vblade dirly run in background, targets range from 0 0 to 0 7.
 
#big greets to the masters of #etherboot on freenode. Thanks for all
#your help getting gpxe working for me!!!!!!
#no thanks to device mapper documentation!!!!
 
 
modprobe dm_mod
modprobe dm_mirror
modprobe dm_snapshot
 
IMAGE_FILE=$1
 
img_loop_dev=`losetup -f`
 
losetup -v -f $IMAGE_FILE
 
cow_size=`blockdev --getsize $img_loop_dev`
echo $cow_size
chunk_size=64
 
FILE=$IMAGE_FILE
 
for loopnumber in 0 1 2 3 4 5 6 7 
do
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
done
 
losetup -a
dmsetup table

Same diagram but in Ascii.

Converted to PNG with http://ditaa.sourceforge.net/

                              -----------------------------
                              |--/dev/mapper/Image.cow.0--|
                       |----/----------+       /-----------+      
                       |    :{s}       |       |{s}        |--vblade eth0
                       |    |/dev/loop1|------>|Image.cow.0|  0 0
                       |    +----------/       +-----------/
                       |
                       |      -----------------------------     
/-----------+          |      |--/dev/mapper/Image.cow.1--|
:{s}        |          |----/----------+       /-----------+
|           |          |    :{s}       |       |{s}        |--vblade eth0
|           |    COW   |    |/dev/loop2|------>|Image.cow.1|  0 1
|/dev/loop0 |----------|    +----------/       +-----------/
|           |          |
|           |          |      -----------------------------
|           | SNAPSHOT |      |--/dev/mapper/Image.cow.2--|
|READ ONLY  |          |----/----------+       /-----------+
+-----------/          |    :{s}       |       |{s}        |-->vblade eth0
      |                |    |/dev/loop3|------>|Image.cow.2|   0 2
      |                |    +----------/       +-----------/
      |                |
/-----------+          |      -----------------------------
|{s}        |          |      |--/dev/mapper/Image.cow.3--|
|Image.img  |          |----/----------+       /-----------+
+-----------/               :{s}       |       |{s}        |-->vblade eth0
                            |/dev/loop4|------>|Image.cow.3|   0 3
                            +----------/       +-----------/   
                              
/--------------------------------------------\
|             dmsetup table                  |
|Image.cow.3: 0 8193150 snapshot 7:0 7:4 P 64|
|Image.cow.2: 0 8193150 snapshot 7:0 7:3 P 64|
|Image.cow.1: 0 8193150 snapshot 7:0 7:2 P 64|
|Image.cow.0: 0 8193150 snapshot 7:0 7:1 P 64|
\--------------------------------------------/
                       

Navigation

* [[:start|Home]] * [[:about|About our Project]] * [[:download|Download]] * [[:screenshots|Screenshots]] * Documentation * [[:howtos|HowTo Guides]] * [[:appnotes|Application Notes]] * [[:faq:|FAQs]] * [[:doc|General Doc]] * [[:talks|Videos, Talks, and Papers]] * [[:hardwareissues|Hardware Issues]] * [[:mailinglists|Mailing lists]] * [[http://support.etherboot.org/|Bugtracker]] * [[:contributing|Contributing]] * [[:editing_permission|Wiki Edit Permission]] * [[:wiki:syntax|Wiki Syntax]] * [[:contact|Contact]] * [[:relatedlinks|Related Links]] * [[:commerciallinks|Commercial Links]] * [[:acknowledgements|Acknowledgements]] * [[:logos|Logo Art]]

QR Code
QR Code appnotes:cow (generated for current page)