VMware

VMware Workstation 4

Features | Documentation | Knowledge Base | Discussion Forums

previous Prev   Contents   Last   Next next

Configuring Hard Disk Storage in a Virtual Machine

Configuring Hard Disk Storage in a Virtual Machine

Like a physical computer, a VMware Workstation virtual machine stores its operating system, programs and data files on one or more hard disks. Unlike a physical computer, VMware Workstation gives you options for undoing changes to the virtual machine's hard disk.

The New Virtual Machine Wizard creates a virtual machine with one disk drive. You can use the Virtual Machine Control Panel (Edit > Virtual Machine Settings) to add more disk drives to your virtual machine, to remove disk drives from your virtual machine or to change certain settings for the existing disk drives.

This section describes the choices you can make in setting up hard disk storage for your virtual machine.

Disk Types: Virtual and Physical

Disk Types: Virtual and Physical

In the most common configurations, VMware Workstation creates virtual hard disks, which are made up of files that are typically stored on your host computer's hard disk. In some circumstances, you may need to give your virtual machine direct access to a physical hard drive on your host computer - using the disk type also referred to as a raw disk.

Virtual Disk

Virtual Disk

A virtual disk is a file or set of files that appears as a physical disk drive to a guest operating system. The files can be on the host machine or on a remote computer. When you configure a virtual machine with a virtual disk, you can install a new operating system onto the virtual disk without repartitioning a physical disk or rebooting the host.

IDE virtual disks can be as large as 128GB. SCSI virtual disks can be as large as 256GB. Depending on the size of the virtual disk and the host operating system, VMware Workstation creates one or more files to hold each virtual disk.

By default, the actual files used by the virtual disk start out small and grow to their maximum size as needed. The main advantage of this approach is the smaller file size. Smaller files require less storage space and are easier to move if you want to move the virtual machine to a new location. However, it takes longer to write data to disk configured in this way.

You may also configure virtual disks so all the disk space is allocated at the time the virtual disk is created. This approach provides enhanced performance and is useful if you are running performance-sensitive applications in the virtual machine. Virtual disks created in this way are similar to the experimental plain disks that could be created under VMware Workstation 2.

Virtual disks can be set up as IDE disks for any guest operating system. They can be set up as SCSI disks for any guest operating system that has a driver for the BusLogic SCSI adapter used in a VMware Workstation virtual machine.

Note: To use SCSI disks in a Windows XP or Windows Server 2003 virtual machine, you need a special SCSI driver available from the download section of the VMware Web site at www.vmware.com/download. Follow the instructions on the Web site to use the driver with a fresh installation of Windows XP or Server 2003.

A virtual disk of either type can be stored on either type of physical hard disk. That is, the files that make up an IDE virtual disk can be stored on either an IDE hard disk or a SCSI hard disk. So can the files that make up a SCSI virtual disk. They can also be stored on other types of fast-access storage media, such as DVD-ROM or CD-ROM discs.

A key advantage of virtual disks is their portability. Because the virtual disks are stored as files on the host machine or a remote computer, you can move them easily to a new location on the same computer or to a different computer. You can also use VMware Workstation on a Windows host to create virtual disks, then move them to a Linux computer and use them under VMware Workstation for Linux - or vice versa. For information about moving virtual disks, see Moving and Sharing Virtual Machines.

Raw Disk

Raw Disk

A raw disk directly accesses an existing local disk or partition. You can use raw disks if you want VMware Workstation to run one or more guest operating systems from existing disk partitions. Raw disks may be set up on both IDE and SCSI devices. At this time, however, booting from an operating system already set up on an existing SCSI disk or partition is not supported.

The most common use of a raw disk is for converting a dual-boot or multiple-boot machine so one or more of the existing operating systems can be run inside a virtual machine.

Caution: If you run an operating system natively on the host computer, then switch to running it inside a virtual machine, the change is like pulling the hard drive out of one computer and installing it in a second computer with a different motherboard and other hardware. You need to prepare carefully for such a switch. The specific steps you need to take depend on the operating system you want to use inside the virtual machine. For details, see Configuring a Dual-Boot Computer for Use with a Virtual Machine.

