The following examples illustrate
how to use the virtual disk manager. You run the virtual disk manager from a
command prompt.
To create a new virtual disk, use
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.
To convert a virtual disk from
preallocated to a growable disk, use 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. All of 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 the following:
vmware-vdiskmanager
-x 40GB myDisk.vmdk
This increases the maximum
capacity of the virtual disk to 40GB.
Cuando es el
disco inicial no es el que tiene el nombre disck-flat.vmdk aunque tenga el
tamaño es el que tiene el nombre disk.vmdk.
To rename a virtual disk, first
remove it from any virtual machine that contains the disk (choose VM
> Settings > <virtualdisk>, then click Remove).
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.
To defragment a virtual disk, use
the following:
vmware-vdiskmanager
-d myDisk.vmdk
Remember, you cannot defragment a
virtual disk if you preallocated 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 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 Shrinking Virtual Disks with VMware
Virtual Disk Manager.
VMware DiskMount mounts individual
volumes of a virtual disk. For optimal shrinking of 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 at the M drive for shrinking, use the following:
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 the
following:
vmware-vdiskmanager
-k myDisk.vmdk
Remember, you cannot shrink a
virtual disk if you preallocated all the disk space when you created the
virtual disk. You cannot shrink a physical (raw) disk.
You cannot shrink a virtual disk
if the virtual machine has a snapshot. To keep the virtual disk in its current
state, simply remove the snapshot. To discard changes made since you took the
snapshot, revert to the snapshot.
If your
host is a multiprocessor system (multiple physical processors) or if the
processor or processors are hyperthreaded (where each physical processor is
split into two or more logical processors), you can associate each virtual
machine with a specific processor on the host.
By default,
each virtual machine is associated with all physical and logical processors on
the host. The virtual machine uses whichever processor is available at the time
it needs to execute instructions.
To
associate a virtual machine with a specific physical or logical processor on
the host, do the following.
Note: These
steps apply to virtual machines on Windows hosts and on Linux hosts with 2.6.x
kernels.
In a text
editor, open the virtual machine's configuration file (.vmx).
Add the
following line for each processor with which you do not want to associate the
virtual machine:
processor.use = FALSE
where is the number of the processor on the host.
On a
Windows host, processors are listed in the registry. To view the processors,
complete the following steps.
Choose Start>Run,
then type regedt32. The Windows registry opens.
In the
registry, choose HKEY_LOCAL_MACHINE>HARDWARE>DESCRIPTION>System>CentralProcessor.
Each CPU on the host is listed here, numbered starting with 0.
Expanding the Virtual Disk Size in 4 Steps
Applies to: GSX Server, VMware Server, VMware Workstation |
|
In this article I will show you an effective way to expand the virtual
disk size in 4 steps. It's easy and doesn't require installing any additional
OS or third-party tools.
Running out of disk space is a common problem and a very annoying one as
it always comes all of a sudden. When you run out of hardware space, the idea
of going out to buy a new disk makes you sick. A benefit of using a virtual
machine is that you don’t have to go out to expand the disk. You just need to
know how to do it.
One day I faced the same problem. I got one the Windows insufficient
disk space message on my virtual machine:
You are running out of disk space on Local Disk (C:).
To free space on this drive by
deleting old or unnecessary files, click here…
I realized that I needed more space. I spent much time searching through
the Internet and looking for the solution in VMware manuals. Finally, I found
my own way to get rid of the problem.
To start with, I needed to make sure that the disk I had was in a
consistent state for expanding. It was also necessary to make a backup so that
I could always get back to what I had had before. Besides, the task was not
only to expand the disk itself as this wouldn’t give me the desired result, but
also increase the Windows partition to the full disk size. I worked out this
approach testing it on VMware Workstation. However, it can definitely be
applied to other VMware products: VMware Server, GSX Server, etc.
I am using Windows XP professional SP2 with a 4 GB capacity
pre-allocated disk (I have several snapshots taken - so the machine itself
occupies 7.3GB). My XP installation uses one NTFS drive but most things in the approach can
also be used by those who use FAT. For my needs I needed to expand the vmdk to
10 GB. Thus, I needed 17.3 GB of the host machine free disk space: 7.3 GB for
backup + 10GB for the destination disk.
Step 1. Checking the disk consistency
Before the expansion I had to see if the virtual disk is consistent. This
step is not vital, but as the upcoming steps will change the structure of my
disk, I have to make sure everything works ok, before I start to improve it.
1. I shutdown my guest OS.
2. I used vmware-mount utility to mount the virtual disk into host OS:
pressed Start->Run and typed “cmd”. In the command window I typed:
D:\Program Files\VMware\VMware Workstation>vmware-mount v:
G:\vmimages\winxp_pro_sp2\diskc.vmdk
The operation took less that 1 minute.
3. Then I used built-in Windows utility chkdsk to test the virtual disk for
consistency.
To see the full list of available options, please run the ‘CHKDSK /?’
command.
In my case, I ran the command as follows: ‘chkdsk V: /F /X’
which means that the utility will fix all the errors found (which is performed
by /F) and, in case if you had some files opened on this disk, /X forces its
unmount.
As a result, I saw that my disk was ok:
D:\Program Files\VMware\VMware Workstation>chkdsk /F V:
The type of the file system is NTFS.
CHKDSK is verifying files (stage 1 of 3)...
File verification completed.
CHKDSK is verifying indexes (stage 2 of 3)...
Index verification completed.
CHKDSK is verifying security descriptors (stage 3 of 3)...
Security descriptor verification completed.
4184900 KB total disk space.
3004792 KB in 24880 files.
7248 KB in 3054 indexes.
0 KB in bad sectors.
51512 KB in use by the system.
22976 KB occupied by the log file.
1121348 KB available on disk.
4096 bytes in each allocation unit.
1046225 total allocation units on disk.
280337 allocation units available on disk.
The operation took me about 2 minutes.
4. I used vmware-mount utility to unmount the virtual disk from host OS. In
case you don’t have vmware-mount utility, you can download it here: http://www.vmware.com/download/eula/diskmount_ws_v55.html
In the command window I typed:
D:\Program Files\VMware\VMware Workstation>vmware-mount v: /d
Now everything was ready to start expanding the vmdk disk. However, before I
had to backup my virtual machine to be sure that I could always restore the
virtual machine if things went wrong.
Step 2. Backup of the virtual machine
I backed up the virtual machine folder by copying the entire VM folder
to the backup directory (C:\vm_backup\). Please don’t forget to copy the
snapshots folder as well.
The command looked as follows:
xcopy "C:\vmware_vms\winXPproSp2\*.*" "c:\vm_backup\winXPproSp2\*.*"
C:\vmware_vms\winXPproSp2\564d13ea-a63b-e915-a27f-7752c1d76fa1.vme
C:\vmware_vms\winXPproSp2\diskC-000001.vmdk
C:\vmware_vms\winXPproSp2\diskC-000002.vmdk
C:\vmware_vms\winXPproSp2\diskC-000003.vmdk
C:\vmware_vms\winXPproSp2\diskC-flat.vmdk
C:\vmware_vms\winXPproSp2\diskC.vmdk
C:\vmware_vms\winXPproSp2\vmware-0.log
C:\vmware_vms\winXPproSp2\vmware-1.log
C:\vmware_vms\winXPproSp2\vmware-2.log
C:\vmware_vms\winXPproSp2\vmware.log
C:\vmware_vms\winXPproSp2\Windows XP Professional-Snapshot1.vmem
C:\vmware_vms\winXPproSp2\Windows XP Professional-Snapshot1.vmsn
C:\vmware_vms\winXPproSp2\Windows XP Professional-Snapshot2.vmem
C:\vmware_vms\winXPproSp2\Windows XP Professional-Snapshot2.vmsn
C:\vmware_vms\winXPproSp2\Windows XP Professional-Snapshot3.vmem
C:\vmware_vms\winXPproSp2\Windows XP Professional-Snapshot3.vmsn
C:\vmware_vms\winXPproSp2\Windows XP Professional.nvram
C:\vmware_vms\winXPproSp2\Windows XP Professional.vmsd
C:\vmware_vms\winXPproSp2\Windows XP Professional.vmx
C:\vmware_vms\winXPproSp2\Windows XP Professional.vmx.lck
20 File(s) copied
It took me 7.26 GB (7,796,603,535 bytes) to backup my virtual machine
together with 3 snapshots.
Step 3. Solving snapshot problems
To my astonishment, this was the most time-consuming out of all the
steps.
To resolve this problem, I deleted all snapshots except the one selected for
further extending.
I didn’t worry about deleting the snapshots as I had made a backup.

The result of this step was the following:

Alternatively, you can clone the selected snapshot into a standalone
disk.
I fulfilled the step in 10 minutes.
Step 3. Virtual disk expansion
The essential step of the whole procedure is expanding the virtual disk
capacity. Having prepared the backup, I started expanding my disk using the
VMware utility called vmware-vdiskmanager.
1. The command window utility vmware-vdiskmanager.
This utility uses the following syntax:
VMware Virtual Disk Manager - build 19175.
Usage: vmware-vdiskmanager.exe OPTIONS diskName | drive-letter:
Offline disk manipulation utility
Options:
-c
: create disk; need to specify other create options
-d
: defragment the specified virtual disk
-k
: shrink the specified virtual disk
-n <source-disk> :
rename the specified virtual disk; need to
specify destination disk-name
-p
: prepare the mounted virtual disk specified by
the drive-letter for shrinking
-q
: do not log messages
-r <source-disk> :
convert the specified disk; need to specify
destination disk-type
-x <new-capacity> : expand the
disk to the specified capacity
Additional options for create and convert:
-a
<adapter> : (for use with -c only) adapter
type (ide, buslogic or lsilogic)
-s
<size> : capacity of the
virtual disk
-t
<disk-type> : disk type id
Disk types:
0
: single growable virtual disk
1
: growable virtual disk split in 2Gb files
2
: preallocated virtual disk
3
: preallocated virtual disk split in 2Gb files
The capacity can be specified in sectors, Kb,
Mb or Gb.
The acceptable ranges:
ide adapter : [100.0Mb, 950.0Gb]
scsi adapter: [100.0Mb, 950.0Gb]
ex 1: vmware-vdiskmanager.exe -c -s
850Mb -a ide -t 0 myIdeDisk.vmdk
ex 2: vmware-vdiskmanager.exe -d
myDisk.vmdk
ex 3: vmware-vdiskmanager.exe -r
sourceDisk.vmdk -t 0 destinationDisk.vmdk
ex 4: vmware-vdiskmanager.exe -x
36Gb myDisk.vmdk
ex 5: vmware-vdiskmanager.exe -n
sourceName.vmdk destinationName.vmdk
ex 6: vmware-vdiskmanager.exe -k
myDisk.vmdk
ex 7: vmware-vdiskmanager.exe -p m:
(A virtual disk first needs to be mounted at m:
using the VMware Diskmount Utility.)
Note that we need only –x option to expand our disk. This parameter gets
the argument <new-capacity> that contains a number and Kb, Mb, Gb (the
first letter must be uppercase and the second – lowercase – it’s case
sensitive).
2. Using vmware-vdiskmanager for expanding virtual disk diskC.vmdk
1. In your host OS click Start->Run and type “cmd”
2.
In the command window:
C:\path to VMware Workstation\vmware-vdiskmanager –x 10Gb diskC.vmdk
Result:
D:\Program Files\VMware\VMware
Workstation>vmware-vdiskmanager.exe -x 10GB
G:\wmimages\winxp_pro_sp2\diskc.vmdk
Using log file D:\DOCUME~1\ALEX\LOCALS~1\Temp\vmware-alex\vdiskmanager.log
Grow: 100% done.
The old geometry C/H/S of the disk is: 8322/16/63
The new geometry C/H/S of the disk is: 16383/16/63
Disk expansion completed successfully.
At the end of this operation I got the following warning:
If the virtual disk is partitioned, you must use a third-party utility
in the virtual machine to expand the
size of the partitions. For more
information, see:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647
However, I decided not to use any
third-party tools at all as there is the one that is built-in to the Windows
XP.
This step took me about 6 minutes. Now the vmdk disk was already
extended. All I had to do was to extend the Windows partition to the size I
needed.
Step 4. Extending the Windows partition to the necessary size
1. First of all, I set “host only” networking of backup machine.
To avoid any changes of backup, I changed the network configuration to
host-only (usually there might be mail synchronization or something like this
in your case):

In less than 1 minute the operation was over.
2. After that I added the expanded disk to the backed up machine.
To do so, I opened the backed up machine and edited its configuration, adding a
new existent disk (diskC.vmdk that I had just extended).

3. Finally, I expanded the partition as follows.
I started the backup machine. Then I clicked Start->Run and typed
“cmd”. In command line I typed diskpart to start Microsoft DiskPart built-in
utility. Then I entered commands ‘list disk’, ‘list volume’ to explore the
configuration of my disks subsystem:
C:\Documents and Settings\Administrator>diskpart
Microsoft DiskPart version 5.1.3565
Copyright (C) 1999-2003 Microsoft Corporation.
On
computer: WebServ
DISKPART> list disk
Disk ### Status
Size Free Dyn Gpt
-------- ---------- ------- ------- ---
---
Disk 0 Online 4095
MB 0 B
Disk 1
Online 10 GB 6150 MB
DISKPART> list volume
Volume ### Ltr
Label Fs
Type Size
Status Info
---------- --- ----------- -----
---------- ------- --------- --------
Volume 0 D
WinLite CDFS
CD-ROM 506 MB
Volume 1
C
NTFS Partition 4087 MB Healthy
System
Volume 2
E
NTFS Partition 4087 MB Healthy
I selected the disk that I had just extended and typed ‘extend’ to
extend the volume for the newly allocated space:
DISKPART> select volume=2
Volume 2 is the selected volume.
DISKPART> extend
DiskPart successfully extended the volume.
After this operation I got what I wanted - the 10 GB disk:
DISKPART> list volume
Volume ### Ltr
Label Fs
Type Size
Status Info
---------- --- ----------- -----
---------- ------- --------- --------
Volume 0 D WinLite
CDFS CD-ROM 506 MB
Volume 1
C
NTFS Partition 4087 MB Healthy
System
* Volume 2
E
NTFS Partition 10 GB Healthy
The operation took me 5 minutes, the step – 7 minutes.
Then I removed the extended disk from the backup machine
settings->Hardware. And that was it! Now my virtual machine had a 10GB disk!
Having fulfilled the 4-step procedure in 40 minutes, I’ve got the virtual
machine with a 10 GB disk that runs without any problems. I am satisfied at the
result and happy about the idea that I can apply this scenario at any time, if
I ever happen to run out of the disk space.
|
||
|
|
||
|
Randall Comm (January 03,
2007) |
||
|
|
||
|
Randall Comm (January 03,
2007) |
||
|
|
||
|
Randall Comm (January 03,
2007) |
||
|
|
||
|
Randall Comm (January 03,
2007) |
||
|
|
||
|
KIran Amin (December 19, 2006) |
||
|
|
||
|
Vlada, VM Weekly Support Team (November 27, 2006) |
||
|
|
||
|
Sean de Jager (November 26,
2006) |
||
|
|
||
|
Chris Reynolds (November 23,
2006) |
||
|
|
||
|
Dan Richards (November 22,
2006) |