[an error occurred while processing this directive] [an error occurred while processing this directive] Sharing Virtual Disk Base Images [an error occurred while processing this directive]
[an error occurred while processing this directive]  
 

Sharing Virtual Disk Base Images

Sharing Virtual Disk Base Images

VMware products have some sophisticated disk capabilities that are not exposed in the user interface. This tech tip explores one such capability - the sharing of a virtual disk base image by multiple virtual machines. The virtual machines sharing the base image can run concurrently. You can modify each virtual machine configuration and install and remove software independently of the other virtual machines. The virtual machines share the original virtual disk base image while the differences are saved in separate redo logs for each virtual machine.

This tech tip is applicable to VMware Workstation 3.x and VMware GSX Server 2.0.

Why Share Virtual Disks Base Images?

Why Share Virtual Disks Base Images?

Sharing virtual disk base images avoids having to install individually the same software, including operating systems, service packs, updates and applications, multiple times for multiple virtual machines. This sharing can be of great value to software developers and QA staff who often have to work with many slightly different software environments.

Using virtual disks to provide standardized base images provides the following benefits:

  • Time savings--the software environment is installed once, avoiding your wasting time needlessly reinstalling software.
  • Standardization--all virtual machines start with the exact same software environment. Standardization minimizes time spent creating and maintaining environments, and greatly reduces the risk of introducing unintentional differences between environments.
  • Storage space saving--sharing the same virtual disk base image requires less space than separate complete software installations for each virtual machine.

Caution: The tech tip is intended for advanced users. VMware recommends that you make back-up copies of virtual machines before first attempting the operations described here. Committing a redo log to, or otherwise modifying, a shared virtual disk base image will destroy other virtual machines that are dependent on that disk.

Creating the Initial Base Virtual Machine

Creating the Initial Base Virtual Machine

For simplicity, we will use Workstation 3.x on a Microsoft Windows host in this example procedure. Similar instructions apply to Workstation 3.x on Linux hosts and to GSX Server 2.0.

  1. You can use an existing virtual machine or create a new virtual machine and install an operating system and other software as you normally would.

    Refer to the product documentation or the in-product Help for the specific steps to create a virtual machine using your VMware product. You can find the latest VMware product documentation at www.vmware.com/support.

  2. Once you are satisfied that the base virtual machine is configured to your liking, complete one of the following, depending on your virtual disk mode:

    If the virtual machine disk is in undoable disk mode, then shut down the guest operating system and power off the virtual machine. When prompted, click Commit.

    or

    If the virtual machine disk is in persistent mode, then shut down the guest operating system and power off the virtual machine. Use the Configuration Editor and change the virtual disk mode to Undoable.

  3. Power on the new virtual machine (the disk should be in undoable mode).
  4. Allow the BIOS in the virtual machine to run and just as the guest operating system starts to boot then power off the virtual machine (this creates an empty redo log for the following steps).
  5. Click Keep to save the redo log.
  6. In the Configuration Editor Virtual Disk panel, click Browse and select the redo log created above as the virtual disk file, instead of the original virtual disk file.

Redo log naming: If you originally named your virtual disk mydisk.vmdk, you will find the mydisk.vmdk and mydisk.vmdk.REDO files. If a REDO log directory was specified in the Options panel for the virtual machine, then the redo logs will be in the specified directory, and they will also have a pseudorandom extension added to the name, such as mydisk.vmdk_a01168. Select the appropriate mydisk.vmdk.REDO or mydisk.vmdk.REDO_<xxxxxx> file.

Note: When you browse for these files, the default file extension the VMware software looks for is .vmdk. Make sure you browse for all file extensions to find the redo log files. Don't select files called, for example, mydisk-02.vmdk, mydisk-02.vmdk.REDO or mydisk-02.vmdk.REDO_<xxxxxx>, and so on. (See Advanced Information on Disks for more information on these files).

  1. Click OK to save your changes.
  2. To avoid accidental damage to the parent virtual disk files, use the host operating system to set the parent virtual disk file to be read-only. In this example, set the mydisk.vmdk file and any other files called mydisk-02.vmdk, mydisk-03.vmdk, and so on to be read-only (see Advanced Information on Disks for more information on these files).

