Exporting VMs MAC and IP from vCenter

I stumbled across a forum post that describes a simple way to export all of your VMs MAC and ip addresses.

Just connect to your vCenter database using SQL Management studio and run the following:

select e.name, n.mac_address, n.network_name, i.ip_address
from vpx_vm v

inner join vpx_nic n on (v.id = n.entity_id)
inner join vpx_entity e on (v.id = e.id)
inner join vpx_ip_address i on (i.entity_id = n.entity_id and i.device_id = n.device_id)

Source: http://communities.vmware.com/thread/217326

gcc path problem with Debian 6.0.4 on VMware Fusion

I got the following error message while installing VMware Tools on Debian 6.0.4 on VMware Fusion.

The path "/usr/bin/gcc" is not valid path to the gcc binary.

I tried to fix it by installing the linux-header files…without any success.

I solved it by running:

apt-get install kernel-package

apt-get install gcc-4.3 linux-headers-`uname -r` -y

I found the solution here.

Enable Clipboard Copy and Paste in vSphere Client 4.1

First enable local or remote TSM from the vSphere Client on every ESXi host:

  1. Select the host and click the Configuration tab.
  2. Click Security profile > Properties.
  3. Click Local Tech Support or Remote Tech Support (SSH) and click Options.
  4. Choose the desired startup policy and click Start, then click OK.
  5. Verify that the daemon selected in step 3 shows as running in the Services Properties window

Next enable Clipboard Copy and Paste on every ESXi host:

Log in to the ESX/ESXi host as a root user and open the /etc/vmware/config file using a text editor.
Add these entries to the file:

isolation.tools.copy.disable="FALSE" 
isolation.tools.paste.disable="FALSE"

Save and close the file. The Copy and Paste options are only enabled when the virtual machines restart or resume the next time.

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

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

Linked: eagerZeroedThick powershell script

I found this great Powershell script that convert virtual disk files to eagered zeroed.

Awesome script! I had to make some changes to make it work in my environment.

 function Set-EagerZeroThick{
 param($vcName, $vmName, $hdName)

# Find ESX host for VM
 $vmImpl = Get-VM $vmName
 Write-Host $vmImpl
 if($vmImpl.PowerState -ne "PoweredOff"){
 Write-Host "Guest must be powered off to use this script !" -ForegroundColor red
 return $false
 }

 $vm = $vmImpl | Get-View
 Write-Host $vm
 $esxName = (Get-View $vm.Runtime.Host).Name
 Write-Host $esxName
# Find datastore path
 $dev = $vm.Config.Hardware.Device[10] | where {$_.DeviceInfo.Label -eq $hdName}
 Write-Host $dev
 if($dev.Backing.thinProvisioned){
 return $false
 }
 $hdPath = $dev.Backing.FileName
 Write-Host $hdPath

# For Virtual Disk Manager we need to connect to the ESX server
 $esxHost = Connect-VIServer -Server $esxName -User $esxAccount -Password $esxPasswd

# Convert HD
 $vDiskMgr = Get-View -Id (Get-View ServiceInstance -Server $esxHost).Content.VirtualDiskManager
 Write-Host $vDiskMgr
 $dc = Get-Datacenter -Server $esxHost | Get-View
 Write-Host $dc
 $taskMoRef = $vDiskMgr.EagerZeroVirtualDisk_Task($hdPath, $dc.MoRef)
 Write-Host $taskMoRef
 $task = Get-View $taskMoRef
 Write-Host $task
 while("running","queued" -contains $task.Info.State){
 $task.UpdateViewData("Info")
 }

 Disconnect-VIServer -Server $esxHost -Confirm:$false

# Connect to the vCenter
 Connect-VIServer -Server $vcName
 if($task.Info.State -eq "success"){
 return $true
 }
 else{
 return $false
 }
}

$vmName = "vm1"
$vCenter = "vcenter_server"
$esxAccount = "rootuser"
$esxPasswd = "password"

Set-EagerZeroThick $vCenter $vmName "Hard disk 1"

To validate before and after running the eageredZeroed script I run the following script:

$vm = Get-VM vm1 | Get-View
$vm.config.Hardware.Device[10].backing
$vm.config.Hardware.Device[10].DeviceInfo

Source: http://www.lucd.info/2009/11/15/scripts-for-yellow-bricks-advise-thin-provisioning-alarm-eagerzeroedthick/

Linked: Move-Template

A couple of days ago I found a really great PowerCLI script that move templates i vSphere. Awesome post and script by afokkema at ict-freak.nl!

Storage vMotion is a great feature to Move your VMs to other datastores. But what if you want to move your Templates?
In the current version of vSphere there is no option within the Client

function Move-Template{
    param( [string] $template, [string] $esx, [string] $datastore)

    if($template -eq ""){Write-Host "Enter a Template name"}
    if($esx -eq ""){Write-Host "Enter an ESX hostname"}
    if($esx -ne "" -and $datastore -eq ""){$vmotion = $true}
    if($datastore -ne ""){$svmotion = $true}

    Write-Host "Converting $template to VM"
    $vm = Set-Template -Template (Get-Template $template) -ToVM 

    if($svmotion){
        Write-Host "Migrate $template to $esx and $datastore"
        Move-VM -VM (Get-VM $vm) -Destination (Get-VMHost $esx) `
        -Datastore (Get-Datastore $datastore) -Confirm:$false
        (Get-VM $vm | Get-View).MarkAsTemplate() | Out-Null
    }        

    if($vmotion){
        Write-Host "Migrate $template to $esx"
        Move-VM -VM $vm -Destination (Get-VMHost $esx) -Confirm:$false
        ($vm | Get-View).MarkAsTemplate() | Out-Null
    }
}

The function above can be used to move a single template via:

Move-Template <template> <esxhost> <datastore>

Source: http://ict-freak.nl/2010/01/21/powercli-move-template/

Linked: Remove the “host currently has no management network redundancy” warning from your whitebox HA enabled ESX cluster

I found a great post on how to remove the Host <ESXi Hostname> currently has no management network redundancy warning that you get on a typical ESXi whitebox installation. Due to the fact that most whitebox machines don’t have multiple nics..

For more info and screenshots, checkout the original post.

When you completed building your ESX cluster from so called whitebox machines, you might see a warning sign at the cluster level. It will tell you the management network has no redundancy. This is probably correct because whitebox clusters usually don’t have 2 NIC’s for the management network.

To loose this irritating warning message do the following.

  1. Go to the properties of your cluster
  2. Select HA from the left pane
  3. Click the ‘Advanced Options’ button
  4. Fill in the first column of the first row by double clicking and typing the value ‘das.ignoreRedundantNetWarning’
  5. Fill in the second column of the same row by double clicking and typing the value ‘True’
  6. Close the Advanced Options window
  7. Now deselect the option ‘Enable HA’ and press OK
  8. HA will be disabled, this will take some time
  9. Go back to the options and select ‘Enable HA’ and press OK
  10. HA will be enabled and the warning will be gone

How I manually migrated from vCenter 4.0(32-bit) to 4.1u1(64-bit)

Last week I upgraded a vCenter 4.0 installation to 4.1u1. The vCenter was installed on a 32-bit VM so I needed to migrate the installation to a new 64-bit host.

I tried to do the migration according to the vSphere 4.1 upgrade pre-installation requirements and considerations guide. But sadly I got an error during the migration process.

RESTORE FILELIST is terminating abnormally.

The error is described in this thread at vmware communities.

Also, the datamigration scripts makes the original vCenter database corrupt. So if the datamigration fails, as it did for me, the original installation is trashed. (Luckily the datamigration scripts exports a backup before trashing it. But this procedure stinks anyway.)

So how did I migrate? Well I found a workaround and did the following.:

On the old vCenter 4.0 server (32-bit)

  1. Stop the vCenter service
  2. Install Microsoft SQL Server Management Studio Express
  3. Open Management Studio and detached the vCenter database.
  4. Copy the database files.
  5. Copy the % ProgramData% \ VMware \ VMware VirtualCenter \ SSL folder.
  6. Shutdown the vCenter VM.

On the new vCenter 4.1u1 server (64-bit)

  1. Install vCenter 4.1u1 with all the default settings. (This installs SQLExpress and the vCenter database)
  2. Uninstall vCenter from add and remove programs. (This does not remove the SQLExpress installation)
  3. Restore the % ProgramData% \ VMware \ VMware VirtualCenter \ SSL
  4. Install Microsoft SQL Server Management Studio Express
  5. Detach the newly installed database and attach the one from the old vCenter server.
  6. Create a ODBC connection to the local SQLExpress server with the old vCenter database.
  7. Install vCenter 4.1u1 and choose existing ODBC connection during the installation. The installer will detect the old vCenter database and upgrade it.

I wonder why VMware don’t recommend this procedure in the first place?

Install VMware Tools on Trixbox

Recently I had to install VMware Tools on a Trixbox installation.

1. First, in the VMware console, run ‘install vmware tools’ in the menu
2. Mount the cd-rom drive in an empty folder:

cd /media
mkdir cdrom
mount /dev/cdrom /media/cdrom
cd /media/cdrom

3. Copy the .tar.gz file to somewhere such as /home & extract..

cp VMware-tools.xxxxxxxxx.tar.gz /home
tar xvfz VMware-tools.xxxxxxxxx.tar.gz
cd /home/vmware-tools-distrib

4. Run the installation:

./vmware-install.pl

Source

How to speed up the vSphere 4 Client

Lately I’ve found that the my vSphere Client has been really slow.

It turned out that deleting the following 2 registry keys does the trick:

HKCU\Software\VMware\Virtual Infrastructure Client

HKCU\Software\VMware\VMware Infrastructure Client

Check out the original post here:

Apparently, all the prior versions and settings get retained during updates / upgrades and seem to cause significant delays due to components referenced that no longer exist.

Update 2011-04-21:

I also found this guide that shows you how to disable some Aero features that’s slowing down the client on Windows 7. Here is a link to the VMware KB.

This issue occurs when desktop composition is enabled.
To workaround this issue, disable desktop composition:
  1. Right-click the shortcut for the vSphere Client and click Properties.
  2. Click the Compatibility tab.
  3. Select Disable desktop composition.Note: This disables Aero desktop effects while the application is open.
  4. Click OK.
  5. Run the vSphere Client.

Aligning VM Partitions Without Losing Data

If you align your virtual disks the performance of your VM:s increases. The only problem is when you have a n already installed VM that doesn’t have aligned disks.

Do you really want to create a new VM with aligned disks and then install the OS, VMware tools, applications etc?

I found a great guide on how to align partitions without losing data on tuxyturvy.com.

It basically boils down to the following:

1.  Make sure the disk is defragmented
2.  Boot the system with the Gparted live CD.
3.  Select the parition you are wanting to resize and choose (Move/Resize)
4.  Shrink the volume by some amount, the smaller you shrink it the faster it will copy during the move step.  I usually shrink it a GB or so larger than the amount of data on the drive.
5.  Move the partition to right by a few MB’s to free up space at the start of the disk.
6.  Once the move completes, exit Gparted, not the entire live CD, just the Gparted application
7.  Start the terminal window on the live CD
8.  In the command window type ‘parted /dev/sda’ (substitute your actual device here) to start the command line parted editor
9.  Create a new partition at the start of the disk to fill in the space up to the section where you want to align your parition.  For example, if you want your system partition to start at sector 128, create a very small partition that takes up space from sectors 63-127.  The command would be something like this:

mkpart primary 63s 127s

This tells parted to create a new primary partition from sector 63 to sector 127.  That means the very next sector available is 128, a stripe aligned partition.  You may want a different start sector based on your array (some use 64K, some 128K, some bigger) but I’ve found the 128K alignment to work well with both 64K (Equallogic) and 128K (EMC Clariiion) stripe sizes.

10.  Exit parted and restart the Gparted GUI by clicking the Gparted icon.
11.  Use the Move/Resize option to resize the NTFS partition to fill the entire remaining space.  As pointed out by several users, you MUST uncheck the “Round to Cylinders” option prior to this.  I guess I thought this was obvious since we’re trying to align to a specific sector but that’s why I’m not a documentation writer.
12.  Exit gparted, run parted again, remove the small partition you created earlier and reboot.

How to backup vCenter running SQL Express

I found a great way to backup the vCenter SQL database running on SQL Express. The downside of running vCenter on SQL Express is the lack of the SQL agent. So running a scheduled backup of the SQL database is a bit tricky.

ExpressMaint is a small application set of scripts/stored procedures that enables you to run backup and maintenance jobs from commandline.(You could run the application ExpressMaint as well, but I installed the stored procedure version.)

I installed and configured it by doing the following:

  1. I created c:\backups to store my backups
  2. I downloaded the ExpressMaint TSQL file.
  3. I opened a new cmd.exe (with administrative rights) and installed the Stored Procedure by running:
    sqlcmd -S .\SQLEXP_VIM -i c:\expressmaint.sql
  4. I created c:\backups\database to store my database backups
  5. I created c:\backups\reports to store my reports
  6. I created c:\backups\backupscript.sql (SQL file that contains the backup settings, note that my script performs the backup and rebuilds the indexes on the vCenter database):
    exec expressmaint
    @database = 'ALL_USER',
    @optype = 'DB',
    @backupfldr = 'c:\backups\databases',
    @reportfldr = 'c:\backups\reports',
    @verify = 1,
    @dbretainunit = 'days',
    @dbretainval = 5,
    @rptretainunit = 'weeks',
    @rptretainval = 1,
    @report = 1
    exec expressmaint
    @database = 'VIM_VCDB',
    @optype = 'REINDEX',
    @reportfldr = 'c:\backups\reports',
    @rptretainunit = 'days',
    @rptretainval = 1,
    @report = 1
  7. I created c:\backups\PerformBackup.cmd (this is the batch script that executes the backup):
    sqlcmd -S .\SQLEXP_VIM -i c:\backups\backupscript.sql
  8. I schedule c:\backups\PerformBackup.cmd using the ordinary Windows scheduled task manager.

Replacing blurry windows icons in VMware Fusion.

One of the first things that I noticed after installing VMware Fusion was that the Windows icons look awful compared too the native Mac OS X ones..

But there is a way to fix this.

The solution is to download better looking icons and replace the default ones.

These will be located inside the .vmwarevm file of the relevant virtual machine. Typically, the .vmwarevm file is located in: ~/Documents/Virtual Machines. For those with a Bootcamp partition, you can find the .vmwarevm file in: ~/Library/Application Support/VMWare Fusion/Virtual Machines/Boot Camp/Boot Camp partition.vmwarevm.

Ctrl-click (right-click) this file and select “Show Package Contents.” Go to the Applications folder and you should see a list of Windows applications.

Select the application which icon you would like to replace and choose Get Info (Command-i or File » Get Info). The window that pops up should have an icon in the top left; this is the icon that you will replace.

Here are some alternative icons:

Benjigarner and TpdkDesign.net

References

http://blogs.vmware.com/teamfusion/2008/06/replacing-those.html

Linked: Updating ESXi 4.1 to Update 1 brings an error vim.fault.noHost | ESX Virtualization

Nice of Vladan to share this with the rest of us!

If you have any invalid, inaccessible or orphaned VMs (like me) in the inventory, you should unregister those virtual machines and try again with update in Update Manager.

Works for me.

Updating ESXi 4.1 to Update 1 brings an error vim.fault.noHost | ESX Virtualization.