Up_to_date_with_ me: VMware Server 2.0

Why we live in an anti-tech age

Complex planning -- and true innovation -- is out of fashion, argues PayPal co-founder Peter Thiel

Does Science Back Samsung's 80% Battery Boost Claim?

A longer-lasting smartphone battery has been on the to-do list of tech companies for years. And now Samsung claims to have developed one that could keep your phone humming for 80 percent longer. But could the new battery really boost battery life by that much? Some scientists are skeptical, saying the study researchers didn't account for energy that's permanently lost after the battery goes through its first charge-recharge cycle.

US Military's Hypersonic Jet Could Fly 5 Times the Speed of Sound

The U.S. military is reportedly developing a hypersonic jet plane that could soar at up to five times the speed of sound — faster than a bullet, which generally travels at Mach 2, or twice the speed of sound.

World's Thinnest Light Bulb Created from Graphene

raphene, a form of carbon famous for being stronger than steel and more conductive than copper, can add another wonder to the list: making light. Researchers have developed a light-emitting graphene transistor that works in the same way as the filament in a light bulb.

Remote Control Airplanes Review

Remote control airplanes bring the thrill of flight to your backyard or local field

Showing posts with label VMware Server 2.0. Show all posts
Showing posts with label VMware Server 2.0. Show all posts

Tuesday 19 May 2015

Controlling VMware Virtual Machines from the Command Line with vmrun

Controlling VMware Virtual Machines from the Command Line with vmrun



The Basics and Syntax of vmrun

The vmrun tool is installed by default with the VMware Server and VMware Workstation products. Assuming that a standard installation is performed, the vmrun executable is located in\Program Files\VMware\VMware Server on Windows hosts and /usr/bin on Linux.
The basic command line syntax for using vmrun varies between host platforms and VMware product, but may be generally summarized as follows:
vmrun <host authentication flags> <guest authentication flags> <command> <parameters>
The host authentication flags are required to provide host information and the login and password for the host system to perform management tasks on the virtual machines. These are essentially the same credentials that would be used when accessing the VI Web Access management interface. These flags are required only on VMware Server hosts, and are not needed for VMware Workstation:
Flag
Description
-h
The https URL of the host to which vmrun is required to connect. Must also include the /sdk sub-directory and, optionally the port number (unless the -p flag below is used). For example, https://hostname:8333/sdk.
-PThe port number used by the host for virtual machine management. By default this will be 8333. If the port is specified in the URL (see above) this flag is not required.
-T
The type of VMware product which is running on the host. Options are ws for VMware Workstation, server for VMware Server 2 and server1 for VMware Server 1.
-uThe user name on the host to be used to log into the VMware management interface. The same as the user name that would be used when logging in using the VI Web Access interface.
-p
The password corresponding to the user name specified with -u as outlined above.
The guest authentication flags are specified if vmrun is required to log into the guest operating system to perform tasks such as work with guest files or execute commands. If such operations are not required, these flags may be omitted from the command line:
Flag
Description
-gu
A suitable user name via which vmrun may log into the specified guest operating system
-gpThe corresponding password for the guest user specified using the -gu flag.
The command argument instructs vmrun on the task to be performed. For example, startstop and reset are all valid commands. Other valid commands include those to perform tasks within a guest operating system, such as runProgramInGuest and deleteFileInGuest.
The parameters arguments specify additional information required for a specific command. If, for example, the start command is specified, the parameters argument is used to reference the .vmx file of the virtual machine which is to be started. In the case of running guest commands, both the .vmx file of the target virtual machine and the path to the program to be executed must be provided as parameters.
When specifying the virtual machine on which a command is to be executed, the location of the virtual machine .vmx configuration file must be provided. For VMware Workstation, this involves specifying the full path of the file. For example:
"C:\VMware\VMachines\win2008.vmx"
In the case of VMware Server 2.0, which introduced the concept of datastores, the name of the datastore in which the virtual machines resides must be provided together with the path of the .vmx file within that datastore. For example, to reference a virtual machine stored in the win2008 sub-directory of the Vol1 datastore, the vmrun path parameter would be defined as follows (note that the datastore name is enclosed in square brackets and separated from the sub-directory by a space character):
"[Vol1] win2008/win2008.vmx"
Bringing all of these different command line arguments together, a typical vmrun command to start a virtual machine on a host named hostname running VMware Server 2 might appear as follows:
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword stop 
                       "[Vol1] win2008/win2008.vmx"

