WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud
  • Tanzu
    • Application Modernization
    • Tanzu services
    • Tanzu Community Edition
    • Tanzu Kubernetes Grid
    • vSphere with Tanzu
  • Home Lab
  • Nested Virtualization
  • Apple
You are here: Home / ESXi / Executing Commands During Boot Up In ESXi 5.1

Executing Commands During Boot Up In ESXi 5.1

05.09.2013 by William Lam // 6 Comments

There maybe certain use cases where you need to execute a command or series of commands during the boot up of an ESX(i) host and historically administrators have added commands to the /etc/rc.local which is one of the last scripts to be executed in the boot up process. However, with ESXi 5.1, the location of the file has changed from /etc/rc.local to /etc/rc.local.d/local.sh.

VMware also provides a KB2043564 that describes the locations for the various version of ESX(i):

  • In ESX 3.x/4.x - You would add the command(s) to /etc/rc.d/rc.local
  • In ESXi 4.x/5.0 - You would add the command(s) to /etc/rc.local
  • In ESXi 5.1 - It has changed to /etc/rc.local.d/local.sh

Disclaimer: As mentioned in the VMware KB, though this is supported, it is still not recommended that you edit these files unless directed by VMware support or under special scenarios.

A question that came up recently was about automatically loading the "multiextent" VMkernel module (which is required if you wish to use the 2gbsparse VMDK format, you can find more details in this blog article here) during the boot up of an ESXi 5.1 host as this had to be done manually, even if you had enabled the module. To do so, you just need to edit the /etc/rc.local.d/local.sh and add the following command above the "exit 0".

localcli system module load -m multiextent

Note: The reason I used localcli versus ESXCLI is that hostd may not be completely ready and hence the command may fail during the boot up process. One can also loop and wait for ESXCLI to be ready, but this is another way of performing the operation.

 

More from my site

  • Adding Non-Supported ESXi Builds to VIN (vSphere Infrastructure Navigator)
  • ESXi on palm size iKOOLCORE R1
  • Quick Tip - Automating ESXi local user passwords using SHA512 encrypted hashes
  • ESXi Advanced & Kernel Settings Reference
  • High-end Dell Precision 7770 & 7670 laptops with 128GB memory for ESXi

Categories // ESXi Tags // esx, esxi, local.sh, rc.local

Comments

  1. Jason Logan says

    05/11/2013 at 1:11 pm

    I edited the /etc/rc.local.d/local.sh, I then did a cat on the file and it looked good. It did NOT last after a reboot. The file went back to default.

    What file should I append the cron addition to to make it stick after a reboot?

    Reply
    • William Lam says

      05/11/2013 at 3:49 pm

      The file is automatically backed up by ESXi every 1hr, but if you reboot before then it may not have ran. You can manually back it up by running /sbin/auto-backup.sh

      Reply
  2. Ronald Buder says

    05/12/2013 at 5:09 am

    As I asked already on Twitter a few days ago, any idea as to why this has been changed? Will anything of the likes of /etc/rc.local.d/*.sh be treated as local start up scripts? Is it just someone's personal preference?

    I just checked Linux FHS, its not mentioned there as far as I can tell.

    Just wondering.

    Cheers Ronald (@Str0hhut)

    Reply
    • William Lam says

      05/12/2013 at 3:15 pm

      I don't. My guess is that /etc/rc.local contained some default set of commands and instead of trying to support that which could cause issue, it was decided to introduce a specific file for these custom "boot commands". Also editing /etc/rc.local did not persist in the past, so introducing this new file and making it persist may have been the better option.

      Reply
  3. Rickard Nobel says

    05/13/2013 at 9:58 pm

    Interesting article as always. I would have really thought this would be unsupported by VMware, but seems to be "just" unrecommended.

    Reply

Trackbacks

  1. Running a Command During ESXi Boot to Start a VM. » vHersey - VCDX Two to the Seventh Power (#128) says:
    12/17/2015 at 11:54 am

    […] article from @lamw on Executing Commands During Boot Up in ESXi 5.1 pointed me to one potential […]

    Reply

Thanks for the comment! Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Author

William Lam is a Senior Staff Solution Architect working in the VMware Cloud team within the Cloud Infrastructure Business Group (CIBG) at VMware. He focuses on Cloud Native technologies, Automation, Integration and Operation for the VMware Cloud based Software Defined Datacenters (SDDC)

Connect

  • Email
  • GitHub
  • LinkedIn
  • RSS
  • Twitter
  • Vimeo

Recent

  • Changing the default HTTP(s) Reverse Proxy Ports on ESXi 8.0 03/22/2023
  • Quick Tip - How to download ESXi ISO image for all releases including patch updates? 03/15/2023
  • SSD with multiple NVMe namespaces for VMware Homelab 03/14/2023
  • Is my vSphere Cluster managed by vSphere Lifecycle Manager (vLCM) as a Desired Image or Baseline? 03/10/2023
  • Interesting VMware Homelab Kits for 2023 03/08/2023

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2023