Any time you plan to create multiple virtual machines that are all based on the same virtual disk image, the smart way to go about it is to use linked clones. The term linked clone is actually used by VMware Inc. most commonly in its VMware View VDI offering. However, VMware linked clones haven't cornered the market on the concept. Microsoft's Hyper-V offers virtual disks, called "differencing disks," that are similar in concept. This technical tip explains VMware linked clones and the reasons to use them.
So, what are linked clones and when should you use them? Let's say you were rolling out a virtual lab environment or a virtual desktop infrastructure (VDI) for your company. You create a base Windows 7 or Windows 8 VM that will be used for these purposes. It has the guest OS and all the applications an end user would need. It may be approximately 20 GB when it's ready to roll out. With your 500 end users, the 20 GB virtual disk is cloned (or duplicated) 500 times to take up a total of about 10 TB. But what if that VM for 500 users only had to take up about 25 GB (or less than 1% of the space)?
To make that kind of disk capacity savings possible, linked clones are created based on a snapshot of a parent virtual machine. This parent snapshot is the base virtual disk for the virtual machine, and any changes made to the VM are stored in a delta disk on a per-VM basis. Changes to the child VM are not reflected on the parent and changes on the parent aren't reflected on the child. (See Figure 1: Linked clone technology in use)
This works great until you want to update the parent's VM and have those changes reflected on the children (for example, an OS or app upgrade). To make that happen, you need to perform a recompose. With the recompose option (thanks to VMware View Composer), you are saying that you want all VMs to point to a new snapshot for their base disk. This is usually because that new snapshot has a new service pack or application (for example, Windows 8 SP1, Office 2013 or your own internal app). Desktop recomposition simultaneously updates all the linked clone desktops anchored to a parent virtual machine so they point to the right base disk. To do this, users have to log off these desktops and then log back on when the new desktop is ready. The recompose option can take a while and, during that time, end users are unable to use their applications or do their work.
New View Controlled Recompose script
VMware Labs is where VMware software engineers post their pet projects, referred to as "flings." You can try these free projects for yourself. Some flings are later moved into a general availability (GA) VMware product. VMware Labs has been around for a few years, and in that time more than 30 flings have been posted, some of which have been very popular and helpful to VMware administrators.
Recently, VMware released two flings related to VDI recomposition. The first fling is the new View Controlled Recompose script.
When run, this script does a "controlled recomposition" of a VMware View linked clone pool of virtual desktops. It identifies a free desktop and recomposes it to create the first replica desktop. After the recomposition of the first desktop, the script recomposes a specified number of additional free desktops to create a supply of recomposed systems. These desktops will be available for reconnecting users when the script next recomposes the remaining desktops in the pool, directing VMware View to force-logoff active users after the warning period specified in View Manager. An optional extra recompose can be run against the pool as the final step to provide a second attempt to recompose any desktops that may have failed. This automated PowerShell script allows VMware View admins to recompose a large number of VDI desktops in a controlled and scripted way.
It doesn't have a pretty GUI interface today as this is a 100% command line interface tool. However, I'm betting that you'll see this tool in the next version of VMware View.
Lctree for vCloud Director
The second VMware Labs fling related to virtual desktop recomposition is Lctree. Because VMware vCloud Director (vCD) originally didn't offer linked clone technologies, it was a welcome addition to vCloud Director 5.1. However, in large private and public cloud environments, the number of VMs can reach the tens of thousands. To help you visualize all those base virtual machines and linked clones, VMware Labs released Lctree.
Unlike the VMware View script above, Lctree is for admins using VMware vCD. Lctree allows vCD admins to visualize linked clone trees. This Java-based application could be very helpful in complex vCD environments that use linked clones. (See Figure 2: Lctree tool helps visualize linked clone trees)
The use of linked clones is crucial for disk capacity and update management in environments where you have many VMs with similar operating systems and applications (VMware View and vCD environments). The controlled recompose script and Lctree tools need to be integrated into both VMware View and vCD so administrators can recompose VMs and figure out what's going on with their linked clone virtual machines. I applaud VMware for continuing to support VMware Labs and hope that so many of the great tools found at VMware Labs will soon be seen in VMware's general availability products.