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

Modifying the rc.local or local.sh file in ESX/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 ESX/ESXi during the boot process. This process differs depending on the version of ESX/ESXi used.

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

Environment

VMware vSphere ESXi 6.5
VMware ESX 4.0.x
VMware ESXi 4.1.x Embedded
VMware vSphere ESXi 6.7
VMware ESX 4.1.x
VMware ESXi 4.0.x Installable
VMware vSphere ESXi 5.0
VMware ESX Server 3.5.x
VMware vSphere ESXi 5.1
VMware ESXi 4.1.x Installable
VMware vSphere ESXi 5.5
VMware vSphere ESXi 6.0
VMware ESXi 4.0.x Embedded

Resolution

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

Note: VMware recommends you to not modify these files. Ensure to modify these files only under special use case scenarios or if directed by VMware 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 5.1 / 5.5 / 6.x / 7.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 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

Editing configuration files in VMware ESXi and ESX
Configuring advanced driver module parameters in ESX/ESXi
Configuring advanced options for ESXi/ESX
ESX/ESXi で rc.local または sh.local ファイルを変更して、起動中にコマンドを実行する
在 ESX/ESXi 中,修改 rc.local 或 local.sh 文件以在引导时执行命令
[Internal] Unable to load HDLM PSP after reboot if the PSP changes from VMware to HDLM by esxcli from ESXi.