Difference between revisions of "How to Reduce the Size of a VMware Server 2.0 Virtual Disk"

From Virtuatopia
Jump to: navigation, search
Line 1: Line 1:
This HowTo covers the steps necessary to shrink a VMware Server 2.0 virtual disk. Before beginning this process it is important to understand a few requirements:
+
This HowTo covers the steps necessary to shrink a VMware Server 2.0 virtual disk. Two techniques are available, one involving VMware Tools and the another using the commandline ''vmware-vdiskmanager'' tool), both of which will be covered in this guide.
 +
 
 +
Before beginning this process it is important to understand a few requirements:
  
 
* At least one of the virtual machines currently using the virtual disk must have the VMware Tools package installed.
 
* At least one of the virtual machines currently using the virtual disk must have the VMware Tools package installed.
Line 9: Line 11:
 
* If the virtual disk is configured as ''Independent'' it must be in ''Persistent Mode''.
 
* If the virtual disk is configured as ''Independent'' it must be in ''Persistent Mode''.
  
== Installing VMware Tools ==
+
* Shrinking involves discarding the majority of any unallocated space within the virtual disk. As such, it is not possible to dictate the amount by which the disk should be shrunk. If the shrink process leaves insufficient space, additional space may be subsequently be allocated as outlined in [[How to Increase the Size of a VMware Server 2.0 Virtual Disk]].
 +
 
 +
== Shrinking a Virtual Disk from the Command Line ==
 +
 
 +
The size of a VMware virtual disk may be reduced from the command line using the ''vmware-vdiskmanager''. If the disk to be resized is pre-allocated it must first be convereted to a growable disk, the syntax for which is:
 +
 
 +
vmware-vdiskmanager -r ''<oldfilename>.vmdk'' -t ''<type> <newfilename>.vmdk''
 +
 
 +
where ''<oldfilename>.vmdk'' is the name of the virtual disk image file to be converted, ''<type>'' is the number from the above table indicating the target virtual disk type, and ''<newfilename>.vmdk'' is the name of the new, converted file.
 +
 
 +
For example, to convert a virtual disk image file called ''win2008-1_2.vmdk'' to a growable disk called ''new.vmdk'' the following command would need to be executed:
 +
 
 +
<pre>
 +
vmware-vdiskmanager -r  win2008-1_2.vmdk -t 0 new.vmdk
 +
</pre>
 +
 
 +
Once the disk has been converted, the size may be reduced, using the ''-k'' command line option. For example:
 +
 
 +
<pre>
 +
vmware-vdiskmanager -k new.vmdk
 +
</pre>
 +
 
 +
== Shrinking Virtual Disks Using VMware Tools ==
  
 
If VMware Tools are not currently installed on the guest operating system, steps to perform the installation are outlined in [[Understanding and Installing VMware Tools]].
 
If VMware Tools are not currently installed on the guest operating system, steps to perform the installation are outlined in [[Understanding and Installing VMware Tools]].

Revision as of 17:38, 27 October 2008

This HowTo covers the steps necessary to shrink a VMware Server 2.0 virtual disk. Two techniques are available, one involving VMware Tools and the another using the commandline vmware-vdiskmanager tool), both of which will be covered in this guide.

Before beginning this process it is important to understand a few requirements:

  • At least one of the virtual machines currently using the virtual disk must have the VMware Tools package installed.
  • There must be no current snapshots of any virtual machines which utilize the virtual disk.
  • If the virtual disk is configured as Independent it must be in Persistent Mode.
  • Shrinking involves discarding the majority of any unallocated space within the virtual disk. As such, it is not possible to dictate the amount by which the disk should be shrunk. If the shrink process leaves insufficient space, additional space may be subsequently be allocated as outlined in How to Increase the Size of a VMware Server 2.0 Virtual Disk.



Shrinking a Virtual Disk from the Command Line

The size of a VMware virtual disk may be reduced from the command line using the vmware-vdiskmanager. If the disk to be resized is pre-allocated it must first be convereted to a growable disk, the syntax for which is:

vmware-vdiskmanager -r <oldfilename>.vmdk -t <type> <newfilename>.vmdk

where <oldfilename>.vmdk is the name of the virtual disk image file to be converted, <type> is the number from the above table indicating the target virtual disk type, and <newfilename>.vmdk is the name of the new, converted file.

For example, to convert a virtual disk image file called win2008-1_2.vmdk to a growable disk called new.vmdk the following command would need to be executed:

vmware-vdiskmanager -r  win2008-1_2.vmdk -t 0 new.vmdk

Once the disk has been converted, the size may be reduced, using the -k command line option. For example:

vmware-vdiskmanager -k new.vmdk 

Shrinking Virtual Disks Using VMware Tools

If VMware Tools are not currently installed on the guest operating system, steps to perform the installation are outlined in Understanding and Installing VMware Tools.

Accessing the VMware Tools Control Panel

Once the VMware Tools are installed into the guest operating system of a virtual machine using the virtual disk, the shrink process is initiated using the VMware Tools Control Panel.The VMware Tools control panel provides a graphical environment in which a variety of VMware Tools settings may be configured and virtual disks reduced in size (although this feature is not available for pre-allocated virtual disks).

The default configuration for VMware Tools on Windows should have placed a VMware Tools icon in the Windows notification area in the bottom right hand corner of the Windows task bar (where the date and time are typically displayed) and also as an icon in the Windows Control Panel (accessed via Start->Control Panel).

The following figure illustrates a taskbar from a Windows server 2008 desktop containing the VMware Tools icon (the second icon from the left in the notification area):


The Vmware Tools icon in the Windows notification area


Once the taskbar icon has been located, double click on it to invoke the VMware Tools control panel interface.

To invoke the VMware Tools control panel on Linux, FreeBSD and Solaris systems, simply execute the following at a command-line prompt (note that since the control panel will appear in its own window on the desktop the trailing '&' character is used to run the process in the background, thereby freeing up the command line shell for running other commands):

/usr/bin/vmware-toolbox&

Once loaded, the control panel will appear as follows:


The VMware Tools Control Panel

Shrinking the Virtual Disk

The shrink tab of the VMware Tools control panel allows virtual disks associated with the virtual machine to be reduced in size by reclaiming unused areas on the disk. In the first instance, free space on the disk is reclaimed within the guest operating system. Subsequently, the virtual disk image on the host file system is then reduced in size by the VMware Server software.

To shrink the disk, select the Shrink tab of the VMware Tools Control Panel. Within the Shrink page, select the disk and click on the Shrink button. A number of confirmation dialogs will be displayed seeking confirmation that the size of the disk is to be reduced. Once confirmation has been received, VMware Server will reclaim unused space on the disk and reduce the size of the physical virtual disk image (.vmdk) file on the host system.

If the shrinking process reduced the size of the virtual disk by too much, simply enlarge the disk to the desired size following the instructions in the Virtuatopia How to Increase the Size of a VMware Server 2.0 Virtual Disk How To.