[dm-devel] Re: [RFC][PATCH] dm-cow: copy-on-write stackable target for device-mapper

Eric Van Hensbergen ericvh at gmail.com
Fri Jan 26 17:07:28 UTC 2007


On 11/27/06, Eric Van Hensbergen <ericvh at hera.kernel.org> wrote:
> Subject: [RFC] [PATCH] dm-cow: copy-on-write stackable target for device-mapper
>
> +
> +A simple script file is included to format WB.
> +The way it works is the standard dmsetup calls for
> +the device mapper. The arguments are
> +

There have been several requests for the "simple" script file.
Portions of its implementation are somewhat specific to our
installation (like the use of the rc shell).  I'm including it inline
here - not sure where else to put it -- perhaps in the Documentation:

#!/usr/bin/rc

tableboth ='0 devblksz cow devread 0 devwrite devbmapw 0'
devsize = `{sfdisk -s $1}

fn wipeoutdev{
        bmapsize = `{echo $devsize / 512 /2 |bc}
        echo dd 'if=/dev/zero' 'of='^$1 'count='^$bmapsize 'bs=512'
        dd 'if=/dev/zero' 'of='^$1 'count='^$bmapsize 'bs=512'
}

fn escapedev{
    echo $1|sed 's/\//\\\//g'
}


fn setcow{
        devread = `{escapedev $1}
        devwrite = `{escapedev $2}
        devbmapw = `{escapedev $3}
        tableset = `{echo $tableboth|sed -r 's/devread/'^$devread^'/'}
        tableset = `{echo $tableset|sed -r 's/devwrite/'^$devwrite^'/'}
        tableset = `{echo $tableset|sed -r 's/devbmapw/'^$devbmapw^'/'}
        devblksz = `{expr $devsize '*' 2}
        tableset = `{echo $tableset|sed -r 's/devblksz/'^$devblksz^'/'}
        echo trying to set $tableset
        echo $tableset > /tmp/tableset
        echo trying to dmsetup create $4
        dmsetup create $4 << EOF
$tableset
EOF
        dmsetup table
}

if(! ~ $#* 4){
        echo usage: newcow origdev destdev bmapdest namecow
        exit 1
}

namecow=$4
origdev=$1
wipeoutdev $2
setcow $1 $2 $3 $namecow




More information about the dm-devel mailing list