Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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:
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:
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.
vmware-vdiskmanager [options]
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>).
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.
-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:
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.
The following examples illustrate how to use the virtual disk manager. You run the virtual
disk manager from a command prompt.
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:
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.
To expand the size of a virtual disk, use a command like the following:
To rename a virtual disk, first remove it from any virtual machine that contains the disk
(choose VM > Settings > <virtualdisk>, then click Remove).
To locate the disk in a different directory but keep the same name, use:
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.
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.
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.
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.