Sei sulla pagina 1di 7

VMware Workstation 5.

5 Using VMware
Virtual Disk Manager
VMware Virtual Disk Manager is a utility in VMware Workstation that allows you to
create, manage and modify virtual disk files from the command line or within scripts.

One key feature is the ability to enlarge a virtual disk so its maximum capacity is larger
than it was when you created it. This way, if you find you need more disk space in a given
virtual machine, but you do not want to add another virtual disk or use ghosting software to
transfer the data on a virtual disk to a larger virtual disk, you can instead change the
maximum size of the virtual disk. This is something you cannot do with physical hard
drives.

Another feature allows you to change disk types. When you create a virtual machine, you
specify how disk space is allocated. You select one of the following:

 All space for the virtual disk is allocated in advance. This corresponds to what the virtual
disk manager calls the preallocated disk type.
 Space allocated for the virtual disk begins small and grows as needed. This corresponds
to what the virtual disk manager calls the growable disk type.

With virtual disk manager you can change whether the virtual disk type is preallocated or
growable and whether the virtual disk is stored in a single file or split into 2GB files. For
example, you may have allocated all the disk space for a virtual disk, then find that you
need to reclaim some hard disk space on the host. You can convert the preallocated virtual
disk into a growable disk, then remove the original virtual disk file. The new virtual disk is
large enough to contain all the data in the original virtual disk. The virtual disk grows in
size as you add data to it.

These features and the ability to use scripting to automate management of virtual disks
were added to VMware Workstation in version 5.0.

You can use the virtual disk manager for the following tasks:

 Automate the management of virtual disks with scripts.


 Create virtual disks that are not associated with a particular virtual machine, for example
to be used as templates.
 Switch the virtual disk type from preallocated to growable, or vice versa. When you
change the disk type to growable, you reclaim some disk space. You can shrink the virtual
disk to reclaim even more disk space.
 Expand the size of a virtual disk so it is larger than the size specified when you created it.
 Defragment virtual disks.
 Prepare and shrink virtual disks without powering on the virtual machine (Windows
hosts only).

You can use the virtual disk manager with virtual disks created under VMware GSX
Server, VMware Workstation and VMware VirtualCenter (provided the virtual disk was
created on a GSX Server host managed by VirtualCenter).

Note: You cannot use the virtual disk manager to create physical disks. Physical disks
cannot be shrunk by the virtual disk manager or by Workstation.

For more information about using the virtual disk manager, read the following sections:

VMware Workstation 5.5


Features | Documentation | Knowledge Base | Discussion Forums

Prev Contents Last Next

Running the VMware Virtual Disk Manager Utility

To run the VMware Virtual Disk Manager utility, open a command prompt or terminal on
the host operating system. On a Windows host, change to the directory where you installed
your Workstation software. By default, this directory is C:\Program
Files\VMware\VMware Workstation.

The command syntax is:

vmware-vdiskmanager [options]

The options you can or must use include the following:

Options and Description


Parameters
<diskname> The name of the virtual disk file. The virtual disk file must have
a .vmdk extension.

You can specify a path to the folder where you want to store the
disk files. If you mapped a network share on your host operating
system, you can create the virtual disk on that share by providing
the correct path information with the disk file name.
-c Creates the virtual disk. You must use the -a, -s and -t options,
and you must specify the name of the virtual disk (<diskname>).
-r Converts the specified virtual disk, creating a new virtual disk as a
<sourcediskname>
result. You must use the -t option to specify the disk type to
which the virtual disk is converted and you must specify the name
of the target virtual disk (<targetdiskname>).

Once the conversion is completed and you have tested the


converted virtual disk to make sure it works as expected, you can
delete the original virtual disk file.

In order for the virtual machine to recognize the converted virtual


disk, you should use the virtual machine settings editor to remove
the existing virtual disk from the virtual machine, then add the
converted disk to the virtual machine. For information on adding
virtual disks to a virtual machine, see Adding Drives to a Virtual
Machine.
-x <n>[GB|MB] Expands the virtual disk to the specified capacity. You must
<diskname> specify the new, larger size of the virtual disk in gigabytes or
megabytes. You cannot change the size of a physical disk.

