Get-VMHost Host1 | Get-AdvancedSetting -name ScratchConfig.CurrentScratchLocation | Select value
Let's assume the value returned is /tmp/scratch, as is the case with my new install, then you may want to relocate it. I have created a datastore and mounted it on every new ESX host. There is a good article by Duncan Epping that explains some of his thinking around sizing. You can find it here
I have written a script that will create all the required directories on my scratch volume and it will also set the advanced setting for you. Please note that you will have to reboot your hosts for the change to take effect.
function Set-ScratchDirectory {
<#
.SYNOPSIS
Set a scratch directory for ESX hosts
.DESCRIPTION
Set a scratch directory for ESX hosts on shared storage
.NOTES
Author : Guy Defryn
Version : 1.1
Date : 4/8/2015
.PARAMETER Host
Specify Host to create scratch directory for
.EXAMPLE
Set-ScratchDirectory -Hostname ESX1
Set scratch directory for specified host
.EXAMPLE
Import-CSV .\scratchhosts.csv | Set-ScratchDirectory
Set scratch directory for each host
.LINKS
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1033696
.TODO
Retrieve UUID instead of hard coding
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$True, ValueFromPipelineByPropertyName=$True)][String] $Hostname
)
Begin{
$Datastore = Get-datastore "scratch_vol1"
New-PSDrive -Location $Datastore -Name ds -PSProvider VimDatastore -Root "\" | out-null
Set-Location ds:\
}
Process{
new-item ".locker-$Hostname" -type Directory | out-null
Get-AdvancedSetting -Entity $Hostname -Name Scratchconfig.ConfiguredScratchLocation | Set-AdvancedSetting -Value "/vmfs/volumes/0174119b-06db5bc5/.locker-$hostname"
}
End{
Write-Host "Please reboot your host for changes to take effect" -ForegroundColor Red
}
}
No comments:
Post a Comment