«

»

Mar 21 2013

ESXi host disk.terminateVMOnPDLDefault configuration using PowerCLI

This section is updated since vSphere 5.5 was GA during VMworld 2013.
From now on the configuration option has changed regarding two things:

  • Name – It is now called VMkernel.Boot.terminateVMOnPDL and not Disk.terminateVMOnPDLDefault
  • Configuration – It is now an advanced ESXi configuration parameter and not a text string in the ESXi host file /etc/vmware/settings

Continue reading if you need to configured the ESXi host disk.terminateVMOnPDLDefault setting in a version prior to 5.5. If you need a configuration script for vSphere 5.5 i got a post here.

I have been asked several times how to automatically configure the ESXi host, version 5.1.x, host file “settings” to include the configuration:

  •  disk.terminateVMOnPDLDefault=”true”

I will not explain the purpose of this setting since Duncan Epping provides excellent information about the topic in the below blog posts:

  • http://www.yellow-bricks.com/2012/03/16/permanent-device-loss-pdl-enhancements-in-vsphere-5-0-update-1-for-stretched-clusters/
  • http://www.yellow-bricks.com/2012/09/20/enabling-pdl-enhancements-in-a-non-stretched-environment/

There are of course many ways to take care of this and i will provide one configuration example i have used a couple of times during the initial ESXi host deployment. The script included at the bottom of this blog post includes only the necessary part to configure the ESXi host file /etc/vmware/settings and the required configuration to connect to the ESXi host, not the entire initial ESXi host configuration script.

There were two major customer requirements to respect during my last assignment:

  1. Do not type passwords in script files.
  2. SSH must never be activated per ESXi host after reaching production status.

The second customer requirement means i can start the ESXi host SSH service during the initial ESXi host configuration as long as the ESXi host SSH service is turned off after the initial ESXi host configuration.

First thing is to create the “settings” file by opening a text editor and type only the below line:

  • disk.terminateVMOnPDLDefault=”true”

Next, place the below mentioned files in the script directory, in my case the directory C:vSpherescripts:

  • ESXi-configuration.ps1 (the PowerCLI configuration script)
  • pscp.exe (the application used to upload the settings file)
  • settings (the ESXI host configuration file)

Let’s go through the script which requires user interaction.

Figure 1: Start the script, read the information and press the enter key.
Screen Shot 2013-03-21 at 13.24.02
Figure 2: Type the ESXi host “User name” and “Password” to log on to the ESXi host. This is required since i can not put the “User name” and “Password” in the script file.
Screen Shot 2013-03-21 at 13.24.35
Figure 3: Type “n” and press the enter key. This means you will not store the ESXi host key in the Windows registry.
Screen Shot 2013-03-21 at 20.36.51
Figure 4: Type the ESXi host root password and press the enter key. This will establish the SSH session using pscp.exe.
Screen Shot 2013-03-21 at 20.38.01
Figure 5: Press the enter key once the file upload is finished.
Screen Shot 2013-03-21 at 20.38.16
Figure 6: The last thing to do is to shut down the ESXi host SSH service, called TSM-SSH, and this figure shows that the “Running” output is reported as “false” meaning the TSM-SSH service is turned off.
Screen Shot 2013-03-21 at 21.18.05
Below you will find the script and once again, this is a small section of the entire PowerCLI script used to perform the ESXi host initial configuration and it requires user interaction.

#
# PowerCLI script to configure ESXi-servers used by customer X
# Version 1.0
# Magnus Andersson, Real Time Services AB
#
#
# Set the windows size
$pshost = get-host
$pswindow = $pshost.ui.rawui
$newsize = $pswindow.buffersize
$newsize.height = 3000
$newsize.width = 150
$pswindow.buffersize = $newsize
$newsize = $pswindow.windowsize
$newsize.height = 50
$newsize.width = 150
$pswindow.windowsize = $newsize
#____________________________________________________
# Manual configuration section starts here
# Script parameters to be changed per ESXi server installation. Change the expression value X to your parameters.
#
# Directory where the PowerCLI script and the settings file are located
$scriptdir=”X
# vCenter Server FQDN
$vcenter=”X
# ESXi server FQDN
$esxihost=”X
#
Manual configuration section ends here
#_________________________________________________
#
clear
Write-Host “****************************************************************”
Write-Host “** **”
Write-Host “** !!!!Important!!!! **”
Write-Host “** **”
Write-Host “** Before continue running the script, make sure that the **”
Write-Host “** ESXi server is registered in the DNS and that the below **”
Write-Host “** three files are present in the in the directory **”
Write-Host “** $scriptdir **”
Write-Host “** **”
Write-Host “** 1, pscp.exe **”
Write-Host “** 2, settings – this file must contain the below text: **”
Write-Host “** disk.terminateVMonPDLDefault=”true” **”
Write-Host “** 3, plink.exe  **”
Write-Host “** **”
Write-Host “** **”
Write-Host “****************************************************************”
#
Read-Host “Please press Enter if you are ready to proceed, or CTRL-C to abort”
#
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
#
#
Clear
Write-Host “******************************************************”
Write-Host “** **”
Write-Host “** When prompted, login using the below information **”
Write-Host “** User name: = root **”
Write-Host “** Password: = root user password **”
Write-Host “** **”
Write-Host “******************************************************”
#
#
# Connect to the ESXi host
connect-viserver $esxihost
$ErrorActionPreference = “Stop”
#
#
# Start the ESXi host SSH service
Write-Host Starting the $esxihost SSH service
Start-VMHostService -HostService (Get-VMHost -Name $esxihost | Get-VMHostService | Where { $_.Key -eq “TSM-SSH”} )
#
#
# Upload the file settings to the directory /etc/vmware and the file ip to the directory /tmp
#
clear
Write-Host “************************************************************************”
Write-Host “** **”
Write-Host “** Upload the file settings to the ESXi server directory /etc/vmware **”
Write-Host “** **”
Write-Host “** !!!!Important!!!! **”
Write-Host “** **”
Write-Host “** Follow the below instructions: **”
Write-Host “** 1, Press the n key followed by the enter key **”
Write-Host “** 2, Type the new ESXi server root password and press the enter key **”
Write-Host “** 3, Press the enter key once more when the file upload is finished **”
Write-Host “** **”
Write-Host “************************************************************************”
cd $scriptdir
.pscp.exe settings root@”$esxihost”:/etc/vmware
Read-Host
#
#
# Stop the SSH service
Write-Host Stopping the $esxihost SSH service
Stop-VMHostService -HostService (Get-VMHost -Name $esxihost | Get-VMHostService | Where { $_.Key -eq “TSM-SSH”} ) -confirm:$false

If the ESXi host “settings” file contains additional configuration you need to add the additional configuration to the file you upload or use the plink.exe software to echo the configuration string to the “settings” file. This is not covered in this blog post.

3 comments

3 pings

  1. online free stopwatch

    Wow! Finally I got a website from where I be able to in fact take valuable facts concerning my study and knowledge.

  2. sets in chennai|gold jewellery shops chennai|chennai jewellery|temple jewellery chennai|jewellery stores in chennai|jewellery chennai silks|jewellery shops in chennai|chennai jewellery shops|cheap fashion jewellery in chennai|22ct jewellery in chennai|sil

    Howdy, i read your blog from time to time and i own a similar one and i was just wondering if you get a lot of spam feedback? If so how do you reduce it, any plugin or anything you can suggest? I get so much lately it’s driving me crazy so any help is very much appreciated.|

  3. magander3

    Hi,
    i use standard wordpress.org tools and they work great.

    //Magnus

  1. ESXi host advanced settings | vcdx56

    […] file /etc/vmware/settings and i covered one way of implementing the configuration in my blog post, ESXi host disk.terminateVMOnPDLDefault configuration using PowerCLI. The disk.terminateVMOnPDLDefault applies to both vSphere 5.0 and vSphere […]

  2. ESXi host VMkernel.Boot.terminateVMOnPDL configuration using PowerCLI | VCDX56

    […] I have already written a blog post about how you can configure the ESXi host  setting disk.terminateVMOnPDLDefault in vSphere version 5.1. You can find that blog post here. […]

  3. Yet another blog post about vSphere HA and PDL » boche.net – VMware vEvangelist

    […] ESXi host disk.terminateVMOnPDLDefault configuration … […]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">