Logical Domains 1.2 Administration Guide

Using ZFS With Virtual Disks

This section describes using the Zettabyte File System (ZFS) to store virtual disk backends exported to guest domains. ZFS provides a convenient and powerful solution to create and manage virtual disk backends. ZFS enables:

Refer to the Solaris ZFS Administration Guide for more information about using the ZFS.

In the following descriptions and examples, the primary domain is also the service domain where disk images are stored.

Configuring a ZFS Pool in a Service Domain

To store the disk images, first create a ZFS storage pool in the service domain. For example, this command creates the ZFS storage pool ldmpool containing the disk c1t50d0 in the primary domain.


primary# zpool create ldmpool c1t50d0

Storing Disk Images With ZFS

The following command creates a disk image for guest domain ldg1. A ZFS file system for this guest domain is created, and all disk images of this guest domain will be stored on that file system.


primary# zfs create ldmpool/ldg1

Disk images can be stored on ZFS volumes or ZFS files. Creating a ZFS volume, whatever its size, is quick using the zfs create -V command. On the other hand, ZFS files have to be created using the mkfile command. The command can take some time to complete, especially if the file to create is quite large, which is often the case when creating a disk image.

Both ZFS volumes and ZFS files can take advantage of ZFS features such as snapshot and clone, but a ZFS volume is a pseudo device while a ZFS file is a regular file.

If the disk image is to be used as a virtual disk onto which the Solaris OS is to be installed, then it should be large enough to contain:

Therefore, the size of a disk image to install the entire Solaris OS should be at least 8 gigabytes.

Examples of Storing Disk Images With ZFS

    The following examples:

  1. Create a 10-gigabyte image on a ZFS volume or file.

  2. Export the ZFS volume or file as a virtual disk. The syntax to export a ZFS volume or file is the same, but the path to the backend is different.

  3. Assign the exported ZFS volume or file to a guest domain.

When the guest domain is started, the ZFS volume or file appears as a virtual disk on which the Solaris OS can be installed.

ProcedureCreate a Disk Image Using a ZFS Volume

  1. For example, create a 10-gigabyte disk image on a ZFS volume.


    primary# zfs create -V 10gb ldmpool/ldg1/disk0
    

ProcedureCreate a Disk Image Using a ZFS File

  1. For example, create a 10-gigabyte disk image on a ZFS volume.


    primary# zfs create ldmpool/ldg1/disk0
    primary# mkfile 10g /ldmpool/ldg1/disk0/file
    

ProcedureExport the ZFS Volume

  1. Export the ZFS volume as a virtual disk.


    primary# ldm add-vdsdev /dev/zvol/dsk/ldmpool/ldg1/disk0 ldg1_disk0@primary-vds0
    

ProcedureExport the ZFS File

  1. Export the ZFS file as a virtual disk.


    primary# ldm add-vdsdev /ldmpool/ldg1/disk0/file ldg1_disk0@primary-vds0
    

ProcedureAssign the ZFS Volume or File to a Guest Domain

  1. Assign the ZFS volume or file to a guest domain; in this example, ldg1.


    primary# ldm add-vdisk disk0 ldg1_disk0@primary-vds0 ldg1
    

Creating a Snapshot of a Disk Image

When your disk image is stored on a ZFS volume or on a ZFS file, you can create snapshots of this disk image by using the ZFS snapshot command.

Before you create a snapshot of the disk image, ensure that the disk is not currently in use in the guest domain to ensure that data currently stored on the disk image are coherent. There are several ways to ensure that a disk is not in use in a guest domain. You can either:

In this example, because of the ZFS layout, the command to create a snapshot of the disk image is the same whether the disk image is stored on a ZFS volume or on a ZFS file.

ProcedureCreate a Snapshot of a Disk Image

  1. Create a snapshot of the disk image that was created for the ldg1 domain, for example.


    primary# zfs snapshot ldmpool/ldg1/disk0@version_1
    

Using Clone to Provision a New Domain

Once you have created a snapshot of a disk image, you can duplicate this disk image by using the ZFS clone command. Then the cloned image can be assigned to another domain. Cloning a boot disk image quickly creates a boot disk for a new guest domain without having to perform the entire Solaris OS installation process.

For example, if the disk0 created was the boot disk of domain ldg1, do the following to clone that disk to create a boot disk for domain ldg2.


primary# zfs create ldmpool/ldg2
primary# zfs clone ldmpool/ldg1/disk0@version_1 ldmpool/ldg2/disk0

Then ldompool/ldg2/disk0 can be exported as a virtual disk and assigned to the new ldg2 domain. The domain ldg2 can directly boot from that virtual disk without having to go through the OS installation process.

Cloning a Boot Disk Image

When a boot disk image is cloned, the new image is exactly the same as the original boot disk, and it contains any information that has been stored on the boot disk before the image was cloned, such as the host name, the IP address, the mounted file system table, or any system configuration or tuning.

Because the mounted file system table is the same on the original boot disk image and on the cloned disk image, the cloned disk image has to be assigned to the new domain in the same order as it was on the original domain. For example, if the boot disk image was assigned as the first disk of the original domain, then the cloned disk image has to be assigned as the first disk of the new domain. Otherwise, the new domain is unable to boot.

If the original domain was configured with a static IP address, then a new domain using the cloned image starts with the same IP address. In that case, you can change the network configuration of the new domain by using the sys-unconfig(1M) command. To avoid this problem you can also create a snapshot of a disk image of an unconfigured system.

If the original domain was configured with the Dynamic Host Configuration Protocol (DHCP), then a new domain using the cloned image also uses DHCP. In that case, you do not need to change the network configuration of the new domain because it automatically receives an IP address and its network configuration as it boots.


Note –

The host ID of a domain is not stored on the boot disk, but it is assigned by the Logical Domains Manager when you create a domain. Therefore, when you clone a disk image, the new domain does not keep the host ID of the original domain.


ProcedureCreate a Snapshot of a Disk Image of an Unconfigured System

  1. Bind and start the original domain.

  2. Execute the sys-unconfig command.

  3. After the sys-unconfig command completes, the domain halts.

  4. Stop and unbind the domain; do not reboot it.

  5. Take a snapshot of the domain boot disk image.

    For example:


    primary# zfs snapshot ldmpool/ldg1/disk0@unconfigured
    

    At this point you have the snapshot of the boot disk image of an unconfigured system.

  6. Clone this image to create a new domain which, when first booted, asks for the configuration of the system.