As you hopefully have read I have been busy over the last weeks with a new project. This project is all about enabling migrations to ESXi. I wrote two articles for the ESXi Chronicles blog of which the first article describes the scripted install procedure and the seconds gives some additional advanced examples of what is possible in these scripts. Based on that article I started receiving some questions from the field and last week I had a conference call with a customer who had issues “injecting” a driver into ESXi during the install. Normally installing a driver is done by using a simple “esxupdate” command and a reboot, but in this case however the situation was slightly different and let me explain the problem first.
This customer implemented a script that would run during the %firstboot section. The name of the section already explains what it is, this section will run after the reboot of the scripted install has been completed. The way this works is that ESXi creates a script in /etc/vmware/init/init.d with the prefix 999. This script will run as the last script during the boot and is generally used to configure the host. After a final reboot this script is automatically deleted and the host is ready to be added to vCenter.
The challenge however that this customer was facing is that it was using a Xsigo network environment. In this scenario a server that would need to be reinstalled would get a temporary network configuration that would only work during the first boot. Meaning that before this %firstboot section would even run the original network configuration would be restored. The problem with that however is that the original network configuration requires the drivers to be installed before it can be used. In other words, after the reboot done by the installer you will not be able to access the network unless you have loaded the drivers. This rules out downloading the drivers during the %firstboot section. Now how do we solve this?
The scripted installation has multiple sections that can contain your commands. The first section is called %post. The ESXi setup guide describes this section as follows:
Executes the specified script after package installation has been completed. If you specify multiple %post sections, they are executed in the order they appear in the installation script.
This means that in the case of this customer we will be able to use this section to download any driver package required with for instance “wget” and that is what I did. I issued the command below during the %post section and rebooted the server.
wget http://192.168.1.100/xsigo.zip
The problem however was that the package wasn’t persisted after a reboot which brought me back to right where I began, without a network after the restart. Than I figured that during the install a local datastore is created and I could use that as persistent storage. So I issued the following command in the %post section of the script:
wget http://192.168.1.100/xsigo.zip -O /vmfs/volumes/datastore1/xsigo.zip
I rebooted the installer and checked after the install if the driver bundle was there or not, and yes it was. The only thing left to do was to install the driver in the %fistboot section. This by itself is a fairly simple task:
esxupdate --bundle=/vmfs/volumes/datastore1/xsigo.zip update
As the host will need to reboot before the drivers are loaded I also added a “reboot” command at the end of to the “%firstboot” section. This ensures the drivers are loaded and the network is accessible.
I guess this demonstrates how easy a solution can be. When I first started looking into this issue and started brainstorming I was making things way too complex. By using the standard capabilities of the scripted install mechanism and a simple “wget” command you can do almost everything you need to do during the install. This also removes the need to fiddle around with injecting drivers straight into the ISO itself.
Go ESXi 🙂
Yuri Semenikhin says
Nice example
“Go ESXi”
after new release of vSphere, no choose to use ESX 😉
so preparing to migrate from ESX to ESXi
Sylvain Huguet says
I had to do the same recently, and I’d like to point that you need to enable maintenance mode (using vim-cmd for exemple) before installing the driver.
Don’t forget to leave the maintenance mode after the driver as been installed!
Duncan Epping says
It seems to work fine without entering maintenance mode here during the install?
Sylvain Huguet says
I had to do this first last year for an ESX scripted install, and then I updated the script for ESXi PXE installation.
I have to admit I didn’t test without entering maintenance mode on ESXi, but for ESX I’m sure you have to… I’ve assumed it would be the same for ESXi, and didn’t bother to test without it.
If you say it’s not needed anymore, then it’s great news!
Duncan Epping says
It worked here, but it does make sense to enter maintenance mode first just to be on the safe side.
Jeff Couch says
Great article Duncan. Exactly what I have been looking for! Thanks.
Duncan Epping says
As one of my colleagues pointed out you can also download patches directly via “esxupdate” however in this case that would not work as esxupdate cannot be used in the %post section of the script as far as I am aware. In the %firstboot section it would look like this:
esxupdate –bundle=http://192.168.1.100/xsigo.zip update
ilya says
i’m under impression “wget/curl” and alike dont exist on esxi 4.1u1
Is script above still valid?