在 ESX/ESXi 中,修改 rc.local 或 local.sh 文件以在引导时执行命令 (2043564)

时间:2020-03-23 阅读:2621 评论:0 作者:hkear

要在 ESX/ESXi 引导过程中执行命令,需修改 rc.local 或 local.sh 配置文件。

注意:VMware 建议不要修改这些文件。若要修改,请务必在特殊用例场景下或在 VMware 技术支持的指导下修改文件。大多数 ESX/ESXi 配置选项和驱动程序参数在重新引导后仍然保留,并可使用其他方法设置。有关详细信息,请参见 Configuring advanced options for ESX/ESXi (1038578) 和 Configuring advanced driver module parameters in ESX/ESXi (1017588)

ESXi 5.1/5.5/6.x

若在 ESXi 5.1 引导过程中执行命令,须修改 /etc/rc.local.d/ 目录中的 local.sh 文件。
要修改 local.sh 文件,请执行以下操作:
  1. 使用 VI 编辑器打开 local.sh 文件。有关详细信息,请参见 Editing configuration files in VMware ESXi and ESX (1017022)

  2. 在行 exit 0 上面添加要执行的命令。例如:

    #!/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.

    /vmfs/volumes/5e9166f9-994de396-8a2f-5cf3fce5febc/crontab/amount.sh

    /vmfs/volumes/5e9166f9-994de396-8a2f-5cf3fce5febc/crontab/asnapcron.sh

    exit 0

在本例中,在 exit 0 行上面添加了用于禁用流控制自动协商的 ethtool 命令。

注意
  • 在 exit 0 行后面添加的命令不会执行。

  • 可以在 exit 0 前面添加其他命令。

  • 命令按列出的顺序执行。

  • 通常,不必修改 local.sh 文件的权限。在 ESXi 5.1 中,默认情况下,root 用户对此文件具有读写权限。



本文链接: https://dkicloud.com/?id=15 转载请注明出处!

评论区 交流一下吧!

共有0条评论来说两句吧...

欢迎 发表评论: