System Administration Guide: Virtualization Using the Solaris Operating System

ProcedureHow 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.

  1. Become superuser, or assume the appropriate role.

  2. (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.

  3. Shut down domain1.

    # virsh shutdown domain1
  4. Take a snapshot of the root disk used by domain1.

    # zfs snapshot pool/domain1-root@clone
  5. Create a clone named domain2 from the snapshot domain1-root@clone.

    # zfs clone pool/domain1-root@clone pool/domain2-root
  6. (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
  7. Dump the configuration of domain1.

    # virsh dumpxml domain1 >domain1.xml
  8. Copy the configuration file domain1.xml to a file named domain2.xml.

    # cp domain1.xml domain2.xml
  9. Make the following changes in the domain2.xml file.

    1. Replace domain1 in this line:


      With the new name, domain2:

    2. So that virsh will generate a new domain configuration, remove the UUID line, which looks like this:

    3. 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'/>
  10. Inform virsh about the new domain:

    # virsh define domain2.xml
  11. Boot the cloned domain.

More Information on ZFS Snapshot Features

Also see Chapter 7, Working With ZFS Snapshots and Clones, in Solaris ZFS Administration Guide.