Categories
General

ESXi : Clone Windows 2008 R2

ESXi : Clone Windows 2008 R2

I ran into some issue recently when cloning an existing Windows 2008 R2 system, when manually using sysprep or using VMware to customise it I eventually ended up with the clone failing to boot with a C0000021C BSOD error.

The get around this I performed the following steps:

  1. Power off Source
  2. Change Windows 2008 R2 source type to Windows 2008 64-bit
  3. Clone VM
  4. Change source back to Windows 2008 R2 and power on
  5. Power on Clone allow to run sysprep
  6. Shutdown Clone
  7. Change clone to Windows 2008 R2

Don’t ask me why it works, it just does….

Categories
General

vSphere : Semi-automate Bulk Datastore Creation

vSphere : Semi-automate Bulk Datastore Creation

Use the following command to output new LUNs that are on the EVA8400 (these will not be set to RoundRobin):
Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*” | Where {$_.MultipathPolicy -ne “RoundRobin”} | ft –autosize

Copy output to text file and then open with Excel as below, adding the CapacityGB, Name and LunID columns. Use the vCenter GUI to obtain LUN IDs that can then be translated into the correct name as per the your sites LUN/Datastore naming convention.

CanonicalName

ConsoleDeviceName

LunType

LunID

Name

CapacityMB

CapacityGB

MultipathPolicy

naa.6001438005deea3c0000900003030000

/vmfs/devices/disks/naa.6001438005deea3c0000900003030000

disk

9

EUVMCL01_8400_DS09

491520

480

MostRecentlyUsed

naa.6001438005deea3c00009000030f0000

/vmfs/devices/disks/naa.6001438005deea3c00009000030f0000

disk

13

EUVMCL01_8400_TEST_DS04

716800

700

MostRecentlyUsed

Save the new CSV file to C:\new_datastores.csv

Now create the script to perform the task, copy the text below into C:\storage_setup.ps1. Modify the text in RED to suit your environment:

$CSVFile = “C:\NewDisk.csv

$vmcluster = “vm cluster name

$vmhost = Get-VMHost “vmhost fqdn

write “Importing CSV: $($CSVFile)”

$CSV = Import-CSV $CSVFile

