Making a bootable USB ESXi installer in Windows

The steps I perform are as follows:

1. Partition the usb disk

2. Install syslinux

3. Copy ESXi installer files

4. Setup boot config and scripts


When performing step 1, 2 and 3 in Windows, and then step 4 in Linux- all works nice. The VMware installer boots as it is supposed to and installs ESXi.

However, as soon as I do step 4 in Windows, then the VMware installer will run the first boot scripts after the install forever on every boot and reboot in a loop each time. I have no idea what the difference is between copying the configuration files in Windows and doing it in Linux. I tried using dos2unix to convert any newline characters that might have slipped in there, but that did not help. Checked the access rights on one of the configuration files, and it seemed to be the same result when doing the process in both windows and linux.

The process when done in linux is as follows:

#!/bin/bash
echo -e "\e[35m **Starting section where we copy in from ESXi ISO to ESXI USB.. \e[0m"
DISKPARTITION=$1
ESXICUSTOM=$2

if [ -z "$DISKPARTITION" ] || [ -z "$ESXICUSTOM" ]; then
      echo -e "\e[31mError: invalid arguments in $0 \e[0m"
      echo -e "Example usage: $0 sdc [HP | NONE]"
      exit 1
fi

if [ ! -z "$DISKPARTITION" ]; then
      if [ ! -d "/mnt/usb" ]; then
            mkdir -p /mnt/usb
      fi
      if mount | grep -E '(^| )/mnt/usb( |$)' > /dev/null; then
            umount /mnt/usb
      fi
      mount -t vfat /dev/${DISKPARTITION}1 /mnt/usb
      if mount | grep -E '(^| )/mnt/usb( |$)' > /dev/null; then
            echo -e "\e[35m **Usb successfully mounted.. \e[0m"
            if mount | grep /mnt/cdrom > /dev/null; then
                  umount /mnt/cdrom
            fi
            mount /dev/cdrom /mnt/cdrom

            echo -e "\e[35m **Copy done, setting up syslinux.cfg..\e[0m"
            cp /mnt/cdrom/isolinux.cfg /mnt/usb/syslinux.cfg
            sed -i 's|menu.c32|mboot.c32|' /mnt/usb/syslinux.cfg
            cp /mnt/usb/syslinux.cfg /mnt/usb-compilation/esxi/syslinux-last_used.cfg
      fi
      if mount | grep -E '(^| )/mnt/usb( |$)' > /dev/null; then
            umount /mnt/usb
      fi
      if mount | grep /mnt/cdrom > /dev/null; then
            umount /mnt/cdrom
      fi
fi

echo -e "\e[35m **Copying ESXi kickstart files.. \e[0m"

if mount | grep -E '(^| )/mnt/usb( |$)' > /dev/null; then
      umount /mnt/usb
fi
mount -t vfat /dev/${DISKPARTITION}1 /mnt/usb
if [ $ESXICUSTOM = "HP" ]; then
      echo -e "\e[35m       HP setup files are being copied..\e[0m"
      cp /mnt/usb-compilation/esxi/BOOT.CFG /mnt/usb/BOOT.CFG
      cp /mnt/usb-compilation/esxi/KS.CFG /mnt/usb/KS.CFG
else
      echo -e "\e[35m      generic setup files are being copied..\e[0m"
      cp /mnt/usb-compilation/esxi/NON-HP/BOOT.CFG /mnt/usb/BOOT.CFG
      sed "s/='HP iLO'//g" /mnt/usb-compilation/esxi/KS.CFG | sed "s/clearpart --firstdisk=HP --overwritevmfs//g" | sed "s/partition datastore1 --onfirstdisk=HP//g" > /mnt/usb/KS.CFG
fi
if mount | grep -E '(^| )/mnt/usb( |$)' > /dev/null; then
      umount /mnt/usb
fi

chmod 777 /mnt/usb/ovf-00.t00

#Section of the script where ovf-00.t00 is created an placed is omitted:
echo -e "\e[35m **Copying ovf-00.t00 to host.. \e[0m"
cp /mnt/usb/ovf-00.t00 /mnt/usb-compilation/esxi/ovf-00.t00

if mount | grep -E '(^| )/mnt/usb( |$)' > /dev/null; then
      umount /mnt/usb
fi
LVL 2
itniflAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
why not use....

http://www.pendrivelinux.com/tag/boot-multiple-isos-from-flash-drive/

or

https://unetbootin.github.io

