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 appropriate 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 pool/domain1-root@clone |
Create a clone named domain2 from the snapshot domain1-root@clone.
# zfs clone pool/domain1-root@clone 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:
<name>domain1</name> |
With the new name, domain2:
<name>domain2</name> |
So that virsh will generate a new domain configuration, remove the UUID line, which looks like this:
<uuid>72bb96b6e6cf13594fb0cd1290610611</uuid> |
Point to the new disk by editing the following line:
<source dev='/dev/zvol/dsk/export/domain1-root'/> |
Change domain1–root to domain2–root so that the line appears as follows:
<source dev='/dev/zvol/dsk/export/domain2-root'/> |
Inform virsh about the new domain:
# virsh define domain2.xml |
Boot the cloned domain.
Also see Chapter 7, Working With ZFS Snapshots and Clones, in Solaris ZFS Administration Guide.