Caution: Attempting to boot a virtual machine using the original virtual disk in persistent disk mode will cause writes to the virtual disk. This action will corrupt other virtual machines using this base disk. This is why, in the instructions above, we tell you to set the base virtual disk files to read-only. We also configured the original virtual machine to access the disk base image, by referencing a redo log (that it can safely write to), instead of the actual virtual disk.

Creating Additional Virtual Machines on the Same Virtual Disk Base Image

Creating Additional Virtual Machines on the Same Virtual Disk Base Image

While creating the new virtual machines, you have to power off other virtual machines that are sharing the same base virtual disk. Once you have created the virtual machines, you can run multiple virtual machines concurrently using the same virtual disk base image. (There are more complex methods of creating a new virtual machines while others are running on the same base image, but the approach below is the simplest overall method for you to get started).

Follow these steps to create new virtual machines using the virtual disk base image. Continuing with the previous procedure, we are using Workstation 3.x on a Windows host.

  1. Shut down the guest operating system and power off any other virtual machines that are sharing the same virtual disk base image.
  2. Create a virtual machine using the New Virtual Machine Wizard. Select Custom to create a virtual machine configuration.
  3. Make selections as appropriate in the Wizard panels.
    1. On the Name the Virtual Machine panel, accept the default location or pick a new location for the virtual machine, but do not make this the same location as the initial base virtual machine created previously.
    2. On the Select a Disk panel, select Use an existing virtual disk.
    3. Select the .vmdk file for the virtual disk you are using as a base image.
    4. In the Select a Disk Mode panel, select Undoable.
    5. Click Finish.
  4. In the Options tab of the Configuration Editor, enter the name of a new directory, to store the redo logs for this machine, in the box marked REDO log directory.

    The best place to put your new redo logs is in the same directory as the virtual machine configuration file (the .vmx file on Windows hosts, the .cfg file on Linux hosts). To do this, place a period (.) in the REDO log directory box.

Note: The default location for redo logs (if the REDO log directory field is blank) is in the same directory as the virtual disks. If you do not change the default directory as described in this step, it can cause conflicts with other virtual machines trying to share the same base image.

  1. Make any other changes to the virtual machine configuration that you want. In general you want to have the virtual devices such as serial ports, parallel ports, and so on, configured as similar to the original virtual machine as possible. If you don't do this, you may need to add or remove devices in the guest operating system. In the latest versions of Windows, plug and play reconfigures the guest operating system drivers.

    Note: Starting with as similar virtual machine configurations as possible helps to minimize the work needed to reconfigure the guest operating system in each virtual machine.

  2. Click OK to save your changes.
  3. Power on the new virtual machine (the disk should be in undoable mode).
  4. Allow the BIOS in the virtual machine to run and just as the guest operating system starts to boot, then power off the virtual machine (this creates an empty redo log for the following steps).
  5. Click Keep to save the redo log.
  6. In the Configuration Editor, in the Virtual Disk panel, select the .REDO log file that was just created. If you followed the instructions above, the file is in the same folder or directory as the configuration file for the virtual machine (.vmx on Windows hosts and .cfg on Linux hosts). Since a redo log directory was specified for this virtual machine, the redo log file has a name resembling mydisk.vmdk.REDO_<xxxxxx>, where <xxxxxx> is a random string.
  7. You can now power on the virtual machines sharing this same virtual disk base image.
Notes

Notes

  • If you want to run multiple virtual machines sharing the same base image and have them operate on the same network, you need to change the network identity of each virtual machine. For Microsoft Windows guest operating systems, you need to use Sysprep or a similar tool to ensure the virtual machine has a unique SID (Security ID). See www.microsoft.com/technet/treeview/default.asp?url=/TechNet/prodtechnol/windows2000pro/deploy/depopt/sysprep.asp for information on Sysprep. For other operating systems, make sure that machine names and network addresses are set to be unique.
  • For sharing images across different physical machines, you can place the original virtual disk on a file server, with the redo logs on the local computer.
How Does this Work?

How Does this Work?

VMware products can use virtual disks or raw disk partitions; most users will use virtual disks because of their convenience. The capability in this tech tip actually applies to all disk types, but for simplicity we only discuss virtual disks. A virtual disk is a file (or set of files) on a host file system. From inside the virtual machine, this virtual disk appears to the guest operating system to be an IDE or SCSI disk.