You can also create a new virtual machine using a raw disk. For details, see Installing an Operating System onto a Raw Partition from a Virtual Machine. In most cases, however, it is better to use a virtual disk.

Only expert users should attempt raw disk configurations.

Note: You should not use a raw disk to share files between host and guest operating systems. It is not safe to make the same partition visible to both host and guest. You can cause data corruption if you do this. To share files between host and guest operating systems, use shared folders. For details, see Using Shared Folders.

File Locations

File Locations

Disk Files

Disk Files

The Virtual Machine Control Panel (Edit > Virtual Machine Settings) allows you to choose the disk files for a virtual machine.

You may want to choose a file other than the one created by the New Virtual Machine Wizard if you are using a virtual disk that you created in a different location or if you are moving the automatically created disk files to a new location.

The disk files for a virtual disk store the information that you write to a virtual machine's hard disk - the operating system, the program files and the data files. The virtual disk files have a .vmdk extension.

A virtual disk is made up of one or more .vmdk files.

On Windows hosts, each virtual disk is contained in one file by default. You may, as an option, configure the virtual disk to use a set of files limited to 2GB per file. Use this option if you plan to move the virtual disk to a file system that does not support files larger than 2GB.

You must set this option at the time the virtual disk is created.

If you are setting up a new virtual machine, in the New Virtual Machine Wizard follow the Custom path. In the screen that allows you to specify the virtual disk's capacity, select Split disk into 2GB files.

If you are adding a virtual disk to an existing virtual machine, follow the steps in the Add Hardware Wizard. In the screen that allows you to specify the virtual disk's capacity, select Split disk into 2GB files.

When a disk is split into multiple files, larger virtual disks have more .vmdk files.

The first .vmdk file for each disk is small and contains pointers to the other files that make up the virtual disk. The other .vmdk files contain data stored by your virtual machine and use a small amount of space for virtual machine overhead.

If you chose to allocate space for the virtual disk in advance, the file sizes are fixed, and most of the files are 2GB. As mentioned above, the first file is small. The last file in the series may also be smaller than 2GB.

If you did not allocate the space in advance, the .vmdk files grow as data is added, to a maximum of 2GB each - except for the first file in the set, which remains small.

The Virtual Machine Control Panel shows the name of the first file in the set - the one that contains pointers to the other files in the set. The other files used for that disk are automatically given names based on the first file's name.

For example, a Windows XP Professional virtual machine using the default configuration, with files that grow as needed, store the disk in files named Windows XP Professional.vmdk, Windows XP Professional-s001.vmdk, Windows XP Professional-s002.vmdk and so on.

If the disk space is allocated in advance, the names are similar, except that they include an f instead of an s - for example, Windows XP Professional-f001.vmdk.

If your virtual machine uses files created under earlier VMware products, with a .dsk extension, the filenames can be updated automatically on a Windows host. For details, see Updating Filenames for Virtual Disks Created with Earlier VMware Products.

If you are using a raw disk, the .vmdk file stores information about the physical disk or partition used by the virtual machine.

Lock Files

Lock Files

A running virtual machine creates lock files to prevent consistency problems on virtual disks. If the virtual machine did not use locks, multiple virtual machines might read and write to the disk, causing data corruption.

Lock files are always created in the same directory as the .vmdk file.

The locking methods used by VMware Workstation on Windows and Linux hosts are different, so files shared between them are not fully protected. If you use a common file repository that provides files to users on both Windows and Linux hosts, be sure that each virtual machine is run by only one user at a time.

When a virtual machine is powered off, it removes the lock files it created. If it cannot remove the lock, a stale lock file is left protecting the .vmdk file. For example, if the host machine crashes before the virtual machine has a chance to remove its lock file, a stale lock remains.

If a stale lock file remains when the virtual machine is started again, the virtual machine tries to remove the stale lock. To make sure that no virtual machine could be using the lock file, the virtual machine checks the lock file to see if

  1. The lock was created on the same host where the virtual machine is running.
  2. The process that created the lock is not running.

