A. Mikkelsen

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

Browsing Posts in ESXi

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

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 :-)

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

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.


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

Have you ever needed to verify the security or hardened state of you ESX hosts?

If yes, then these tools from ConfigureSoft.com or TripWire.com will help you make the process easier.
If no, take a look at the tools anyway – it’s always nice to know if your “babies” are safe ;-) .

http://www.configuresoft.com/compliance-checker.aspx
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.

TripWire ConfigCheck

http://tripwire.com/configcheck/download.cfm
Read a great how to.
http://searchvmware.techtarget.com/tip/0,289483,sid179_gci1344980,00.html

2 years ago a VMUG user in Denmark created a Ubuntu VM that could graficily could show the develeoment of the amount of VM’s in a Cluster.

Unfurtionally someone stole my labtop and the VM :-) .

So I had to create a new. And of cause it’s based on PowerShell ;-) .

The webpages shows the following information

  • Amount of VM’s in each Cluster
  • Amount of Hosts in each Cluster
  • The size of each Datastore and the amount of free disk space

Get the source code in the Download section under Vi Toolkit for Windows

Today I had to upgrade all our Jumphost VM’s from 256MB to 512MB of memory (more than 200 VM’s).
There are two ways accomplice this.

1. Do it manually (Very time consuming)

2. Script it with PowerShell

As the lazy person I am I decided that scripting was the way forward.
The script I came up with is as follows:

Connect-VIServer "vi_servername" -User "vi_username" -Password password"

# Select all VM's that have less than 512MB and change the Memory to 512MB
foreach ($vm in Get-VM | Select Name,MemoryMB | Where-Object{$_.MemoryMB -lt "512"}){
Set-VM $vm.Name -MemoryMB "512" -Confirm:$FALSE
}

To suppress the script to prompt for acceptance each time I added the following option
-Confirm:$FALSE

The script easily be changed to add or update other VM hardware settings.
- Number of CPU’s (Set-VM <vm-name> -NumCpu 2)

- Rename VM (Set-VM <vm-name> -Name “NewName”)

Find more options and ideas in the “Automating VMware with PowerShell – Hands-On Lab” from VMworls 2008.

Just remember if a VM is running you have to poweroff or shutdown the VM before the changes will take effect.
This is because a restart or reset does’t reload the vmx file.

Update:

The script is now updates so it also implements the following settings

  • Sets Memory Reservation to half of the amount of ram.
  • Sets Memory Limit to “Unlimited”
  • Sets the VM to check for new VMware Tools on PowerOn.
  • Sets the VM to sync time from host.

Take a look at the scripts here.

VMware has released a video comparing the two installations.
The video is worth watching

http://www.vmware.com/technology/whyvmware/resources/esxi-hyper-v-installation.html

Comparing ESXi and HyperV

A few weeks ago we were conducting a vRanger DR test of a VM (new host and new LUN).

The VM was restored succesfull, but when we powered it on we discovered that it for some unexplaned reason had lost the SCSI0:1 (100GB) and SCSI0:2(300GB) VMDK’s.
It had created two new 20GB VMDK’s instead.
We searched the LUN and found the two orginal *-flatvmdk files but not the descripter files.

Use Putty to identify the size of the *-flatvmdk file. ex. 100GB

ls -lah

From a VM (not running) create a new disk with the same size as the one you are missing. The name is not important.

Locate the newly created *.vmdk and *-flat.vmdk file. Copy the new *.vmdk file to the folder that contains the orginal *-flat.vmdk file.

cp rescue_me.vmdk /vmfs/volumes/mysan/rescued/rescued.vmdk

Use VI or NANO to change the following line as below from:
RW 419426200 VMFS “rescue_me-flat.vmdk”

To:
RW 419430500 VMFS “rescued-flat.vmdk”

Make sure that the name of the .vmdk file correspond to the SCSI*:*.fileName in the vmx file.
Now just power on the VM and the orginal disks are intac.

UPDATE
Today I found out that esXpress has created a website that can create a VMDK descriptor file.
http://www.esxpress.com/tools/wrapgen.php

Below is an exampel for the rescure_me-flat.vmdk file with a size of 100GB (107374182400 bytes)
esXpress WMDK descriptor file creator

