A. Mikkelsen

VMware ESX scripts, commands, tools and other nice to know things that will make your virtualization days easier!!!!

Browsing Posts in vSphere (ESX)

Friday I was at a customer to upgrade their ESXi 4.0 (free) to version 4.1.
This should have been an easy task, download CD, burn it and install.

This wasn’t the case, the new ESXi 4.1 wouldn’t install, it kept freezing during the extract of the cim.vgz file.
The problem occurred on both the Dell custom of ESXi 4.0 U1 and the standard ESXi 4.1.
We googled and googled but didn’t find a solution – in the end we blamed the error on the old bios version 1.1.4.

To my luck the customer still had the CD we installed the server with 9 months ago – ESXi 4.0.

We installed ESXi using the old CD and then everything was working – but we still needed to upgrade to ESXi 4.1.

So now what to do …….

Normally you use the hostupdate utility or the Remote CLI but the hostupdate utility is not included in the free version of ESXi and the we didn’t want to install the Remote CLI on the computer.
To my luck I had the hostupdate utility installed but i kept getting this error when trying to upgrade the ESXi host.

“Failed to read the upgrade package metadata.xml”

The solution to our problem was:

  1. Since it was a ESXi free with out support, we decided to use the “ESXi command line interface”, witch is unsupported.
    Follow this guide to enable it (http://www.bauer-power.net/2010/04/vmware-esxi-hack-to-allow-ssh.html).
  2. Download and extract the upgrade ZIP file from VMware.
  3. From the VIclient, upload the extracted files to the host datastore, using the “datastore browser”
    - I uploaded the files to a folder named “upgrade”
  4. Put the ESXi host in “Maintance Mode”
    - Since it is a ESXi, this can only be done when all VM’s are powered off.
  5. Connect the the ESXi console using ex. Putty.exe.
  6. Navigate to the upgrade directory.
    cd /vmfs/volumes/local-datastore/upgrade
  7. Begin the upgrade process
    esxupdate update -m metadata.zip
    
  8. When the upgrade is finished, reboot the host.
    reboot
  9. To verify the new build number:
    - Connect to the host using the VIclient
    - Select the host
    - Choose the “Summery” tab
    - Verify that the ESXi version number and build has been updated

VMware has released their hardening guide for vSphere 4.0.

There is more than 100 guidelines to choose from, divided between

  • Introduction
  • Virtual Machines
  • Host (both ESXi and ESX)
  • vNetwork
  • vCenter
  • Console OS (for ESX only)

http://blogs.vmware.com/security/2010/04/vsphere-40-hardening-guide-released.html

Time keeping in a virtual environment can be a challenge to setup.

To help you, VMware has maintained a KB on the subject.

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1318

The KB presents best practices for achieving accurate timekeeping in Windows Guest operating systems. These recommendations include a suggested configuration for timesynchronization in the guest and on the host.

A more specific guide also exists for Windows and Linux servers:
For Windows read:
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=1318&sliceId=1&docTypeID=DT_KB_1_1&dialogID=73678717&stateId=0%200%2078515868
For Linux read:
http://kb.vmware.com/selfservice/microsites/microsite.do?cmd=displayKCPopup&docType=kc&externalId=1006427&sliceId=1&docTypeID=DT_KB_1_1

It’s great reading, but very nerdy :-)

Today I needed to create a list of all users connected to a vCenter sever through the Client.
And during so I created a few variants :-)

This creates a list of all usernames connected to the vCenter server through a vCenter Client.

$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
foreach ($sess in $sessMgr.SessionList){
   write "$($sess.UserName)"
}

If you want to see a witch clients have been idle for 60 minutes try this.

$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
foreach ($sess in $sessMgr.SessionList){
    if (($sess.LastActiveTime).addminutes(60) -lt (Get-Date)){
        write "$($sess.UserName)"
      }
}

If you the want to terminate the sessions that have been inactive  for more than 60 minute

$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
$oldSessions = @()
foreach ($sess in $sessMgr.SessionList){
    if (($sess.LastActiveTime).addminutes(60) -lt (Get-Date)){
        $oldSessions += $sess.Key
      }
}
$sessMgr.TerminateSession($oldSessions)

You can modify the hell out of this script to suit your needs and be my guest….

You can download the full script here.

The scripts are based on code found  at the PowerCLI community by LucD.
http://communities.vmware.com/message/914858#914858

vLogView by Xtravirt

No comments

