Cloning ZFS-based domains

Introduction

If you're using a ZFS volume as the root disk for a domain, you can
make use of the snapshotting facilities to quickly "clone" another
domain with the same configuration. By taking a clone of the root disk,
you can very quickly provision similar domains, and even better, the
nature of the clone means the only extra storage used is that of
the differences between the domains.

We're working on ways of automating this procedure, but for now these
are the steps you'll need to take.

Step-by-step

First, we need to shutdown the domain we're cloning so we can take
a consistent snapshot of the disk:

xm shutdown -w domain1

Alternatively, you might want to do a sys-unconfig in the domain so
the new clone will come up with the configuration screens.

Now we take a snapshot of the root disk used by 'domain1', and then a
clone (writable snapshot) :

zfs snapshot pool/domain1-root@clone
zfs clone pool/domain1-root@clone pool/domain2-root

If you now do a zfs list, you should see the snapshot and clone
present, and using next to no additional disk space. For our last
step, we need to duplicate domain1's configuration. First dump
the configuration to a file:

virsh dumpxml domain1 >domain1.xml
cp domain1.xml domain2.xml

You will need to make at least three changes. First, you will want a
new name for your domain, so edit this line:

    <name>domain1</name>

with the new name:

    <name>domain2</name>

Second, you must remove the UUID line so virsh will generate a new
domain configuration. Remove the line that looks like this:

    <uuid>72bb96b6e6cf13594fb0cd1290610611</uuid>

Finally we have to point to the new disk by editing the following line:

    <source dev='/dev/zvol/dsk/export/domain1-root'/>

to be:

    <source dev='/dev/zvol/dsk/export/domain2-root'/>

Finally, tell virsh about the new domain:

virsh define domain2.xml

Now you can boot your cloned domain!

Tags:
Created by admin on 2009/10/26 12:11
Last modified by johnlev on 2009/10/28 23:56

Collectives

Project


© 2010, Oracle Corporation and/or its affiliates
XWiki Enterprise 2.1.1.25889 - Documentation
Terms Of Use | Privacy | Trademarks | Copyright Policy | Site Guidelines | Site map | Help
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.
Oracle