Contents
Previous 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 Settings editor (VM > 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
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 computerusing the disk type also referred to as a raw 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.
Virtual disks can be as large as 950GB (IDE or SCSI). 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 LSI Logic or BusLogic SCSI adapter available in a VMware Workstation virtual machine. You determine which SCSI adapter to use at the time you create the 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 Linuxor vice versa. For information about moving virtual disks, see
Moving and Sharing Virtual Machines.
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. While virtual disks are limited to 950GB, raw disks may be set up on both IDE and SCSI devices of up to 2.0TB capacity. 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.
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
Disk Files
The Virtual Machine Settings editor (
VM > Settings) allows you to choose the disk files for a virtual machine. See
What Files Make Up a Virtual Machine? for a comprehensive list of the other files.
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 diskthe 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 eachexcept for the first file in the set, which remains small.
The Virtual Machine Settings editor shows the name of the first file in the setthe 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, stores 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 sfor example, Windows XP Professional-f001.vmdk.
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
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.
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.
Defragmenting Virtual Disks
Defragmenting disks rearranges files, programs and unused space on the virtual disk so that programs run faster and files open more quickly. Defragmenting does not reclaim unused space on a virtual disk; to reclaim unused space, shrink the 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. Power off the virtual machine, then defragment its virtual disks from the virtual machine settings editor (VM > Settings). Select the virtual disk you want to defragment, then click Defragment.
Note: Note: This capability only works with virtual disks, not raw or plain disks.
3. Run a disk defragmentation utility on the host computer
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.
Shrinking Virtual Disks
Shrinking a virtual disk 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. You cannot shrink preallocated virtual disks or physical disks.
Shrinking virtual disks is a convenient way to convert a virtual disk to the format supported by Workstation. Virtual disks created in the new format can be recognized only by VMware Workstation 3.0 and higher.
The virtual disks to be shrunk must not be booted as independent disks. You can change the mode of a virtual disk before the virtual machine is powered on. See
Excluding Disks from Snapshots for a discussion of independent disks.
Shrinking requires free disk space on the host equal to the size of the virtual disk being shrunk.
Shrinking a disk is a two-step process: the first step, called wiping, is where VMware Tools reclaims all unused portions of disk partitions (such as deleted files) and prepares them for shrinking. This allows for the maximum shrink possible. Wiping takes place in the guest operating system.
The shrink process itself is the second step, and it takes place outside the virtual machine. Workstation reduces the size of the disk based on the disk space reclaimed by the wipe process. This step occurs after the wipe finishes preparing the disk for shrinking.
When a virtual machine is powered on, you 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.
In a Linux or FreeBSD guest operating system, to prepare virtual disks for shrinking, you should run VMware Tools as the root user. This way, you ensure the whole virtual disk is shrunk. Otherwise, if you shrink disks as a non-root user you cannot wipe the parts of the virtual disk that require root-level permissions.
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.
Note: If you deselect some of the partitions to wipe, the whole disk is still shrunk. However, those partitions are not prepared for shrinking, and the shrink does not reduce the size of the virtual disk as much as it could otherwise.
4. When VMware Tools finishes wiping the selected disk partitions, you are prompted to begin shrinking the disks.
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. For example, you cannot shrink a virtual disk if:
You preallocated disk space when you created the disk, which is the default option for both typical and custom virtual machine creation paths.
The virtual machine has any snapshots. To delete a snapshot, choose Snapshot > Snapshot Manager > Delete.
The virtual machine contains physical (raw) disks.
The virtual disk is not an independent disk in persistent mode. For more information, see Independent Disks.
The virtual disk is stored on a CD-ROM.