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:
Storing disk images in ZFS volumes or ZFS files
Using snapshots to backup disk images
Using clones to duplicate disk images and provision additional domains
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.
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
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:
Installed software – about 6 gigabytes
Swap partition – about 1 gigabyte
Extra space to store system data – at least 1 gigabyte
Therefore, the size of a disk image to install the entire Solaris OS should be at least 8 gigabytes.
The following examples:
Create a 10-gigabyte image on a ZFS volume or file.
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.
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.
For example, create a 10-gigabyte disk image on a ZFS volume.
primary# zfs create -V 10gb ldmpool/ldg1/disk0
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
Export the ZFS volume as a virtual disk.
primary# ldm add-vdsdev /dev/zvol/dsk/ldmpool/ldg1/disk0 ldg1_disk0@primary-vds0
Export the ZFS file as a virtual disk.
primary# ldm add-vdsdev /ldmpool/ldg1/disk0/file ldg1_disk0@primary-vds0
Assign the ZFS volume or file to a guest domain; in this example, ldg1.
primary# ldm add-vdisk disk0 ldg1_disk0@primary-vds0 ldg1
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:
Stop and unbind the guest domain. This is the safest solution, and this is the only solution available if you want to create a snapshot of a disk image used as the boot disk of a guest domain.
Alternatively, you can unmount any slices of the disk you want to snapshot used in the guest domain, and ensure that no slice is in use the guest domain.
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.
Create a snapshot of the disk image that was created for the ldg1 domain, for example.
primary# zfs snapshot ldmpool/ldg1/disk0@version_1
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.
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.
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.
Bind and start the original domain.
Execute the sys-unconfig command.
After the sys-unconfig command completes, the domain halts.
Stop and unbind the domain; do not reboot it.
Take a snapshot of the domain boot disk image.
primary# zfs snapshot ldmpool/ldg1/disk0@unconfigured
At this point you have the snapshot of the boot disk image of an unconfigured system.
Clone this image to create a new domain which, when first booted, asks for the configuration of the system.