Performing General Administrative Tasks with vmrun

The vmrun tool can be used to perform a number of general administrative tasks such as listing running virtual machines, installing VMware Tools in a guest operating system and registering virtual machines.
To list the currently running virtual machines on a VMware Server host:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword list
Total running VMs: 2
[Vol1] win2008-1/win2008-1.vmx
[Vol1] CentOS 5.2/CentOS 5.2.vmx
The VMware Tools installation process may be initiated from the command line as follows, although completion of the installation will need to be performed at the console of the guest operating system:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword installTools "[Vol1] CentOS 5.2/CentOS 5.2.vmx"
To register a virtual machine with the inventory on a specific VMware host, use the register commands as follows:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword register "[Vol1] CentOS 5.2/CentOS 5.2.vmx"
Similarly, to unregister a virtual machine from the host inventory:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword unregister "[Vol1] CentOS 5.2/CentOS 5.2.vmx"

Controlling Virtual Machine Power States with vmrun

The power states of virtual machines can be controlled either locally or remotely using the vmrun tool. The commands associated with these tasks are as follows:
  • start - Powers on the specified virtual machine. The virtual machine may started either with a GUI console visible, or no console using the gui and nogui options.
  • stop - Powers off the specified virtual machine. The power off process can be specified as hard or soft.
  • reset - Reboots the specified virtual machine. The reboot process can be specified as hard or soft.
  • Suspend - Suspends a virtual machine allowing fast restart via the start command. The suspend process can be specified as hard or soft.
  • pause - Pauses the specified virtual machine.
  • unpause - Unpauses a paused virtual machine.
When the hard option is specified for the stop and suspend commands, the virtual machine state changes without giving the guest operating system the opportunity to execute shutdown or hibernate procedures (analogous to disconnecting the power to a physical computer system). To ensure an ordered power off or suspension, be sure to specify the soft option. For example, to power off a specific virtual machine residing on host named hostname using the soft method:
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword stop 
          "[Vol1] win2008/win2008.vmx" soft
Similarly, to subsequently start the same virtual machine:
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword reset 
           "[Vol1] win2008/win2008.vmx"

Virtual Machine Snapshots with vmrun

VMware allows snapshots of virtual machines to be taken, whereby the state of a virtual machine (including the guest operating system) may be saved and then restored at a later date. This feature is particularly useful when performing operating system or application testing. Whilst snapshots may be taken and restored using the VI Web Access interface, it is often quicker and more convenient to use the vmrun tool. As with other vmrun commands, the appropriate authentication, host and virtual machine arguments must be provided along with a snapshot name.
The following example takes a snapshot (named MySnapshot) of a virtual machine using the snapshot command:
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword snapshot 
          "[Vol1] CentOS 5.2/CentOS 5.2.vmx" MySnapshot
The corresponding command to revert the virtual machine to the snapshot state uses the revertToSnapshot command and would read as follows:
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword revertToSnapshot 
          "[Vol1] CentOS 5.2/CentOS 5.2.vmx" MySnapshot
Note that if the virtual machine is running at the time the revertToSnapshot command is issued, the virtual machine will be placed into the suspended state while the restoration process is performed. To resume the suspended virtual machine using the restored state, it may be resumed using the vmrun start command as follows:
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword start 
          "[Vol1] CentOS 5.2/CentOS 5.2.vmx"