vLogView, helps you view and search all LOG files from each of your ESX hosts from a single application.

For more info and the latest download, visit http://xtravirt.com/xd10132

vlogview

If you need a good guide to Interpreting the statistic from ESXTOP then take a look at this guide from VMware.

http://communities.vmware.com/docs/DOC-9279

I’m using it to troubleshoot performance issues (poor response times) from clients in different locations, when using the remote console.

Restarting the Management agents on ESX Server 3.x

  1. Login to the ESX host using SSH (or from COS)
  2. Type service mgmt-vmware restart.
    CAUTION
    Before restarting the Management Agent make sure that Automatic Startup/Shutdown is Disabled
    For more info see
    Restarting hostd (mgmt-vmware) on ESX Server Hosts Restarts Hosted Virtual Machines Where Virtual Machine Startup/Shutdown is Enabled (1003312)
  3. Type service vmware-vpxa restart.
  4. Exit the SSH session or logout of COS

Just found this very interesting article http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1013109 describing a problem with Windows 2008 and ESX 4 virtual hardware version 7.

In short the article states that you might have the disks go offline in a Windows 2008 VM if you

  • Upgrade virtual hardware from version 4 to 7
  • Installing a new VM with virtual hardware 7

There is two ways to get around this (taken from the VMware KB 103109)

————————

This can be resolved by changing the SAN Automount Policy on the system. See the Microsoft article http://support.microsoft.com/kb/973834 to change the SAN Policy to online.
The SAN policy is defined within the VDS environment of the system and is represented by the following values:
  • VDS_SP_UNKNOWN = 0×0
  • VDS_SP_ONLINE = 0×1
  • VDS_SP_OFFLINE_SHARED = 0×2
  • VDS_SP_OFFLINE = 0×3
On Windows Server 2008 Enterprise and Windows Server 2008 Datacenter, the default SAN policy is VDS_SP_OFFLINE_SHARED. On all other Windows Server 2008 editions, the default SAN policy is VDS_SP_ONLINE.
To query current SAN policy from the command line, start DISKPART and issue a SAN command:
C:\>DISKPART.EXE
DISKPART> san
SAN Policy : Offline Shared

DISKPART> exit

Alternatively, you can set the disk to Online after the hardware version upgrade.
To set the disk to Online:
  1. Log in to your system as an Administrator.
  2. Click Computer Management > Storage > Disk Management.
  3. Right-click the disk and choose Online.

If you are looking for a easy and simple guide for setting up iSCSI on vSphere (ESX 4.x) you might want to take a look at this guide from www.techhead.co.uk
http://www.techhead.co.uk/vmware-esxi-4-0-vsphere-connecting-to-an-iscsi-storage-target

Many admins have upgraded to Windows 7 and gotten into problems when trying to install the vSphere Client.

I have found a few guides to do a workaround, but the best guide is found at techhead.co.uk.
http://www.techhead.co.uk/running-vmware-vsphere-client-on-windows-7

Thanks to Kiwi Si.

