As per VMware KB1033696 the SD card can't be used to store scratch partition. The main purpose of the scratch partition is to store logging files and to provide space for vm-support output.
So, the normal practice is to use shared storage (VMFS/NFS) as a scratch location. The problem is that the configuration of the scratch location is not automated in the existing vSphere. So you have to manually create folder for each of the ESXi host and configure each ESXi host to use that folder.
This can be quite time-consuming and boring tasks when you have to do it for hundred of servers.
This can be quite time-consuming and boring tasks when you have to do it for hundred of servers.
To make things worse Host Profiles do not let you configure scratch location too.
I had some time last week and thought it was a good chance to have fun with PowerCLI and automate the scratch configuration for ESXi hosts.
So here is overview of what the script does:
- Connects to vCenter
- Collects the list of ESXi hosts in the cluster. Very often storage is not shared across multiple compute clusters so I decided to use cluster, not a datacenter, as a configuration target.
- Checks if there is a designated scratch folder for each of the clusters and creates if it doesn't exist
- Checks if the ESXi host configured with scratch location and if it points to the right datastore and folder.
- If ESXi is not configured yet or points to the wrong directory the correct setting will be applied.
- Provides a list of the ESXi servers to be rebooted for the configuration change to take effect
There are a couple of thing you have to do before running the script:
- Identify the datastore to be used to store scratch folders
- In that datastore create a folder where the script will create a scratch folder per each host
The syntax is as following:
.\scratch.ps1 -vCenter vCenter_Name -cluster Cluster_Name -datastore Datastore_Name -folder Folder_Name
for example
.\scratch.ps1 -vCenter lab-vc-01.lab.local -cluster HA -datastore ISO -folder Scratch
* I had to add folder as input parameter because I couldn't make the script land into the correct folder with New-PSdrive commandlet
You can go even further by taking advantage of Windows Task Scheduler to run this script on a daily basis to ensure all servers are consistently configured.
Let me know how it worked for you.
Great script. I tried on 6.5 and found that I had to add -server $vcenter to Scratchconfig lines. I did a replace ScratchLocation" with ScratchLocation" -server $vcenter and all worked well.
ReplyDeletethe section that converts the folder name to UUID is not working in 6.5, but if you simply use the datastore name in the string, and apply that in the syslog setting, the host will automatically convert the UUID
ReplyDeleteNice script!
ReplyDelete