The past few days I have been trying to learn the basic of PowerShell and the VIToolkit for Windows.
And after playing around with it, I thought that the best way to learn PowerShell was to have a goal.

And what better goal than converting the vcinfo script I created with VIPerlToolkit.

A beta version of the script is now avaiable for download – get it here.
But I have to warn you – the script is still in beta.

I have added a few of the old information and some new ones.
More info will be added when I get the time.

If you have any suggestions on what info the script should show in VC, please let me know.

This isn’t new!
But what is new, is that it’s now possible to run VM’s inside the hosts.

The performance isn’t the best, but it’s OK for testing.

Read the full article here.

www.vinternals.com has release a super cool looking tool (appliance) for automating the configuration of multi hosts.
The appliance is called statelesx (pronounced “stateless”).

Get more details on this super cool appliance at www.vinternals.com.

Dominic Rivera has documented a undocumented feature of VirtualCenter.

A very useful, yet very undocumented feature of the Virtual Infrastructure Client is that it can be configured to automatically pass your Active Directory credentials without you typing them in. To use: create a shortcut to the Virtual Infrastructure Client, then right-click on it and edit the shortcut properties. You’ll need to pass the program two arguments when calling it like so:

“C:\Program Files\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe” -passthroughAuth -s vc.yourdomain.com

Where “vc.yourdomain.com” is replaced with the DNS name for your VirtualCenter server. It’s extremely simple and just might hold of carpel tunnel syndrome for an extra few days.

Today i came accoss this handy little guide to boost performance of a VM.

  1. Disable the pre-logon screensaver:
    Open Regedit
    HKEY_USERS\.DEFAULT\Control Panel\Desktop
    Change the value of “ScreenSaveActive” to 0.
  2. Disable updates of the last access time attribute for your NTFS filesystem, especially for i/o intensive vm’s this is a real boost:
    Open CMD
    fsutil behavior set disablelastaccess 1
  3. Disable all visual effects:
    Properties on your desktop
    Appearance -> Effects
    Disable all options.
  4. Disable mouse pointer shadow:
    Control Panel -> Mouse
    Click on the tab “pointers” and switch “enable pointer shadow” off.

A big thanks goes to Yellow Bricks – Read the full guide here

TripWire is here….

Came accross this cool free tool to check your ESX 3.5 enviroment security against VMware hardening guide.

——————————–
Tripwire® ConfigCheckTM
is a free utility that rapidly assesses the security of VMware ESX 3.5 hypervisor configurations compared to the VMware Infrastructure 3 Security Hardening guidelines. Developed by Tripwire in cooperation with VMware, Tripwire ConfigCheck ensures ESX environments are properly configured—offering…… (Read More)
——————————–

I’m really looking forward to see what else they can come up with :-)

Ever wanted to see how many DRS VMotion your ESX enviroment is generating?

Using the following query you can extract the requried information from the VC database.

SELECT vpx_event.event_type, vpx_event.vm_name, vpx_event.create_time
from vpx_event where event_type like ‘%migrate%’

(Thanks to: Dave.Mishchenko

http://communities.vmware.com/message/969563)

Also see http://www.gabesvirtualworld.com/?p=69 for an idear to what you can do with the information in Excel.

Eric Siebert has writen a very good and explaining guide on how to troubleshoot snapshots on ESX 3.x.

Virtualization administrators can use snapshots on VMware ESX to travel back in time and figure out what went wrong with their virtual machines (VMs). But what do you do when your snapshots start acting funny? In this tip, we’ll troubleshoot potential problems that may come up when using snapshots on ESX.

Read it here or read my local copy.

Today i came accross a cool article about how to easy get your VM to boot from CD.
This only applies to ESX 3.0.x and not ESX 3.5.x, because in ESX 3.5.x you are able to use the VI Client to set this option and many more.

Read the full story here:

In summery:
add the following line anyware to your VM’s .vmx file.

bios.bootDelay = “boot delay in milliseconds”

Ex. Setting the boot delay to 15000 gives you 15 sec. to hit the F2.

RTFM Education has released a quick guide for ESXi

Get it here
http://www.rtfm-ed.co.uk/?p=476

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