Finally, an existing snapshot may be deleted using the deleteSnapshot command:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword deleteSnapshot 
          "[Vol1] CentOS 5.2/CentOS 5.2.vmx" MySnapshot

Running and Managing Guest Programs with vmrun

One of the most useful features of the vmrun command is the ability to remotely run and manage programs on the guest operating system of a virtual machine.
A listing of the current process running on a guest operating system can be obtained using the listProcessesinGuest command. In order for this command to work, a valid guest user name and password must be provided. The following example show a typical command used to obtain a process listing from a Windows Server 2008 system, together with part of the output listing:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu administrator -gp guestpasswd 
     listProcessesInGuest "[Vol1] win2008-1/win2008-1.vmx"

Process list: 39
pid=0, owner=, cmd=[System Process]
pid=4, owner=, cmd=System
pid=392, owner=, cmd=smss.exe
pid=468, owner=, cmd=csrss.exe
pid=512, owner=, cmd=csrss.exe
pid=520, owner=, cmd=wininit.exe
pid=548, owner=, cmd=winlogon.exe
pid=596, owner=, cmd=services.exe
.
.
.
To run a program within a guest operating system, use the runProgramInGuest command, together with the path to the program which is to run. For example:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu administrator -gp guestpaswd 
  runProgramInGuest "[Vol1] win2008-1/win2008-1.vmx" -activeWindow "c:\windows\system32\cmd.exe"
Note that in order to run a graphical application on a Windows Vista or Windows Server 2008 guest, the -interactive command must be used. Without this command, the guest Windows system will display an Interactive services dialog detection warning dialog stating that the program cannot be displayed on the desktop.
By default, graphical programs started using vmrun on Windows guests will start in a minimized state (in other words the program will appear in the Windows task bar, but will not be displayed on the desktop). To force the program to appear on the desktop when it starts, the -activeWindow flag must be used. The following example shows the combined use of the -interactive and -activeWindow flags to run and display the Windows Notepad program on a Windows Server 2008 guest system:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu administrator -gp guestpasswd 
     runProgramInGuest "[Vol1] win2008-1/win2008-1.vmx" 
     -activeWindow -interactive "c:\windows\system32\notepad.exe"
To terminate a program running in a guest operating system, use the listProcessesInGuest command described above to ascertain the process id (pid) of the program in question and use that id (2368 in the following example) together with the killProcessInGuest command:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu administrator -gp guestpasswd 
              killProcessInGuest "[Vol1] win2008-1/win2008-1.vmx" 2368

Running Scripts Within a Guest

In addition to running executable programs on a guest operating system, vmrun also supports the running of scripts. Scripts are generally text based files containing instructions which are executed by an interpreter. For example, a Perl script would be executed using the perl interpreter and Ruby script by the ruby interpreter. Whilst some operating systems and scripting languages allow scripts to be executed just as any other program is executed (and without referring to the interpreter in the command line) this is not always the case. In such situations the command line to execute the script must provide the path to the script as a command line argument to the interpreter. For example, suppose that the following Ruby script contained in a file called hello.rb located in /home/ruby needs to be executed:
print "hello ruby!\n"
print "goodbye ruby!\n"
In order to execute this script, the hello.rb file needs to be passed as a command line argument to the ruby interpreter program as follows:
/usr/bin/ruby /home/ruby/hello.rb
In essence, the task of executing a script in this way using vmrun is very similar. In the following example, the hello.rb script is executed using the runScriptInGuest command:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu administrator -gp guestpasswd 
     runScriptInGuest "[Vol1] CentOS 5/Centos 5.vmx" /usr/bin/ruby /home/ruby/hello.rb

Using vmrun to Work with Guest Operating Systems Files and Directories

A particularly powerful feature of vmrun is the ability to interact with files residing in guest operating systems from either the host, or a remote system. For example, vmrun can be used to identify the existence of a file in a specific virtual machine guest, delete a file, create a directory and copy files between guest and host. In each case, a user name and password valid for logging into the guest operating system must be provided using the -gu and -gp flags.
The following commands require that VMware Tools be installed in the guest operating system. For more details on VMware Tools refer to the chapter entitled Understanding and Installing VMware Tools.
To check for the existence of a particular file:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd 
           fileExistsInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyFile

The file exists.
To delete a file on a guest:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd 
            deleteFileInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyFile
To create a new directory in a guest filesystem:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd 
            createDirectoryInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyNewDir
To remove a directory from a guest filesystem:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd 
            deleteDirectoryInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyNewDir
To list the files in a guest system directory:
vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu fred -gp guestpassword 
            listDirectoryInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred
Directory list: 5
.esd_auth
.dmrc
.gconfd
.recently-used.xbel
Desktop
To copy a file from the host system to the guest operating system (i.e copy the file /home/fred/MyFile on the guest to /tmp/MyFile on the host):
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd 
      copyFileFromGuestToHost "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyFile /tmp/MyFile
Conversely, to copy a file from the host to the guest:
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd 
      copyFileFromHostToGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /tmp/MyFile /home/fred/MyFile 
To rename a file on the guest:
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd 
      renameFileInGuest "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/MyFile /home/fred/MyNewFile

Capturing a Virtual Machine Screenshot

A screenshot of the console of a running virtual machine may be captured and written to a file on the host using the vmrun captureScreen command. The name of the file to which the image is to be written is supplied as a parameter to the command. Note that the image is created in PNG format, so the file should be given the appropriate .png filename extension. For example:
 vmrun -T server -h https://hostname:8333/sdk -u root -p mypassword -gu fred -gp guestpasswd captureScreen 
       "[Vol1] CentOS 5.2/CentOS 5.2.vmx" /home/fred/images/vm_screen.png

[facebook src="Uptodatewithme" width="500" height="400" hide-cover="true" posts="true"/]

VMware Server 2.0 Security - Access, Roles and Permissions

VMware Server 2.0 Security - Access, Roles and Permissions




Command Line Management of VMware Virtual DisksControlling VMware Virtual Machines from the Command Line with vmrun



VMware Server 2.0 Access Controls

The security features of VMware Server are designed to both control access to the VI Web Access management interface, and to restrict the activities that may be performed once a user has successfully logged in.
Access to the VI Web Access interface is controlled by the login screen which is presented when a web browser connects to the VMware Server system. Rather than duplicate functionality, VMware Server leverages the login and password mechanism offered by the host operating system. This level of security works in conjunction with VMware Server specific roles and permissions, defined by an administrator, which govern permitted actions once the user is logged in.
As such, a user can only log into the VI Web Access interface if they have a valid login and password on the system hosting VMware Server 2.0. In addition, the user must have been assigned the appropriate login permissions by a VMware Server administrator (by default, all users on the host system are configured to have no access). The first administrator was created during the VMware Server 2.0 installation process, though other users may be assigned administrative privileges through the VI Web Access interface.

Understanding Privileges, Roles and Permissions

Once a user has successfully logged into the VI Web Access interface, the next level of security involves the use of privilegesroles and permissions to control the actions which the user can perform and the information to which access is permitted.
privilege provides the right to perform a particular task on a specific VMware Server object within an object category. For example, a user may be given the privilege to power off a virtual machine.
Roles are essentially a number of privileges grouped together and given a name which can then be assigned to users and groups on specific objects or categories. For example, a group of privileges may be bundled into a role for trainee administrators which allows them power virtual machines on and off, but not to remove them from the inventory. VMware Server is supplied with a three pre-defined roles:
  • No Access - The default role for users other than the administrator. Denies access to the VI Web Access interface. Attempts to log in will be met with a You do not have permissions to login to the server message.
  • Read Only - Allows the user to login and view, but not change, configuration settings and virtual machine states. Access to virtual machine consoles is also denied.
  • Administrator - Provides full privileges to all aspects of VMware Server 2.0, including the ability to configure roles, permissions and privileges for all users and groups.
