WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • 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

  • How to install all versions of ESX and ESXi in VM?
  • Adding Non-Supported ESXi Builds to VIN (vSphere Infrastructure Navigator)
  • Programmatically accessing the Broadcom Compatibility Guide (BCG)
  • Supported chipsets for the USB Network Native Driver for ESXi Fling
  • Quick Tip - Auditing ESXi boot firmware type

Categories // ESXi Tags // ESX, ESXi, local.sh, rc.local

Comments

  1. *protectedJason 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
    • *protectedWilliam 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. *protectedRonald 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
    • *protectedWilliam 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. *protectedRickard 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

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

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 © 2025