|
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.
advertisement
 |
| |
Veeam FastSCP 2.0 released by Veeam Software
- ESX to ESX direct copy
- Multiple ESX Management.
- Complete File Management & Windows Integration.
Learn more.
|
|
| |
| |
 |
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.
- I shutdown my guest OS.
- 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.
- 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.
- 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 3a. 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 3b. 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.
- 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
- In your host OS click Start->Run and type “cmd”
- 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.
|