Obviously, a role does very little unless it is applied to a user or group of users and one or more VMware Server object. This pairing is referred to as a permission. For example, assigning the read-only role to a specific user, and applying that to an inventory object is essentially creating a permission.

Creating, Modifying and Removing Roles

As previously outlined, a role is a collection of privileges brought together in a named group. In addition to the three pre-defined system roles, it is also possible to construct custom roles from a wide range of privileges. To create a custom role, log into the VI Web Access interface as a user with administrative privileges, and select the Administration -> Manage Rolesmenu option to invoke the Manage Roles dialog. Once displayed, this dialog will list any existing roles. To create a new role, click on the Add button to launch the New Authorization Roledialog as illustrated below:

Create a new VMware Server Role

In the New Authorization Role dialog, enter a name for the new role in the field provided and then construct the role by enabling the required privileges. Note that each category may be selected in its entirety by selecting the category. Alternatively, unfold a category sub-tree and select from individual privileges. When the required privileges have been selected, click on OK to create the new role, at which point the role will appear in the list under the specified name.
To modify a role, select it from the list in the Manage Roles dialog and click on the Modify button. In the Edit existing roles dialog, make the necessary changes to the privilege selections, rename the role if necessary and click on OK to commit the modifications.
An existing role may be removed from the system by selecting it from the Manage Roles dialog and clicking on the Remove button. If the selected role is currently assigned to users or groups a dialog appears provided the choice to remove the role entirely together with any associated permissions, or to re-assign permissions to another pre-existing role.

Creating, Modifying and Removing Permissions

A permission is a combination of a role and a user or group and assigned to a VMware Server object. For example, a custom role called Training applied to a user called Bill and assigned to a virtual machine called win2008 is a permission since it dictates the access permissions Bill has to the 'win2008 virtual machine.
VMware Server permissions are managed from within the VI Web Access interface. When logged in as a user with appropriate administrative privileges, select the host system or virtual machine to which the new permission is to be associated from the Inventory panel. In so doing the first part of the permission, the VMware Server object, has been selected. Click on thePermissions tab in the workspace area to display the current permission configuration for the selected object.
To create a new permission on the selected object, click on the New Permission link located in the Commands panel to invoke the New Permission dialog as shown in the following figure:

Defining the user or group for a new VMware Server permission

From this screen, the second component of the permission is selected, namely the user or group to which the permission is to apply. Once the required user or group has been selected, the dialog updates to provide a drop down menu containing existing roles, together with a list of individual privileges and privilege categories. Either of the options may be used to configure the access privileges for the permission:

Defining the Role for a new VMware Server permission

To complete the permission creation process, select either a pre-existing role, or select the required combination of privileges. If the permission is to apply to all child objects of the select object, ensure that the Grant this permission to all child objects option is selected. Click OK when completed.
To modify a permission, select the associated host or virtual machine from the Inventory panel, click on the Permissions tab, select the required permission from the list and click the Edit Permission link in the Commands panel. In the Edit Permissions dialog make the changes necessary (including assigning the permission to a different user or group, or associating the permission with a different role) and click on OK to commit the modifications.
To remove a permission, repeat the steps outlined above, selecting the Remove Permission link in place of the Edit Permission link.

[facebook src="Uptodatewithme" width="500" height="400" hide-cover="true" posts="true"/]

Command Line Management of VMware Virtual Disks

Command Line Management of VMware Virtual Disks

PreviousTable of ContentsNext
Managing VMware Server 2.0 Virtual DisksVMware Server 2.0 Security - Access, Roles and Permissions



Contents

 [hide]


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:
vmware-vdiskmanager

Converting Virtual Disks

VMware Server supports both growable and pre-allocated virtual disks. In addition, the disks can be specified to be contained in a single file, or split into multiple 2GB files (usually only used on hosts with restrictive file size limits).
The virtual disk type is initially defined at the point that the disk is created. Whilst this is generally not a problem, VMware Server does not support the shrinking of pre-allocated virtual disks. Before a pre-allocated disk can be reduced in size, therefore, it is necessary to first convert it to a growable disk. This can be performed using the Virtual Disk Manager tool (vmware-vdiskmanager).
The type to which a virtual disk is to be converted is specified using the -t flag, together with the target disk type. This is represented by a number as outlined in the following table:
Type Identifier
Description
0
Growable (single .vmdk file)
1Growable (multiple 2GB files)
2Pre-allocated (single file)
3
Pre-allocated (multiple 2GB files)
4Pre-allocated ESX
5Compressed for streaming
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
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

  Creating disk 'new.vmdk'
  Convert: 100% done.
Virtual disk conversion successful.
Once the conversion is completed, the virtual machine will need to be configured to use the converted disk, or the new disk renamed to have the name of the original disk.

Renaming a Virtual Disk

An existing virtual disk may be renamed using the -n command line flag as follows:
vmware-vdiskmanager -n <oldfilename>.vmdk <newfilename>.vmdk
where <oldfilename>.vmdk is the name of the virtual disk image file to be renamed, and <newfilename>.vmdk is the new name of the file.

Creating a Virtual Disk

The creation of a virtual disk using the vmware-vdiskmanager tool requires the specification of a number of different configuration options:
  • The type of the virtual disk. This is specified using the -t flag combined with the numerical type identifier, as outlined in the above table.
  • The size of the new disk specified in GB with the -s flag.
  • The disk adapter type, using the -a flag and one of idebuslogic or lsilogic.
  • The name of the virtual disk image (.vmdk) file to contain the new virtual disk.
For example, to create a new 100GB, growable, SCSI BusLogic virtual disk in a file named NewDisk.vmdk, the following command would need to be executed:
vmware-vdiskmanager -c -t 0 -s 100GB -a buslogic NewDisk.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 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 may be shrunk. Before a pre-allocated disk 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 DiskMount Tool which is available for download from www.vmware.com/download/ws/#utilities. Once installed, a virtual disk may be mounted using a command similar to the following:
vmware-mount G: "D:\VirtualMachines\Win2008\Win2008.vmdk"
Once the virtual disk is mounted using a suitable drive letter (G: in the above example), the disk must be prepared for shrinking:
vmware-vdiskmanager -p G:
Once the disk is prepared, the vmware-vdiskmanager tool requires only the -k flag followed by the name of the virtual disk image file to perform a shrink operation. For example, to shrink a virtual disk named win2008.vmdk:
vmware-vdiskmanager -k win2008.vmdk
To unmount the virtual disk from the host system, use the vmware-mount command combined with the drive letter and the /d option:
vmware-mount G: /d

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:
vmware-vdiskmanager -x 100GB win2008.vmdk 
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:
vmware-vdiskmanager -d win2008.vmdk

[facebook src="Uptodatewithme" width="500" height="400" hide-cover="true" posts="true"/]

VMware Server 2.0

Managing VMware Server 2.0 Virtual Disks



VMware Server Virtual Disk and Device Types