Segmenting Virtual Disks

Segmenting Virtual Disks

Some file systems are limited to supporting files of 2GB in size, for portability across different file systems. VMware products divide virtual disks into multiple, separate 2GB files. For example if you create a 4GB virtual disk called mydisk.vmdk using the New Virtual Machine Wizard or the Configuration Editor, the actual files created are mydisk.vmdk, mydisk-02.vmdk and mydisk-03.vmdk. (Even though this 4GB file could be stored in two 2GB files, there is a small amount of housekeeping information sited in each file that causes a third file to be created to store 4GB of data.) Each virtual disk file start at almost zero size and grows as data is written to the disk.

Disk Modes and Redo Logs

Disk Modes and Redo Logs

Disks in VMware products have three modes of operation: persistent, undoable, and nonpersistent.

Persistent mode-behaves like conventional disk drives on a physical computer. The virtual machine writes data to the disk file.

Undoable mode-changes to the disk are written to a redo log instead of the disk file. When the virtual machine is powered off, the user is asked to commit, discard or keep the changes made during that session.

  • Commit--writes the changes in the redo log to the parent virtual disk, then deletes the redo log file. This choice makes the changes permanent.
  • Discard--deletes the redo log, leaving the virtual machine as it was when it was first started. This is useful, for example, to reset a virtual machine to a clean state after testing, or to recover from problems such as viruses or file corruption.
  • Keep--saves the redo log for use in subsequent sessions. This action allows changes made over several virtual machine sessions to be later discarded or committed.

Nonpersistent mode-behaves similarly to undoable mode, except the user is never asked what to do with the redo log; it is automatically discarded. Nonpersistent mode is useful for giving software demos and in training classrooms.

When software in a virtual machine using an undoable or nonpersistent disk does I/O, the VMware software only reads from the virtual disk and writes to the redo log. If modified data is in the redo log, then it is read from there instead of from the parent disk image.

VMware products create redo logs for a virtual disk with the same name as the virtual disk, with a .REDO extension appended to the name. For virtual disks that are larger than approximately 2GB and that consist of multiple files, separate redo logs are created for each separate file that makes up the virtual disk. By default, the redo log file(s) are created in the same directory as the virtual disk file(s). You can change this location in the Configuration Editor Options panel.

Advanced Information on Disks

Advanced Information on Disks

If you have specified a REDO log directory in the Configuration Editor Options panel, then redo logs created for that virtual machine also have a unique pseudorandomly generated extension added to the file name. This extension avoids conflicting names as users sometimes want to place redo logs for different virtual machines into the same folder or directory. In this case you will see file names as shown in the figure below.

To have a virtual machine use a redo log as a virtual disk, you specify the first segment of the redo log in the Configuration Editor Virtual Disk panel, which in this example is mydisk.vmdk.REDO_a01000.

In the Virtual Disk panel of the Configuration Editor, you can specify a .REDO log file instead of the normal virtual disk .vmdk file. When this is done, the VMware product follows pointers in the .REDO log to the parent .vmdk file. The software then transparently reads data from this combination of files as if they were from a single virtual disk, consisting of the logical sum of the original virtual disk plus the change in the redo log.

If the virtual disk (in our example mydisk.vmdk.REDO_a01000) is in undoable mode, you see the new redo log files created with another .REDO or .REDO_<xxxxxx> appended to the name; in our example, mydisk.vmdk.REDO_a01000.REDO_<xxxxxx>. This .REDO.REDO file is where new changes, made during this session, are being written.

If you power off the virtual machine and click Commit, then the changes in the .REDO.REDO file are written to the .REDO file, not the original parent disk image. Redo files can be nested multiple times. This leads to another trick for advanced users, of providing undoable disk capability, at multiple points in time.

In this tech tip, we exploit redo logs to allow sharing of a virtual disk base image. For each virtual machine that shares a virtual disk, we use the undoable mode to create a new redo log, then specify that redo log as the virtual disk for the additional virtual machines. Each virtual machine can then write changes to their own .REDO file being used as a virtual disk, but does not write changes to the shared parent virtual disk.

[an error occurred while processing this directive]