Foreach ($Item in $CSV){

$HostID = $Item.HostId

$LunID = $Item.LunID

$LunPath = $Item.CanonicalName

$Name = $Item.Name

Write “Creating: $($Name)…Path: $($LunPath) “

$vmhost | New-Datastore -Vmfs -Name “$($Name)” -Path “$($LunPath)” -BlockSizeMB 8

Write “Created, applying RoundRobin multipathing policy… for cluster: $($vmcluster) “

foreach ($vmhost in get-cluster $vmcluster| get-vmhost) {

write node: $($vmhost.Name)

Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “$($LunPath)” | Where {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “roundrobin”}

}

Open the vSphere PowrCLI and connect to your vCenter; connect-viserver vCentername

Now execute the new script saved above.

Finally, if you are using Enterprise Plus, use the vCenter GUI to set Storage IO Control, this is a drop down box that can be set across all hosts with one change per datastore.

Categories
General

vSphere : Rename VM / Datastore Files

vSphere : Rename VM / Datastore Files

When you rename a VM from vCenter the underlying VM folder/file structure will not be updated.

The easiest way to resolve this is to perform a storage vMotion of the VM, this will rename all files/folders to match the new VM name.

Categories
General

vSphere : PowerCLI Create New VM

vSphere : PowerCLI Create New VM

The script below will semi-automate the creation of a new VM. Change the items in red to suit your environment.

$vmhost = Get-VMHost “hostname
$ds = Get-Datastore “datastore_name
$rp = get-resourcepool “pool_name

#Desired VM name

$vmname = “vm_name

New-VM -name $vmname -VMHost $vmhost -numcpu 2 -DiskMB 10240 -memoryMB 4096 -datastore $ds -guestID rhel5_64Guest -resourcepool $rp -cd -NetworkName dvPortGroup_Internal_VLAN110

To add an additional hard disk to the new VM:

Get-VM $vmname | New-HardDisk -CapacityKB (8*1gb/1024)

Alternative -guestID options:
windows7Server64Guest (2008 R2)
winNetEnterprise64Guest (2003 x64 Ent)

Categories
General

vSphere : PowerCLI Multipath Config

vSphere : PowerCLI Multipath Config

Round-robin configuration is per LUN, per host with vCenter 4.X and ESXi 4.x. When multiple hosts and datastores are in use this is a cumbersome and long-winded configuration that can easily be simplified with PowerCLI.

Single Host Configuration

Open PowerCLI and connect to a/the VCENTER server in your environment, change vcenter_name to match the hostname of your server:

connect-VIServer vcenter_name

To view hosts in a cluster, chage the cluster_name to match that in the vCenter GUI:

get-cluster cluster_name | get-vmhost

Confirm disks attached to each host:

get-cluster cluster_name | Get-VMHost | Get-ScsiLun -LunType disk

In the case of the environment I was working in I only wanted to change the configuration for EVA8400 disks attached to the VM hosts. There were also non-active/active storage devices attached which could not use round-robin.

To view the CanonicalName for all LUNs I used the command:

get-cluster cluster_name | Get-VMHost | Get-ScsiLun -LunType disk | fl -show canonicalname,vendor,capacitymb,model,luntype

From this you can analyse the CanonicalName and find the volumes that share the fist few digits, I ended up with all EVA8400 LUNs sharing ‘naa.6001438005’. An example output is below, you’ll note that two of the three LUNs share CanonicalName string (in red), the other does not (in green):

CanonicalName : naa.600508b1001c3a986c7a228dcad5099b
Vendor : HP
CapacityMB : 57207
Model : LOGICAL VOLUME
LunType : disk
MultipathPolicy : MostRecentlyUsed

CanonicalName : naa.6001438005dee9f70000600003cf0000
Vendor : HP
CapacityMB : 153600
Model : HSV450
LunType : disk
MultipathPolicy : RoundRobin

CanonicalName : naa.6001438005deea3c0000900002a00000
Vendor : HP
CapacityMB : 102400
Model : HSV450
LunType : disk
MultipathPolicy : RoundRobin

Once you have identified which disks you want to change, confirm the string is working – adding a ‘*’ to the end of it, for example in order for me to view the EVA 8400 disks attached to a host:

$vmhost = get-VMhost hostname

Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*”

CanonicalN ConsoleDeviceName LunType CapacityMB MultipathPolicy
ame
———- —————– ——- ———- —————
naa.600… /vmfs/devices/disks/naa.600… disk 102400 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 153600 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 153600 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 230400 RoundRobin

I had four LUNs presented from the EVA8400, so I knew this was working, I had also configured these to be RoundRobin already. This enabled quick identification that these were the correct volumes. You can use the following script to map CanonicalName to DatastoreName as per the vCenter console as can be found here: http://communities.vmware.com/message/1435173#1435173

$h = Get-VMhost hostname

# collect VMFS datastore name and extent cannonical names into a hashtable
$dsLunList = @{}
$dsView = $h | Get-Datastore | ? {$_.Type -eq “VMFS”} | Get-View
foreach ($ds in $dsView) {
foreach ($diskExtent in $ds.Info.Vmfs.Extent) {
$dsLunList[$diskExtent.DiskName] = $ds.Info.Name
}
}

#populate datastore name for each lun if available
$lunList = @()
$h | Get-ScsiLun | % {
$lun = “” | select ConsoleDeviceName, CanonicalName, DatastoreName
$lun.ConsoleDeviceName = $_.ConsoleDeviceName
$lun.CanonicalName = $_.CanonicalName

if ($dsLunList.ContainsKey($_.CanonicalName)) {
$lun.DatastoreName = $dsLunList[$_.CanonicalName]
}

$lunList += $lun
}

$lunList | ft -show CanonicalName,DatastoreName

Confirm EVA LUN’s that are not configured for RoundRobin multipathing:

$vmhost = get-VMhost hostname

Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*” | Where {$_.MultipathPolicy -ne “RoundRobin”}

To modify the LUN multipathing configuration you can use the following command:

$vmhost = get-VMhost hostname

Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*” | Where {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “roundrobin”

Multiple Host Configuration

To perform this for each node in a VM cluster use the following commands:

foreach ($vmhost in get-cluster cluster_name | get-vmhost) {
Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*” | Where {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “roundrobin”
}

Additional Information

naa.6001* is a HP storage device

naa.6006* is an EMC storage device

Categories
General

vSphere : vMA Setup

vSphere : vMA Setup

Import OVF template available form the VM Market Place: http://www.vmware.com/support/developer/vima/

Once completed on first boot a wizard will run, you and set an IP address and vi-admin user account password.

Press Alt-F2 from the VM console then login under vi-admin and execute these commands:

sudo vi /etc/sysconfig/keyboard

Change us to uk and reboot (if applicable!).

Login again via SSH or the console.

sudo vi /etc/ntp.conf

Hash out the serv 0/1/2 lines and enter the lines for your internal NTP servers (domain controllers will work):
server 192.168.1.1
server 192.168.1.2

Start the NTP service:

sudo service ntpd start

Configure NTP to start at boot:

sudo chkconfig ntpd on

Join the vMA appliance to the domain, modify the domain name, NETBIOSNAME and username:

sudo domainjoin-cli join domain.local NETBIOSNAME\\adminname

Enable connections to each ESXi host from the vMA:

vifp addserver vm01.domain.local
vifp addserver vm02.
domain.local
vifp addserver vm03.domain.local
vifp addserver vm04.domain.local

Confirm server connections:

vifp listservers

Enable remote logging to the vMA applicance, modify theVM host names as required:

vilogger enable –server vm01.domain.local –numrotation 20 –maxfilesize 10 –collectionperiod 10
vilogger enable –server vm02.
domain.local –numrotation 20 –maxfilesize 10 –collectionperiod 10
vilogger enable –server vm03.
domain.local –numrotation 20 –maxfilesize 10 –collectionperiod 10
vilogger enable –server vm04.
domain.local –numrotation 20 –maxfilesize 10 –collectionperiod 10

Logs are now collected and stored under /var/log/vmware/

Confirm logging setup:

vilogger list

You’ll probably need to resize the /var/log partition (via gParted) or add an additional drive, and modifiy the log location configurationin /etc/vmware/vMA/vMA.conf

Categories
General

VM : High Number of VHD’s – Boot Order Issues

VM : High Number of VHD’s – Boot Order Issues

Encountered an issue with a VM that had around 15 VHDs and multiple SCSI buses. After testing this a few times I discovered that on adding the 8th drive the boot order changed to: 1:0, 1:1, 1:2… 1:7 – this was automatic, I never changed the boot order.

To make matters worse, you can only see 8 VHDs in the VM BIOS, so it is impossible to change the primary boot disk to 0:0 again!

Workaround – I figured, lets move the boot volume to SCSI channel 1 and the data disks to an other controller. I move the data disks to channel 2/3 and the system booted. So, my system disk was on 1:0, additional disks were on channels 2:X and 3:X.

Update 02/02/2012: You can also set the boot drive in the vmx file. Power off the VM and add the line:
bios.hddOrder=scsi0:0 to force the VM to boot from disk 0:0.

Categories
General

vCenter VMware VirtualCenter Server WIll Not Stay Started

vCenter VMware VirtualCenter Server WIll Not Stay Started

Installation of vCenter Server succeeds, but services will not stay started. The most recent vpxd log shows the following error:

[2010-10-11 16:51:49.252 03800 error ‘App’] [VpxVmomi] Failed to create WebService socket: class Vmacore::SystemException(An attempt was made to access a socket in a way forbidden by its access permissions. )

[2010-10-11 16:51:49.252 03800 error ‘App’] [VpxdVmomi] Failed to start VMOMI services: An attempt was made to access a socket in a way forbidden by its access permissions.

[2010-10-11 16:51:49.252 03800 info ‘App’] Shutting down VMware VirtualCenter…

In this case McAfee EPO FrameWork Service was using the same port as the vCenter service. This can be verified by stopping the FrameworkService.exe process.

To resolve this issue change the vCenter HTTP/HTTPS Service ports to a port other than 8443/8080.

Categories
General

vSphere: Thin/TBZ disks cannot be opened in multiwriter mode

vSphere: Thin/TBZ disks cannot be opened in multiwriter mode

When using a ‘Virtual’ SCSI Bus Sharing controller on a VM Windows 2008 Cluster I was presented with the following error when creating disks via the vSphere Client:

Thin/TBZ disks cannot be opened in multiwriter mode.

Neither VM would power on with the new disk attached.

To resolve this, create the new vDisk from the shell using the command: vmkfstools -d eagerzeroedthick -c 20G -a lsilogic DISKNAME.vmdk

The important part of this command is eagerzeroedthick without this, or using thin or zeroedthick will result in the the same error being presented at power-on of the VM.