Virtual disks provide the storage for guest operating system and user files. Each VMware Server virtual machine will likely have one or more virtual disks configured and during the lifecycle of a virtual machine virtual disks may be added and removed as needed. The size of a virtual disk is specified at creation time and can range from 1MB up to a maximum of 950GB.
When a virtual disk is first created (either during the virtual machine creation process or later) it may be configured as growable or pre-allocated. The virtual disk type may subsequently be converted using the vmware-vdiskmanager command line tool as described in the chapter entitled Command Line Management of VMware Virtual Disks. A growable disk is initially created smaller than the specified disk size, and subsequently grows as space is needed up until the maximum specified size is reached. This has the advantage that the disk creation process is shorter and less disk space on the host is used initially. A further advantage of growable disks is that the size of the disk can be reduced at a later time using the VMware ToolsShrink Disk feature (see the chapter entitled The VMware Tools Control Panel for more details on this and other VMware Tools features). These features, however, come at the cost of reduced performance (since system resources will be needed to increase the size of the disk as additional data is written).
In the case of a pre-allocated virtual disk, the entire space required for the disk is allocated at creation time. This has the advantage that virtual disk performance is not degraded due to the need to increase the disk size as more space is needed. Disadvantages include an increased amount of time needed to create the disk (taking several hours for a 950GB virtual disk) and the inability to reduce the size of the disk at a later time unless the disk is converted to growable.
An additional option allows virtual disks to be split amongst multiple 2GB files on the host, rather than contained in a single file. This option has little benefit unless VMware Server is hosted on a file system which limits file sizes to 2GB.
To the guest operating system running inside a virtual machine, virtual disks appear as though they are physical devices. As such, the disk can be configured to appear to the virtual machine as either an IDE or SCSI device. In the case of SCSI virtual disks, VMware uses a virtual SCSI controller which appears to the guest as either an LSI Logic or BusLogic controller. As such, guest operating system hardware drivers for these devices may need to be installed accordingly.

VMware Server Disk Modes

VMware Server virtual disks may be configured to run in Independent mode which provides two additional options in terms of disk configuration:
  • Persistent - Data written to the disk by the guest operating system is retained when the system is powered off. This is the normal mode of operation for most virtual disks.
  • Nonpersistent - Data written to the disk during a virtual machine session are discarded after the virtual machine is powered off or reset. This is useful if the guest operating system is required to be started with a clean system each time the virtual machine is powered on, perhaps in a testing or secure environment.
Disks configured as independent are not included in snapshots.

VMware Server Virtual Disk Caching Options

The disk write caching policy for virtual disks defines the point at which new data is written to the virtual disk (as opposed to being cached in memory before being written) by the guest operating system. These settings have implications for performance, with increased performance being available at the cost of data integrity. A choice of two policy options is available:
  • Optimize for safety - Data is not cached. Write operations made by the guest operating system are written immediately to the virtual disk image. Reduces risk of data loss in the event of a system failure, but results in slower disk write performance.
  • Optimize for performance - Write operations performed by the guest operating system are initially cached prior to being written to the virtual disk. Provides increased write performance at the cost of increased risk of data loss in the event of a system failure.

Adding a New Virtual Disk

A new virtual disk may be added to a virtual machine via the VI Web Access management interface (details of which are covered in the A Guided Tour of the VMware Server 2.0 Infrastructure Web Access Interface chapter of this book). SCSI based virtual disks may be installed on running virtual machines as long as those machines are running on VMware virtual hardware version 7 or later (the default setting when virtual machines are created in VMware Server 2.0). IDE based virtual disks or virtual machines running on older versions of the virtual hardware require that the virtual machine be powered off prior to the addition of a new virtual disk.
Once logged into the VI Web Access interface, the first step in adding a new virtual disk is to select the required virtual machine from the Inventory panel. In the Commands section of the virtual machine workspace, click on the Add Hardware link to invoke the Add Hardware Wizard as illustrated in the following figure:

The VMware Server Add Hardware Wizard

To add a new virtual disk, select the Hard Disk option from the list of new hardware devices to proceed to the Hard Disk page. Options are available to either create an entirely new virtual disk, or to use an existing virtual disk that may already have been created for a pre-existing virtual machine. In fact, this second option can be used to enable multiple virtual machines to share a virtual disk, although careful steps should be taken to avoid disk write conflicts (for example both guests attempting to write simultaneously to the same disk block will likely cause problems for most standard file systems).
Once a decision has been made about creating or re-using a virtual disk, the next wizard screen provides the option to configure the disk type, mode and caching options as described in the preceding sections of this chapter. Finally, a summary page is displayed highlighting the choices made during the configuration process. Clicking the Finish button will begin the addition process which, depending on the settings, may take some time to complete.

