I’ve recently gone through an exercise to configure the scratch partition on a number of boot from san hosts, which got me thinking about partition layout in general on ESXi hosts.
When you install ESXi you do not get the opportunity to modify the partition layout, its automatically set by the installation process.
If you’re curious you can view the partition layout on ESXi 5 hosts using partedUtil (for earlier versions of ESXi, fdisk is used instead). First we need to identify the disk that we will examine further with partedUtil. We can do this by listing the contents of /dev/disks:
The disk we are looking for is the one with multiple partitions, easily seen in blue in the above screen shot.
Now we have the disk, we can run partedUtil to examine the partition table on the disk:
Disregarding the 11GB VMFS partition and the 4GB scratch partition in the screenshot above, you can see that an installation of ESXi can take up as little as 1 GB.
So what are these partitions?
The first and smallest partition is purely used for booting the system and locating the hypervisor image which is located on one of the next two partitions.
The system/hypervisor image is found on the first 250 MB partition. The image is called s.v00 (124MB compressed) and is decompressed during boot.
The actual system image is located on the first 250 MB partition, formatted with plain old FAT. The image itself, s.v00, is a 124 MB compressed file, which is decompressed on boot and contains the hypervisor operating system.
The next partition is also used for the system image. This is a copy of the last working image. Empty on first install, when the server is upgraded, the previous system image is copied to this partition. It can be accessed during the boot process when you press CTRL-R.
The next partition is the 110 MB core dump partition, which stores the dump file if your host has the dreaded PSOD.
The 286 MB partition is where the ISO files for the VMware Tools are found.
In minimal installs the above partitions may be all that you see, however as seen in our screenshot above, there are a couple of others that you may see.
If you install ESXi on local storage with more than 4 or 5 GB free space then a Scratch partition will be automatically created. Various log files amongst other things will be redirected to this partition. If you didn’t have the necessary free space for this partition, then those files would be stored on a RAM drive, and would be lost in the event of a power failure. More about this shortly…
The final partition on the host in this example is the VMFS partition which was created during install, using available unallocated space. On this host this partition is 11GB.
So, with the partitions coverered, back to my original issue – the scratch partition. With an installation on small disks, USB or boot from SAN, you will find that a dedicated scratch partition won’t be created and will be served out of a ramdisk instead.
ESXi selects one of these scratch locations during startup in order of preference:
- The location configured in the /etc/vmware/locker.conf configuration file, set by the ScratchConfig.ConfiguredScratchLocation configuration option
- A Fat16 filesystem of at least 4 GB on the Local Boot device.
- A Fat16 filesystem of at least 4 GB on a Local device.
- A VMFS Datastore on a Local device, in a .locker/ directory.
- A ramdisk at /tmp/scratch/
It should be said that the scratch partition is necessary for several functions on the ESXi host – you can get an idea of what you will find on there by seeing the symbolic links that are created to redirect files and directories to scratch. For example, /var/log -> /scratch/var/log/
For hosts where a scratch partition hasn’t been automatically created, the following steps can be followed:
- Select the ESXi host in the inventory.
- Click the Configuration tab.
- Click Storage.
- Right-click a datastore and select Browse.
- Create a uniquely-named directory for this ESXi host (eg, .locker-ESXHostname)
- Close the Datastore Browser.
- Click Advanced Settings under Software.
- Select the ScratchConfig section.
- Change the ScratchConfig.ConfiguredScrathLocation configuration option, specifying the full path to the directory (this needs to be unique for every ESXi host). For example:/vmfs/volumes/DatastoreName/.locker-ESXHostname
- Enable the ScratchConfig.ConfiguredSwapState (recommended as this is a requirement for HA: see KB 1004177)
- Put the ESXi host in maintenance mode and reboot for the configuration change to take effect.