Changes

Jump to: navigation, search

Command Line Management of VMware Virtual Disks

1,626 bytes added, 18:48, 29 May 2016
m
Text replacement - "<google>BUY_VMWARE_SERVER_2_BOTTOM</google>" to "<htmlet>vmware</htmlet>"
<table border="0" cellspacing="0" width="100%"><tr><td width="20%">[[Managing VMware Server 2.0 Virtual Disks|Previous]]<td align="center">[[VMware Server 2.0 Essentials|Table of Contents]]<td width="20%" align="right">[[VMware Server 2.0 Security - Access, Roles and Permissions|Next]]</td><tr><td width="20%">Managing VMware Server 2.0 Virtual Disks<td align="center"><td width="20%" align="right">VMware Server 2.0 Security - Access, Roles and Permissions</td></table><hr>  <htmlet>vmware</htmlet>  The previous chapter covered the management of VMware virtual disks using the VI Web Access interface and VMware Tools. Vmware VMware also provides the option to perform a wide range of virtual disk management tasks from the command line using the Virtual Disk Manager tool (''vmware-vdiskmanager'').
This chapter of [[VMware Server 2.0 Essentials]] will cover the use of ''vmware-vdiskmanager'' to create, defragment, shrink, rename, convert and extend VMware based virtual disks.
== The VMware Virtual Disk Manager Command Line Tool ==
The VMware Virtual Disk Manager command line tool is installed by default along with VMware products such as VMware Server. The executable file is named ''vmware-vdiskmanager'' and is installing in ''Program Files\VMware\VMware Server'' on Windows hosts, and ''/usr/bin'' on Linux. The tool accepts a wide range of command line arguments, a summary of which may be obtained by running the tool with no command-line arguments:
<pre>
<tr>
<td><p>0</p></td>
<td>
Growable (single .vmdk file)
<tr>
<td><p>3</p></td>
<td>
Pre-allocated (multiple 2GB files)
</table>
The ''vmware-vdiskmanager'' command requires a number of arguments to perform a virtual disk type conversion. The syntax for a type conversion is as follows:
vmware-vdiskmanager -r ''<oldfilename>.vmdk'' -t ''<type> <newfilename>.vmdk''
== Shrinking a Virtual Disk ==
Shrinking a virtual disk involves the reduction in size of a virtual disk image file by discarding unallocated space in the virtual disk. The process reduces the amount of space the virtual disk uses on the host, but does not change the size of the disk as far as the guest operating systems which use the disk are concerned. When more disk space is needed by a guest, VMware will automatically increase the size of the virtual disk file accordingly, until the maximize maximum specified size of the virtual disk is reached.
The amount by which a virtual disk file can be reduced depends entirely on the amount of unallocated space available and cannot be specified by the user. Only ''growable'' virtual disks on Windows hosts may be shrunk. It is not currently possible to shrink a virtual disk on a Linux host. Before a ''pre-allocated'' disk on a Windows Host can be shrunk it must first be converted using the steps outlined previously in this chapter. A further restriction is that there must be no snapshots of the virtual disk. If snapshots exist, they should be removed prior to performing the shrink operation.
Assuming the virtual disk to be shrunk is a "growable" disk and is on a Windows host, the first step is to prepare the virtual disk for shrinking. To do this, the disk must be mounted with a drive letter on the Windows host. This can be achieved using the ''VMware Dismount DiskMount Tool'' which is available for download from [http://www.vmware.com/download/ws/#utilities www.vmware.com/download/ws/#utilities]. Once installed, a virtual disk may be mounted using a command similar to the following:
<pre>
== Expanding a Virtual Disk ==
 
The size of a virtual disk may be expanded using the ''-x'' flag together with the new size of the disk. For example, the following command extends the size of the virtual disk containing in the file win2008.vmdk to 100GB:
 
<pre>
vmware-vdiskmanager -x 100GB win2008.vmdk
</pre>
 
An important point to note is that although the virtual disk has been extended by VMware, the new space will typically be treated as being unallocated by the guest operating system. In order to use the extra space, either an existing partition on the virtual disk will need to be extended, or a new partition created from within the guest operating system.
 
== Defragmenting a Virtual Disk ==
 
A VMware virtual disk may be defragmented only if created as, or subsequently converted to a ''growable'' disk. The defragmenting of ''pre-allocated'' virtual disks is not supported. In addition, any virtual machines making use of the virtual disk must be powered off prior to beginning the defragmentation process.
 
Defragmentation is initiated using the ''-d'' flag of the ''vmware-vdiskmanager'' tool combined with the name of the virtual disk image file. For example:
 
<pre>
vmware-vdiskmanager -d win2008.vmdk
</pre>
 
 
<htmlet>vmware</htmlet>

Navigation menu