Modifying a VMware Server Virtual Disk Configuration

The current configuration of a virtual disk may be viewed and modified by logging into the VI Web Access interface and selecting the virtual machine to which the disk is attached from the Inventory panel. Once the workspace updates to reflect the selected virtual machine, locate the disk drive from the Hardware panel, click on it and select Edit... from the menu. This will display the hard disk settings dialog as illustrated in the following figure:

Editing the settings for a VMware Server virtual disk

An important point to note is that many of the settings will be read-only (and consequently grayed out) if the selected virtual machine, or any other virtual machine which shares the disk, is currently powered on. In addition, the Increase capacity... link shown in the above figure will not be visible if the virtual machine is powered on. To make changes to configuration values, or to increase disk capacity, it will be necessary to power off all virtual machines that utilize the virtual disk.

Enlarging a VMware Server Virtual Disk

The capacity of a virtual disk may be increased using the disk settings dialog (described above). As with most other virtual disk settings, a disk may only be increased in size when all virtual machines sharing the disk are powered off. Once this is achieved, select a virtual machine which uses the virtual disk from the Inventory panel of the VI Web Access interface, click on the required hard disk from the Hardware panel and select Edit... from the menu. Once the disk settings dialog appears, click on the Increase capacity... link to display the disk capacity fields as illustrated in the following figure:

Increasing the size of a VMware Server 2.0 virtual disk

The current size of the virtual disk is listed, together with two text boxes for the amount by which the disk is to be increased and the new capacity. Both are specified in gigabytes (GB), and either may be used to increase the size of the virtual disk. The amount of space available for allocation to the virtual disk is dictated by the available space on the datastore in which the virtual disk file resides. The current free space on the datastore is also listed beneath the capacity text boxes. The increase in virtual disk capacity cannot exceed this value.

Shrinking a VMware Server Virtual Disk

Unlike increasing the capacity of virtual disks, which is performed outside the virtual machine using the VI Web Access interface, virtual disks can only be reduced in capacity from within the virtual machine's guest operating system and requires the installation of VMware Tools. If VMware Tools are not currently installed on the guest operating system, begin by reading the chapter entitled Understanding and Installing VMware Tools.
Once VMware Tools are installed into the guest operating system, the next step is to access the VMware Tools Control Panel. 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). Double clicking on either of these options will invoke the control panel.
To invoke the VMware Tools control panel on Linux and Solaris systems, simply execute the following at a command-line prompt:
/usr/bin/vmware-toolbox&
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.
In order to be able to perform a shrink operation the virtual disk must not have been created as a pre-allocated disk and there must be no current snapshots of the virtual machine. For details on converting a pre-allocated disk to a growable disk refer to the chapter entitled Command Line Management of VMware Virtual Disks.
If the virtual disk is an independent disk it must be in persistent mode. In the case of Linux guest operating systems, the operation must be performed as superuser.

Removing a VMware Server Virtual Disk

Virtual disks are removed using the VI Web Access interface. As with previous tasks, any virtual machines which access the virtual disk must first be powered off. Assuming this to be case, select the virtual machine to which the disk is attached from the Inventory panel, click on the disk drive in the Hardware panel and select either Remove or Delete from disk. TheRemove option simply removes the disk from the configuration of the currently selected virtual machine. The physical .vmdk file which represents the virtual disk remains intact in the datastore in which it was created and is available for use by other virtual machines.
The Delete from disk option, on the other hand, both removes the disk from the configuration of the select virtual machine and also physically removes the .vmdk file from the datastore. As such the disk is no longer available and the space it used is released.

[facebook src="Uptodatewithme" width="500" height="400" hide-cover="true" posts="true"/]