You may face the situation where you need to run custom commands/scripts while ESXi boot. Although it is not so common situation, as most of the settings done in ESXi are persistent during the reboot, there are some cases.
For this purpose there is a file called /etc/rc.local.d/local.sh and you can read more about modifying it in KB2043564.
If you wonder my reason for this, was to increase QLogic network card receive ring size. All of this because of Packet Receive Errors, reported by ESXi, more precisely because of Receive FIFO errors.
By the way, you can figure out more details about Packet Receive Errors by looking at output of the following command:
esxcli network nic stats get -n vmnic0
To configure rx ring size in the ESXi 6.0 and older, you had to use ethtool which is not persistent during the reboot, with command:
ethtool -G vmnic0 rx 4078
So to have your changes persistent across the reboots you have to modify your local.sh, which for 4 NIC server would look like this:
#!/bin/sh # local configuration options # Note: modify at your own risk! If you do/use anything in this # script that is not part of a stable API (relying on files to be in # specific places, specific tools, specific output, etc) there is a # possibility you will end up with a broken system after patching or # upgrading. Changes are not supported unless under direction of # VMware support. ethtool -G vmnic0 rx 4078 ethtool -G vmnic1 rx 4078 ethtool -G vmnic2 rx 4078 ethtool -G vmnic3 rx 4078 exit 0
In the ESXi 6.5 and later you cannot use ethtool anymore, but you can configure ring size by using ESXCLI with command:
esxcli network nic ring current set -n vmnic0 -r 4078
You would assume, you just need to replace the commands in the local.sh, however there is an issue.
ESXCLI commands do not work with /etc/rc.local.d/local.sh
I have contacted VMware support and they advised me to use LOCALCLI instead of ESXCLI
Apparently to have esxcli commands working, you have to have hostd running. However this is not the case during local.sh execution, localcli bypass hostd.
Therefore to have /etc/rc.local.d/local.sh working with ESXCLI commands you have to use localcli instead. The same syntax applies.
So the working script looks like this:
#!/bin/sh # local configuration options # Note: modify at your own risk! If you do/use anything in this # script that is not part of a stable API (relying on files to be in # specific places, specific tools, specific output, etc) there is a # possibility you will end up with a broken system after patching or # upgrading. Changes are not supported unless under direction of # VMware support. # Note: This script will not be run when UEFI secure boot is enabled. localcli network nic ring current set -n vmnic0 -r 4078 localcli network nic ring current set -n vmnic1 -r 4078 localcli network nic ring current set -n vmnic2 -r 4078 localcli network nic ring current set -n vmnic3 -r 4078 exit 0
Latest posts by Dusan Tekeljak (see all)
- VM Latency Sensitivity set to High still fails with no (proper) warning - June 27, 2024
- ESXi 6.7 U1 fixes: APD and VMCP is not triggered even when no paths can service I/Os - November 30, 2018
- Update manager error: hosts could not enter maintenance mode - November 19, 2018
This approach will not work when Secure UEFI is enabled. Is there some other way to achieve this?
Hi Dusan,
Have you test the feature in the ESX8.0?
ring size setting using esxcli is now persistent, for NSX EDP you need to use nsxdp-cli. if you are asking about local.sh, then this will not work with Secure Boot and no other supported method out there.