Caution: Before running the virtual disk manager utility, you


should back up your virtual disk files.
-d <diskname> Defragments the specified virtual disk. You can defragment only
growable virtual disks. You cannot defragment preallocated virtual
disks.
-p <mountpoint> Prepares a virtual disk for shrinking. If the virtual disk is
partitioned into volumes, each volume must be prepared
separately. The volume (C: or D:, for example) must be mounted
by VMware DiskMount at <mountpoint>. For information on
mounting and unmounting virtual disk volumes with DiskMount,
see the VMware DiskMount user's manual, available from the
VMware Web site at
www.vmware.com/pdf/VMwareDiskMount.pdf. The VMware
DiskMount Utility is available as a free download at
www.vmware.com/download/diskmount.html.

After you prepare the volume, unmount it with VMware


DiskMount. Continue mounting each volume of the virtual disk
and preparing it for shrinking until you complete this process for
all the volumes of the virtual disk.

You can mount only one volume of a virtual disk at a time with
VMware DiskMount. You can prepare volumes of virtual disks for
shrinking on Windows hosts only.
-k <diskname> Shrinks the specified virtual disk. You can shrink only growable
virtual disks. You can shrink virtual disks on Windows hosts only.

You cannot shrink a virtual disk if the virtual machine has a


snapshot. To keep the virtual disk in its current state, use the
snapshot manager to delete all snapshots. To discard changes made
since you took the snapshot, revert to the snapshot.
-a Specifies the disk adapter type. You must specify an adapter type
[ide|buslogic| when creating a new virtual disk. Choose one of the following
lsilogic]
types:

 ide — for an IDE adapter.

 buslogic — for a BusLogic SCSI adapter.

 lsilogic — for an LSI Logic SCSI adapter.

-s <n>[GB|MB] Specifies the size of the virtual disk. Specify whether the size <n>
is in GB (gigabytes) or MB (megabytes). You must specify the size
of a virtual disk when you create it.

Even though you must specify the size of a virtual disk when you
expand it, you do not use the -s option.
-t [0|1|2|3] You must specify the type of virtual disk when you create a new
one or reconfigure an existing one. Specify one of the following
disk types:

0 — to create a growable virtual disk contained in a single virtual


disk file

1 — to create a growable virtual disk split into 2GB files

2 — to create a preallocated virtual disk contained in a single


virtual disk file

3 — to create a preallocated virtual disk split into 2GB files


-q Disables virtual disk manager logging.

If you keep logging enabled, messages generated by the virtual


disk manager are stored in a log file. The name and location of the
log file appear in the command prompt or terminal window after
the virtual disk manager command is run.
Shrinking Virtual Disks with VMware Virtual Disk Manager

On a Windows host, you can use the virtual disk manager to prepare and shrink virtual
disks. You cannot use the virtual disk manager to prepare or shrink virtual disks located on
a Linux host. You cannot use the virtual disk manager to shrink physical disks. Shrinking a
virtual disk does not reduce the maximum capacity of the virtual disk itself. For more
information about shrinking, see Shrinking Virtual Disks.

Caution: You cannot shrink a virtual disk if the virtual machine has snapshots. To keep the
virtual disk in its current state, use the snapshot manager to delete all snapshots. To discard
changes made since you took a snapshot, revert to the snapshot.

You must prepare each volume of the virtual disk (drive C: or D:, for example) for
shrinking before you can shrink the disk. To prepare a volume for shrinking, you must first
mount it. To mount the volume, use the VMware DiskMount Utility, available as a free
download from the VMware Web site. Go to
www.vmware.com/download/diskmount.html.

The VMware DiskMount user's manual is available from the VMware Web site at
www.vmware.com/pdf/VMwareDiskMount.pdf. It contains instructions on mounting and
unmounting virtual disk volumes with DiskMount.

VMware DiskMount mounts individual volumes of a virtual disk. For the best results when
you shrink a virtual disk, you should mount all the volumes and prepare them for shrinking.

After you mount a virtual disk volume, use the virtual disk manager to prepare the volume
for shrinking. Once you prepare a volume, unmount it, then repeat the process for each
volume of the virtual disk. After you prepare all the volumes of the virtual disk, you can
shrink the virtual disk. For examples, see Preparing a Virtual Disk for Shrinking and
Shrinking a Virtual Disk.

Examples Using the VMware Virtual Disk Manager

The following examples illustrate how to use the virtual disk manager. You run the virtual
disk manager from a command prompt.

Creating a Virtual Disk

To create a new virtual disk, use a command like the following:

vmware-vdiskmanager -c -t 0 -s 40GB -a ide myDisk.vmdk

This creates a 40GB IDE virtual disk named myDisk.vmdk. The virtual disk is contained in
a single .vmdk file. The disk space is not preallocated.
Converting a Virtual Disk

To convert a virtual disk from preallocated to growable, use a command like the following:

vmware-vdiskmanager -r sourceDisk.vmdk -t 0 targetDisk.vmdk

This converts the disk from its original preallocated type to a growable virtual disk
consisting of a single virtual disk file. The virtual disk space is no longer preallocated, and
the virtual disk manager reclaims some disk space in the virtual disk so it is only as large as
the data contained within it.

Expand the Size of an Existing Virtual Disk

To expand the size of a virtual disk, use a command like the following:

vmware-vdiskmanager -x 40GB myDisk.vmdk

This increases the maximum capacity of the virtual disk to 40GB.

Renaming a Virtual Disk

To rename a virtual disk, first remove it from any virtual machine that contains the disk
(choose VM > Settings > <virtualdisk>, then click Remove).

Then use the following:

vmware-vdiskmanager -n myDisk.vmdk myNewDisk.vmdk

To rename the disk and locate it in a different directory, use:

vmware-vdiskmanager -n myDisk.vmdk ..\<new-path>\myNewDisk.vmdk

Note: The paths used in these examples assume a Windows host.

To locate the disk in a different directory but keep the same name, use:

vmware-vdiskmanager -n myDisk.vmdk ..\<new-path>\myDisk.vmdk

After you rename or relocate the virtual disk, add it back to any virtual machines that use it.
Choose VM > Settings, click Add, then follow the wizard to add this existing virtual disk.

Defragmenting a Virtual Disk

To defragment a virtual disk, use a command like the following:

vmware-vdiskmanager -d myDisk.vmdk
Remember, you cannot defragment a virtual disk if you allocated all the disk space when
you created the virtual disk. You cannot defragment a physical disk.

See Defragmentation of Disk Drives for a discussion of the performance impact of


defragmenting drives.

Preparing a Virtual Disk for Shrinking

Before you can shrink a virtual disk, you must prepare each volume on the disk (C: or D:,
for example) for shrinking. To prepare a volume, it must be located on a Windows host.
First you must mount the volume. To mount the volume, use the VMware DiskMount
Utility, available as a free download from the VMware Web site. For information about
downloading and using VMware DiskMount, see the VMware DiskMount user's manual,
available from the VMware Web site at www.vmware.com/pdf/VMwareDiskMount.pdf.
The VMware DiskMount Utility is available as a free download.

VMware DiskMount mounts individual volumes of a virtual disk. For the best results when
you shrink a virtual disk, you should mount all the volumes and shrink them.

After you mount a virtual disk volume, use the virtual disk manager to prepare the disk for
shrinking. To prepare the volume mounted as the M: drive for shrinking, use the following
command:

vmware-vdiskmanager -p M:

Once the preparations are complete, unmount the volume. Repeat this process for each
volume of the virtual disk. After you prepare all the volumes for shrinking, you can shrink
the virtual disk.

Shrinking a Virtual Disk

To shrink a virtual disk, it must be located on a Windows host. Before you can shrink the
virtual disk, make sure you prepare all the volumes of the virtual disk for shrinking. Then
use a command like the following:

vmware-vdiskmanager -k myDisk.vmdk

Remember, you cannot shrink a virtual disk if you allocated all the disk space when you
created the virtual disk. You cannot shrink a physical disk.

If the virtual disk has any snapshots, you cannot shrink the virtual disk. You must delete all
snapshots before you shrink the virtual disk.

Potrebbero piacerti anche