Modifying the rc.local or local.sh file in VMware vSphere ESXi to execute commands while booting
search cancel

Modifying the rc.local or local.sh file in VMware vSphere ESXi to execute commands while booting

book

Article ID: 324525

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

This article provides information on how to modify the rc.local or local.sh files to execute commands in VMware vSphere ESXi during the boot process. This process differs depending on the version of ESXi used.

Note: due to the security hardening of the secure boot (UEFI) these options are not available.

Environment

  • VMware vSphere ESXi 8.0
  • VMware vSphere ESXi 7.0
  • VMware vSphere ESXi 6.7
  • VMware vSphere ESXi 6.5

Resolution

To execute a command during the VMware vSphere ESXi boot process, either the rc.local or local.sh configuration file can be modified.

Note: Broadcom recommends you to not modify these files. Ensure to modify these files only under special use case scenarios or if directed by Broadcom Technical Support. Most ESX/ESXi configuration options and driver parameters persist across reboots and are set using other methods. For more information, see Configuring advanced options for ESX/ESXi (1038578) and Configuring advanced driver module parameters in ESX/ESXi (1017588).
 

ESXi 6.x / 7.x / 8.x

To execute a command during the ESXi boot process, modify the local.sh file located at the /etc/rc.local.d/ directory.
 
To modify the local.sh file:
  1. Open the local.sh file using the vi editor. For more information, see Editing configuration files in VMware ESXi and ESX (1017022).
  2. Add the command to be executed above the line exit 0. For example:
    #!/bin/sh
    
    #!/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.
    
    esxcli network nic pauseParams set -n vmnic5 -a true
    exit 0
In the above example, the user is setting vmnic5 to autonegotiate Flow Control.

Notes:
  • Commands added after the exit 0 line are not executed.
  • You can add additional commands before exit 0.
  • The commands are executed in the order listed.
  • Usually, it is not necessary to modify the permissions of the local.sh file. In ESXi 5.1+, by default, the root user has read and write permissions on this file.
  • The script will not be run when UEFI secure boot is enabled.

Additional Information