From: Kevin Corry <kevcorry@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: "roland" <devzero@web.de>
Subject: Re: is there a COW inside the kernel ?
Date: Fri, 3 Mar 2006 08:28:59 -0600 [thread overview]
Message-ID: <200603030828.59567.kevcorry@us.ibm.com> (raw)
In-Reply-To: <043101c63e9c$86e9d710$0200000a@aldipc>
On Fri March 3 2006 2:29 am, roland wrote:
> hello !
>
> is there an equivalent of something like
>
> cowloop ( http://www.atconsultancy.nl/cowloop/total.html ) or md based cow
> device ( http://www.cl.cam.ac.uk/users/br260/doc/report.pdf ),
>
> i.e. a feature called "Copy On Write Blockdevice" inside the current or the
> near-future mainline kernel (besides UserModeLinux Arch)?
Device-Mapper has a snapshot module, which is used by LVM and EVMS. You can
also use dmsetup if you want lower-level access than provided by the volume
managers. To do the equivalent of the cowloop driver that you linked to
above, you could do something like this:
Say you have a read-only block-device (say a cd-rom) at /dev/hdc. And you have
a small disk partition, /dev/hdb1, that you want to use for your "COW file".
Run:
cow_size=`blockdev --getsize /dev/hdc`
chunk_size=64 # Size of each copied-on-write chunk, in 512 byte sectors
cow_name="my_cow_dev"
echo "0 $cow_size snapshot /dev/hdc /dev/hdb1 p $chunk_size" | \
dmsetup create $cow_name
This will give you a device called /dev/mapper/$cow_name. Presuming /dev/hdc
has a filesystem on it, you can mount /dev/mapper/$cow_name and get a
read-write version of the filesystem on /dev/hdc, where updates to the
filesystem will be stored on /dev/hdb1. The size of /dev/hdb1 can be
significantly smaller than /dev/hdc, depending on the amount of writes you
expect to happen on /dev/mapper/$cow_name. While this device is active, don't
try to mount /dev/hdc read-write (assuming that's possible), or it will
corrupt the view of /dev/mapper/$cow_name. If you need read-write access to
both devices simultaneously, you'll probably just want to use LVM or EVMS and
create snapshot volumes, since manually activating that kind of setup with
dmsetup is incredibly tricky.
Use "dmsetup remove $cow_name" to deactivate the device.
> i would find this useful for several purpose, but i don`t want to patch my
> system with 3rd party drivers or "non-standard" stuff - or even recompile
> the kernel.
This should work with any recent 2.6 kernel. You'll also need to have the
device-mapper package installed, which should be available with any recent
Linux distro.
--
Kevin Corry
kevcorry@us.ibm.com
http://www.ibm.com/linux/
http://evms.sourceforge.net/
next prev parent reply other threads:[~2006-03-03 14:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-03 8:29 is there a COW inside the kernel ? roland
2006-03-03 13:33 ` Jan Engelhardt
2006-03-03 14:19 ` Alasdair G Kergon
2006-03-03 14:28 ` Kevin Corry [this message]
2006-03-03 21:29 ` roland
2006-03-03 22:39 ` Kevin Corry
2006-03-04 5:35 ` Jon Masters
2006-03-03 15:25 ` Jeff Dike
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200603030828.59567.kevcorry@us.ibm.com \
--to=kevcorry@us.ibm.com \
--cc=devzero@web.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox