This article provides steps to create a persistent scratch location for ESXi.
VMware recommends that ESXi has a persistent scratch location available for storing temporary data including logs, diagnostic information, and system swap. (However, this is not a requirement) Persistent scratch space may be provisioned on a FAT 16, VMFS, or NFS partition accessible by the ESXi host.
Note: Pointing the scratch location to a partition on an SD card or USB stick is not recommended. These devices only have a limited amount of read/write cycles.
Note: Scratch space is configured automatically during installation or first boot of an ESXi host, and is not required to be manually configured. ESXi Installable creates a 4 GB Fat16 partition on the target device during installation if there is sufficient space, and if the device is considered Local.
Only ESXi systems with swap enabled can be added to an HA cluster. For more information, see ESXi hosts without swap enabled cannot be added to a VMware High Availability Cluster .
Note: For ESXi versions prior to 7.0, scratch space is configured automatically during installation or first boot of an ESXi host, and is not required to be manually configured. ESXi Installer creates a 4 GB Fat16 partition on the target device during installation if there is sufficient space, and if the device is considered Local.
From ESXi 7.0, a VMFS-L based ESX-OSData volume (where logs, coredumps and configuration are stored) replaces the traditional scratch partition. During upgrade, the configured scratch partition is converted to ESX-OSData. The settings described in this article are still applicable for cases where you want to point the scratch path to another location.
Symptoms:
esxcli software vib list
command, you see error similar to:esxcli software
or esxupdate
do not work.General System Error
/var/log/
file or are not being updated.Note: It is not supported to configure the scratch location on a vSAN datastore.
Caution: Do not share a scratch locker directory among multiple ESXi hosts.
Scratch space can be manually configured for an ESXi host using the vSphere Client, PowerCLI, Tech Support Mode, or during scripted installation. Select the method appropriate to your environment. Regardless of the method selected, the configuration is written to the /etc/vmware/locker.conf configuration file for use during the next boot.
Changing the configured scratch location requires a reboot of the ESXi host for the changes to take effect. Use vMotion to migrate or power off all virtual machines on the ESXi host prior to making the change.
The configured scratch location must point to a directory on a filesystem accessible to the ESXi host, such as a VMFS volume. The location may be a directory on a shared or remote disk as long as the ESXi host is allocated its own separate directory.
Method to Configure a Persistent Scratch Location:
It may be necessary to do a reboot of the ESXi host before completing these procedures.
NOTE: To find datastore UUID go to the datastore--> Summary-->url
Warning: Do not set scratch to the root of a directory. Refere this article Upgrading host from vSphere ESXi 6.x to 7.x datastores may become overwritten if incorrect scratch location is set, prior, or after upgrade
Before proceeding, ensure that /tmp/scratch exists. If it does not exist, use the command mkdir /tmp/scratch
to create it.
connect-viserver esx_hostname_or_IP
Get-Datastore
New-PSDrive -Name "mounteddatastore" -Root \ -PSProvider VimDatastore -Datastore (Get-Datastore "DatastoreName")
Set-Location mounteddatastore:\
New-Item "DirectoryName" -ItemType directory
New-Item ".locker-ESXHostname" -ItemType directory
Get-VMhost | Get-AdvancedSetting -Name "ScratchConfig.ConfiguredScratchLocation"
Get-VMhost | Get-AdvancedSetting -Name "ScratchConfig.ConfiguredScratchLocation" | Set-AdvancedSetting -Value "/vmfs/volumes/DatastoreName/DirectoryName"
Get-VMhost | Get-AdvancedSetting -Name "ScratchConfig.ConfiguredScratchLocation" | Set-AdvancedSetting -Value "/vmfs/volumes/Datastore1/.locker-ESXHostname"
ls /vmfs/volumes
mkdir /vmfs/volumes/DatastoreName/DirectoryName
mkdir /vmfs/volumes/Datastore1/.locker-ESXHostname
vim-cmd hostsvc/advopt/view ScratchConfig.ConfiguredScratchLocation
(vim.option.OptionValue) [
(vim.option.OptionValue) {
dynamicType = unset,
key = "ScratchConfig.ConfiguredScratchLocation",
value = "/path/to/location",
}
}
vim-cmd hostsvc/advopt/update ScratchConfig.ConfiguredScratchLocation string /vmfs/volumes/DatastoreName/DirectoryName
/bin/vim-cmd hostsvc/advopt/update ScratchConfig.ConfiguredScratchLocation string /vmfs/volumes/Datastore1/.locker-ESXHostname
You can configure persistent scratch space for ESXi during kickstart installation by adding commands to your kickstart scripts which create the directory and change the configuration option.
Append these commands to your custom kickstart script:
# Generate a new scratch directory for this host on a Datastore:scratchdirectory=/vmfs/volumes/DatastoreName/.locker-$(hostname 2> /dev/null)-$(esxcfg-info -b 2> /dev/null)
# Create the scratch directory:mkdir -p $scratchdirectory
# Change the advanced configuration option:vim-cmd hostsvc/advopt/update ScratchConfig.ConfiguredScratchLocation string $scratchdirectory
Note: The configured scratch location is activated during startup of the ESXi host. A reboot is required after performing the preceding commands.
The alert/warning about persistent scratch location not set can be seen in VMware Skyline Health: VMware Skyline Health Diagnostics for vSphere - FAQ
ScratchConfig.ConfiguredScratchLocation" vs "Syslog.global.logDir"
1. Syslog.global.logDir is the setting of the log path, by default it points to "/scratch/log", but basically you can set it to anywhere.
2. "/scratch" is the scratch location defined by ScratchConfig.ConfiguredScratchLocation, in this path it could or could not contain logs depends on your Syslog.global.logDir setting. If you change Syslog.global.logDir to somewhere other than "/scratch/log", then logs won't go to the location defined by ScratchConfig.ConfiguredScratchLocation
If your "Syslog.global.logDir" is pointing to /scratch/log, then you just need to change "ScratchConfig.ConfiguredScratchLocation" to a persistent location.
Otherwise, change "Syslog.global.logDir" to a persistent location, it does not matter what "ScratchConfig.ConfiguredScratchLocation" is.
"ScratchConfig.ConfiguredScratchLocation" contains other things than merely logs, whether or not set up two different location would depend on:
1. If you want log to be in persistent storage while other things in ramdisk, then you can set up two different location as:
Persistent storage for Syslog.global.logDir
Ramdisk for "ScratchConfig.ConfiguredScratchLocation"
2. Otherwise, keep Syslog.global.logDir as default (/scratch/log), change ScratchConfig.ConfiguredScratchLocation to a persistent storage.
For more information on the scratch partition, see:
If the host is running for more than 24 hours, this setting may not stay persistent after performing the preceding steps. In this case, perform these steps:
ScratchConfig.ConfiguredScratchLocation
configuration option and set it to the full path of the directory./vmfs/volumes/DatastoreName/.locker-ESXHostname
ScratchConfig.ConfiguredScratchLocation
field contains the scratch setting that you configured in step 6. If it does, reboot the host.
For more information on determining whether a disk device, see Identifying disks when working with VMware ESXi, and review the Is Local
flag in the output of the esxcfg-scsidevs -l
command:
ESXi selects one of these scratch locations during startup in this order of preference:
/etc/vmware/locker.conf
configuration file, set by the ScratchConfig.ConfiguredScratchLocation
configuration option, as in this article..locker/
directory./tmp/scratch/.
These are two examples where scratch space may not be automatically defined on persistent storage. In each case, the temporary scratch location is configured on a ramdisk:
To remove the configuration or restore to ramdisk:
1. Place the host into MM and change only the ScratchConfig.ConfiguredScratchLocation in the specific host Advanced Settings to /tmp
2.
Save and reboot the host.
3. Upon reboot you will see the ScratchConfig.CurrentScratchLocation updated to /tmp
.
4. If the change does not reflect please reboot the host 1 additional time. You will then be able to remove the VMFS datastore.
Related Links: