Cloning ZFS-Based Solaris Domains
If you are using a ZFS volume as the root disk for
a domU, you can use the ZFS snapshot facilities to clone another domU
with the same configuration. By taking a clone of the root disk, you
can quickly provision similar domains.
For example, you might install Solaris as a guest domain, run sys-unconfig(1M),
then clone that disk image for use in new Solaris domains. Installing a
Solaris domain in this way requires only the configuration step, rather than a
full install. The only extra storage used for the cloned domain is the
amount needed for the differences between the domains.
You also have the capability to revert to a previous configuration if necessary.
Note - Any clones created from a snapshot must be destroyed before the snapshot can
How to Use ZFS Snapshot to Clone a Solaris DomU
If you use a ZFS volume as the virtual disk for your
guest domain, you can take a snapshot of the storage. The snapshot is
used to create clones.
Note that you might want to use the sys-unconfig command described in sys-unconfig(1M)
in the domain before you take the snapshot. The resulting clones would not
have host names or name services configured, which is also known as "as-manufactured."
When it comes up, the new clone displays the configuration screens.
- Become superuser, or assume the Primary Administrator role.
- (Optional) To create a snapshot to produce domains that require sysidcfg to
complete system identification, use the sys-unconfig command in a domain named domain1.
- Shut down domain1.
# virsh shutdown domain1
- Take a snapshot of the root disk used by domain1.
# zfs snapshot [email protected]
- Create a clone named domain2 from the snapshot [email protected].
# zfs clone [email protected] pool/domain2-root
- (Optional) Display the snapshot and clone.
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
pool 92.0K 67.0G 9.5K /pool
pool/domain1 8K 67.0G 8K /pool/domain1
pool/domain2 8K 67.0G 8K /pool/domain2
- Dump the configuration of domain1.
# virsh dumpxml domain1 >domain1.xml
- Copy the configuration file domain1.xml to a file named domain2.xml.
# cp domain1.xml domain2.xml
- Make the following changes in the domain2.xml file.
- Replace domain1 in this line:
With the new name, domain2:
- So that virsh will generate a new domain configuration, remove the UUID line,
which looks like this:
- Point to the new disk by editing the following line:
Change domain1–root to domain2–root so that the line appears as follows:
- Inform virsh about the new domain:
# virsh define domain2.xml
- Boot the cloned domain.
More InformationMore Information on ZFS Snapshot Features
Also see Chapter 7, Working With ZFS Snapshots and Clones, in Solaris ZFS Administration Guide.
Thus, you can keep snapshots of the guest domain OS installations that are
known to be good images, and use ZFS rollback to revert to
a snapshot if the domain has a problem. For more information, see Rolling Back to a ZFS Snapshot in Solaris ZFS Administration Guide.