Yesterday I by mistake extended a disk on a VM that had snapshots.
Using vmkfstools.
Kind of like this thread (http://communities.vmware.com/thread/238035).

This resulted in the following PowerOn error:

Failed to power on Servername on Host in Cluster:

Cannot open the disk ‘/vmfs/volumes/LUN/Folder/VM.vmdk’
Reason: The parent virtual machine disk has been modified since the child was created

The server was a database server so I had no choice than to fix it.

I tried the following with no luck:

  • Reverting to snapshot didn’t help – (Don’t try this if you don’t have a good backup)
  • Shrinking the vmdk again using vmkfstools – (This has not been possible since ESX 3.0)

Then I tried to use VMware Converter to do a V2V and in the first try (all defaults) that didn’t help the VM started with a BSOD.I tried again using the Converter but this time I changed one default parameter.In the “View/Edit Options” tap, remove the check mark in “Reconfigure destination virtual machine” and click YES to the warning.Removing the reconfigure option saved my day.
The VM started and I was able to restore the latest files from backup.


Last week I upgraded a Virtual Center server from Win2003 & MSSQL 2000 (32-bit) to Win2008 & MSSQL 2005 (64-bit).

During the installation of vCenter it asked for a 32-bit ODBC even though all the new systems was running 64-bit.
After a some time on Google i found that Windows 64-bit also includes a 32-bit version of the ODBC.

To set up a 32-bit DSN launch the 32-bit version of the Data Source Administrator. It is located at:
%systemdrive%\Windows\SysWoW64\Odbcad32.exe

Also se
http://www.vmwarewolf.com/32-bit-odbc-dsn-for-vsphere/

Duncan Epping has released a great post on how to partition your ESX 4.0 (vSphere) using scripting and the grafical installer

http://www.yellow-bricks.com/2009/05/27/partitioning-your-esx-host-part-ii/

You cannot define the sizes of the /boot, vmkcore, and /vmfs partitions when you use the graphical or text installation modes. You can define these partition sizes when you do a scripted installation.

The ESX boot disk requires 1.25GB of free space and includes the /boot and vmkcore partitions. The /boot partition alone requires 1100MB.

The vmcore is created automatically by the installer

Primary:
/     - 5120MB
Swap  - 1600MB
Extended Partition:
/var  - 4096MB
/home - 2048MB
/opt  - 2048MB
/tmp  - 2048MB

Today when I needed to upgrade my VC database from MSSQL2000 to MSSQL 2005 i came upon these quick guides.

http://blog.core-it.com.au/?p=27

http://spininfo.homelinux.com/news/VirtualCenter/2008/01/06/Howto_Move_Migrate_Design_VC_DB_from_SQL2000_to_SQL2005__

Howto add webages in vCenter

No comments

If you want to add a website tab to your vCenter, then here is a quick way to do it.

http://www.ntpro.nl/blog/archives/1270-vSphere-Plugin-Wizard-Released.html

Thanks to Ricky over at virtualizeplanet.com

Have you ever needed to document how secure your ESX servers are.

If the answer is yes then take a look at these free fools (Compliance Checkers) from ConfigureSoft.com.
http://www.configuresoft.com/compliance-checker.aspx

If the answer is no I would sugest you took a look at the tools anyway……

Compliance Checker for VMware ESX, checks the compliance of VMware ESX hosts against VMware hardening guidelines and Center for Internet Security (CIS) benchmarks.

Compliance Checker for PCI DSS, checks the compliance of servers and desktops against PCI DSS v1.2 requirements as specified by PCI Security Standards Council.

VMware have released a demo on YouTube that shows a “must have” for PowerShell users who automate and manage vSphere and vCenter through PowerShell.

The project is named “Onyx” and works like a middelware between the vCenter Client and the vCenter Server.
Onyx is unfortunately still in a private beta and therefore not acceble to the Public…….. :-(

Read more on rtfm-ed.co.uk.
http://www.rtfm-ed.co.uk/?p=1643

Or read more on the “get-scripting podcast” blog
http://get-scripting.blogspot.com/2009/08/get-scripting-podcast-episode-12-carter.html

Simon Long has posted a great test exam for the VCP410 exam.
I used it to study for mine.
http://www.simonlong.co.uk/blog/vcp-vsphere-4-practice-exam/

Also take a look at Somins study notes.
http://www.simonlong.co.uk/blog/vcdx-study-notes/

Another great and very usefull help is to use and memorize the vReference Card.
http://www.vreference.com/

Thanks to VCP for the below study sites
http://www.passguide.com/vcp-410.html
http://www.vcp-410.com

And not to forget Scott Vessey who created a great collection of resources for studying
http://vmwaretraining.blogspot.com/2009/09/studying-for-vcp-on-vsphere-4.html

Passed VCP410

9 comments

Yesterday I passed the VCP401 exam with 375 points.

I feel that the exam was harder than the old exam (VCP310).
Think VMware has realized this and dropped the target for VCI from 400 to 350 points.

Over the past few months we have seen a few Windows servers with a black screen.
Meaning

  • You can’t see the logon promt
  • You get a black screen when you connect with RDP

We found that the problem was caused by a change in the Windows color scheme.

The solution is to copy the color scheme from a simular Windows servers registry and add it the VM/server that has the problem using registry to connect to a remote server.

  1. On a simular windows server locate “[HKEY_USERS\.DEFAULT\Control Panel\Colors]” and export it to a file.
  2. Using the same Registry Editor connect to the remote server.
  3. Import the registry file just created or change the color scheme manually.
  4. Reboote the affected server to change the color scheme.

Default color scheme for a Windows 2003 server.
Default color scheme for a Windows XP.
Default color scheme for a Windows 2000 server.
Default color scheme for a Windows 2008 server.

Powered by WordPress Web Design by SRS Solutions © 2010 A. Mikkelsen Design by SRS Solutions