If those two conditions are true, the virtual machine can safely remove the stale lock. If either of those conditions is not true, a dialog box appears, warning you that the virtual machine cannot be powered on. If you are sure it is safe to do so, you may delete the lock files manually. On Windows hosts, the filenames of the lock files end in .lck. On Linux hosts, the filenames of the lock files end in .WRITELOCK.

Raw disk partitions are also protected by locks. However, the host operating system is not aware of this locking convention and thus does not respect it. For this reason, VMware strongly recommends that the raw disk for a virtual machine not be installed on the same physical disk as the host operating system.

Updating Filenames for Virtual Disks Created with Earlier VMware Products

Updating Filenames for Virtual Disks Created with Earlier VMware Products

Except for VMware Workstation 3, previous VMware products, including VMware Workstation 2, named virtual disk files with a .dsk extension. To avoid conflicts with the System Restore feature on Windows XP and Windows Server 2003 hosts, VMware Workstation now uses a .vmdk extension for those files. VMware Workstation 4 updates existing virtual disk files automatically. It also automatically updates references to the virtual disk files in the configuration files for the virtual machine.

In addition, VMware Workstation converts the filename extensions for the files that store the state of a suspended virtual machine. The old extension was .std. The extension is now .vmss.

If your host computer is running Windows XP or Windows Server 2003, VMware Workstation must turn off System Restore on the host computer while it runs the updater. If this were not done and you restored the host to a restore point that was set sometime before you ran the updater, the System Restore feature would rename your virtual disk files to use the.dsk extension. You would again have the conflict the updater was designed to solve.

Note: Because the VMware Workstation updater turns off the System Restore feature while it runs, all existing restore points are deleted.

System Restore is turned back on after the updater completes its work.

Running the Updater at a Later Time

Running the Updater at a Later Time

On a Windows host computer, you can run the filename updater at any time. To do so, follow these steps.

  1. Open a command prompt.
  2. Change to the folder in which the VMware Workstation program files are installed. If you installed the files in the default locations, use this command:

    cd C:\Program Files\VMware\VMware Workstation\Programs

  3. Run the updater.

    dskrename.exe

Defragmenting and Shrinking Virtual Disks

Defragmenting and Shrinking Virtual Disks

If you have a virtual disk that grows as data is added, you can defragment and shrink it as described in this section. If you allocated all the space for your virtual disk at the time you created it, you cannot defragment and shrink it.

To defragment the virtual disks attached to a virtual machine, power off the virtual machine, then go to the Virtual Machine Control Panel (Edit > Virtual Machine Settings).

Select the virtual disk you want to defragment, then click Defragment.

Defragmenting disks may take considerable time.

Note: The defragmentation process requires free working space on the host computer's disk. If your virtual disk is contained in a single file, for example, you need free space equal to the size of the virtual disk file. Other virtual disk configurations require less free space.

When a virtual machine is powered on, you can shrink its virtual disks from the VMware Tools control panel. You cannot shrink virtual disks if a snapshot exists. To remove the snapshot if one exists, choose Snapshot > Remove Snapshot.

  1. To launch the control panel in a Windows guest, double-click the VMware Tools icon in the system tray or choose Start > Settings > Control Panel, then double-click VMware Tools.

    To launch the control panel in a Linux or FreeBSD guest, become root (su), then run vmware-toolbox.

  2. Click the Shrink tab.
  3. Select the virtual disks you want to shrink, then click Prepare to Shrink.

The shrink tool reclaims unused space in the virtual disk. If there is empty space in the disk, this process reduces the amount of space the virtual disk occupies on the host drive.

Shrinking disks may take considerable time.

In some configurations, it is not possible to shrink virtual disks. If your virtual machine uses such a configuration, the Shrink tab displays information explaining why you cannot shrink your virtual disks.

Note: VMware recommends you defragment your host computer's hard drive after 10 shrink operations on a virtual disk.

For best disk performance, you can take the following three actions, in the order listed:

  1. Run a disk defragmentation utility inside the virtual machine.
  2. Use the VMware Workstation defragmentation tool. Go to Edit > Virtual Machine Settings, click the listing for the virtual disk you want to defragment, then click Defragment.
  3. Run a disk defragmentation utility on the host computer.

previous Prev   Contents   Last   Next next