and just copy the unmodified iso, to the USB pendrive!
1
itniflAuthor Commented:
I am specifically interested in knowing why the installer breaks when doing the last step in Windows. The USB installers that I have seen so far are for general purpose for the general public, while the system I am doing this for is specialized for our specific system. Thus I have my own installer equivalent to those you mention, however it breaks because of step number four. I don't want to replace it, but figure out what is happening and fix it.
0
gheistCommented:
You can use official image construction tool built into PowerCLI
No need to re-invent the wheel. (and why do you reinstall so often that you need to re-generate the images)

You can PXE-boot diskless ESXi-s too,
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

itniflAuthor Commented:
No, I am afraid not. Powercli does not create scripted usb installs. I know you can customize an image with it by using image builder, but you won't be able to make it boot from usb and execute a scripted install.

A PXE boot can be done as you suggest, and that would allow me to script the install of the ESXi in almost exactly the same way as a scripted usb install. This however is not the correct solution for my case, because a PXE environment is impossible to implement in the given environment. To explain that I will have to explain all the technical aspects of the project, which I am afraid I can not. Also there is no need for it here.

I need to know what makes the difference by doing this process in Windows, and in Linux.
The fourth step in the process includes the following files:
1. syslinux.cfg that configures the syslinux bootloader
2. boot.cfg that is loaded thereafter and instructs weasel (vmware python based installer).
3. KS.cfg that boot.cfg points to. This script accept the eula, sets ip addresses, creates vSwitches, creates standard port groups, so forth and so on.

The last step actually is pretty fantastic and contains many cool tweaks, I might blog the contents of it someday and share with you.

After figuring out that copying in the config files in Windows broke the usb installer, I then tried to copy only one and one in Windows, the rest in Linux, and the try the usb boot installer each time. It didn't fail before I copied in ks.cfg. I then copied it in again via Linux and it worked again. As previously mentioned, I have tried using dos2unix to ensure line endings are unix type. I tried that again and it did not help me. When viewing ks.cfg in notepad++ showing all characters, it looks no different to me in Windows or in Linux except that Encoding is specified as UTF-8 in the file stored in Linux while the one in Windows is not specified with a encoding type of what I can see(via the Encoding menu).
0
gheistCommented:
If you are so inclined on your idea I cannot stop you.
Unless you have computers without network cards I really cannot understand the value of running ESXi USB to datacenter.
0
itniflAuthor Commented:
The question in his thread is not if I could get alternate suggestions for install methods, and even though these suggestions are good intended they drift this  thread away from the solution I am seeking. The more we discuss this and fill the thread with text, the more less likely it is that others who might have a solution will bother to read the thread and answer.

Since you are so convinced that PXE boot is viable, I will explain: There are remote locations where there is no qualified IT staff to administer and set up a proper solution. These remote locations are in the hundreds, and many of them have no internet connection - or the connection is via a poor satellite link, sometimes only from time to other. The ESXi hosts are also most often single, and having a PXE server to boot from would be wasteful just to set up one single ESXi. Previously, IT adminstratos have been sent out to these locations, creating travelling costs that shouldn't even be mentioned. Now today, when this system I set up, a usb disk partitioned with ESXi, installer scripts and ovf images is used. This system is tested beforehand, and standardized. It is handed over to the person who install the system. From it everything is auto deployed on boot and automatically set up. No skills needed. PowerCli image builder does not acquire that either. Booting from CD or DVD is also not possible. The data going along with the whole package is far larger then a CD ad DVD, and unless the installer in that case also is scripted, then it would require at least some minimum knowledge that often is not there. Manually entering ip addresses and setting up a server also introduces the possibility of human errors and mistakes. Tested installers do what they are scipted / programmed to do, every time.
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
why not just put a USB flash drive ready configured in the mail.

and ask the non-IT person, with no brains or skills to insert into the server, and power on!

Very quick, and requires no man hours to develop a solution!

I'm not quite sure, how you will troubleshoot these ESXi servers in the future, with the no brains, non-IT staff, with no skills at the site, with no internet, no WAN link, poor satellite link etc

Are these Servers Licensed with VMware vSphere, and managed by vCenter Server, or just standalone ESXi servers using FREE licenses.?
0
itniflAuthor Commented:
They are standalone with a free license.
Yes, the solution is to give them pre-configured flash drives/usb disks in the mail or otherwise as it is today.
Troubleshooting is a pain in the ass, but at least the system is installed and reinstalled perfectly now.

My problem is, as stated, I create these USB disks in Linux and I have documentation for others to do the same in Linux. I would like to port the whole creation process over to Windows, so that it will be easier for others. But when I copy in ks.cfg to the usb disk using Windows, the ESXi installer will execute the firstboot script forever and reboot every time it is done at every boot in a loop.
0
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Keep the creation process in Linux!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
itniflAuthor Commented:
Giving points to everyone for every answer, for participating.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.