Custom kickstart of ESXi

Steps to create a custom ESXi installation:

Extract the media from the CDROM

# mount -o ro,loop -t iso9660 VMware-VMvisor-Installer-4.1.0-260247.x86_64.iso /mnt
# cp -rp /mnt /extract/
# umount /mnt
# cd /extract

Edit the isolinux.cfg file. Eg:

default menu.c32
menu title VMware VMvisor Boot Menu
timeout 80

label ESXi Installer
menu label ^ESXi Installer
kernel mboot.c32
append vmkboot.gz --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.vgz --- install.vgz

label Kickstart debug
menu label ^ESXi Installer (default KS)
kernel mboot.c32
append vmkboot.gz ks=file:///etc/vmware/weasel/ks.cfg --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.vgz --- install.vgz

label ESXi Kickstart
menu label ^ESXi Kickstart from CD
kernel mboot.c32
append vmkboot.gz ks=cdrom:/CUSTOM.CFG --- vmkernel.gz --- sys.vgz --- cim.vgz --- ienviron.vgz --- install.vgz

label ^Boot from local disk
menu label ^Boot from local disk
localboot 0x80

Create a file called custom.cfg which will be the custom jumpstart file.

NB. Because ESXi mounts this as a ISO9660 filesystem, and not Rock Ridge, files will be accessible as UPPER CASE.

Then recreate the CD:

# mkisofs -o /tmp/custom.iso -b isolinux.bin \
  -no-emul-boot -boot-load-size 4 -boot-info-table -c boot.cat -r .

Booting this CD will show two more options. The first additional option will kickstart with the default options, and the second will use a file on the CDROM for installation.

After installation, the following screen is displayed:

The default file is located in /etc/vmware/weasel/ks.cfg, and by manually specifying it, a log file will be created, which is viewable after booting in /var/log/esxi_install.log

Eg /etc/vmware/weasel/ks.cfg has this contents:

vmaccepteula
rootpw letmein
autopart --firstdisk --overwritevmfs
install cdrom
network --bootproto=dhcp --device=vmnic0

%post --unsupported --interpreter=python --ignorefailure=true
import time
stampFile = open('/finished.stamp', mode='w')
stampFile.write( time.asctime() )

And it will generate the following output file (which can be used to verify keywords etc.) :

/var/log/esxi_install.log :

2010-09-29 21:57:22,924 INFO Got boot cmdline “vmkboot.gz ks=file:///etc/vmware/weasel/ks.cfg ”
2010-09-29 21:57:22,941 INFO Weasel skipped boot command line token (vmkboot.gz)
2010-09-29 21:57:22,953 DEBUG command line options: [(‘-s’, ‘file:///etc/vmware/weasel/ks.cfg’)]
2010-09-29 21:57:22,954 WARNING User has not chosen a Weasel run mode.
2010-09-29 21:57:22,954 INFO Weasel run mode defaulting to Scripted.
2010-09-29 21:57:23,262 DEBUG Querying disks
2010-09-29 21:57:23,265 DEBUG  lun — mpx.vmhba1:C0:T0:L0
2010-09-29 21:57:23,265 DEBUG   Trying /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0
2010-09-29 21:57:24,254 DEBUG Unknown parted file system type (‘unknown’) for partition: /vmfs/devices/disks/mpx.vmhba1:C0:T0:L02
2010-09-29 21:57:24,254 INFO Discovered lun — mpx.vmhba1:C0:T0:L0 (console /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0) — VMware,  VMware Virtual S (40960 MB, mptspi)
2010-09-29 21:57:24,256 INFO Using ScriptedInstall file: file:///etc/vmware/weasel/ks.cfg
2010-09-29 21:57:24,259 INFO Using ScriptedInstall file: file:///etc/vmware/weasel/ks.cfg
2010-09-29 21:57:24,260 DEBUG command: install found
2010-09-29 21:57:24,261 DEBUG Branch Created: {‘cdrom’: None}
2010-09-29 21:57:24,261 DEBUG Validating argument: –dir
2010-09-29 21:57:24,261 DEBUG Validating argument: –server
2010-09-29 21:57:24,262 DEBUG Validating argument: cdrom
2010-09-29 21:57:24,262 DEBUG argument is optional
2010-09-29 21:57:24,262 DEBUG Validating argument: nfs
2010-09-29 21:57:24,262 DEBUG Validating argument: url
2010-09-29 21:57:24,263 DEBUG Validating argument: usb
2010-09-29 21:57:24,263 DEBUG doInstall branch: {‘cdrom’: None}
2010-09-29 21:57:24,263 INFO CD-ROM install specified. CD-ROM is the default.
2010-09-29 21:57:24,367 INFO Loaded iso9660 module
2010-09-29 21:57:24,367 DEBUG executing: /sbin/vsish -e set /vmkModules/iso9660/mount mpx.vmhba32:C0:T0:L0
2010-09-29 21:57:24,671 DEBUG command exited with status 0
2010-09-29 21:57:24,672 INFO
2010-09-29 21:57:24,677 INFO setting media location
2010-09-29 21:57:24,679 INFO Using ScriptedInstall file: file:///etc/vmware/weasel/ks.cfg
2010-09-29 21:57:24,680 DEBUG command: vmaccepteula found
2010-09-29 21:57:24,680 DEBUG Branch Created: {}
2010-09-29 21:57:24,681 DEBUG command: rootpw found
2010-09-29 21:57:24,682 DEBUG Validating argument: –iscrypted
2010-09-29 21:57:24,683 DEBUG command: autopart found
2010-09-29 21:57:24,684 DEBUG Branch Created: {‘–firstdisk’: ‘local,remote’, ‘–overwritevmfs’: None}
2010-09-29 21:57:24,684 DEBUG Validating argument: –disk
2010-09-29 21:57:24,684 DEBUG Validating argument: –drive
2010-09-29 21:57:24,685 DEBUG Validating argument: –firstdisk
2010-09-29 21:57:24,685 DEBUG argument is optional
2010-09-29 21:57:24,685 DEBUG Validating argument: –overwritevmfs
2010-09-29 21:57:24,686 DEBUG argument is optional
2010-09-29 21:57:24,686 DEBUG checking disk for install eligibility — mpx.vmhba1:C0:T0:L0 (console /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0) — VMware,  VMware Virtual S (40960 MB, mptspi)
2010-09-29 21:57:24,686 DEBUG   disk is eligible
2010-09-29 21:57:24,687 DEBUG   BEGIN firstdisk order
2010-09-29 21:57:24,687 DEBUG     mpx.vmhba1:C0:T0:L0 (console /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0) — VMware,  VMware Virtual S (40960 MB, mptspi)
2010-09-29 21:57:24,687 DEBUG   END firstdisk order
2010-09-29 21:57:24,688 INFO autopart –firstdisk == mpx.vmhba1:C0:T0:L0 (console /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0) — VMware,  VMware Virtual S (40960 MB, mptspi)
2010-09-29 21:57:24,688 DEBUG command: network found
2010-09-29 21:57:24,689 DEBUG Branch Created: {‘–device’: ‘vmnic0’, ‘–bootproto’: ‘dhcp’}
2010-09-29 21:57:24,690 DEBUG Validating argument: –addvmportgroup
2010-09-29 21:57:24,690 DEBUG Validating argument: –bootproto
2010-09-29 21:57:24,690 DEBUG argument is optional
2010-09-29 21:57:24,690 DEBUG Validating argument: –device
2010-09-29 21:57:24,691 DEBUG argument is optional
2010-09-29 21:57:24,691 DEBUG Validating argument: –gateway
2010-09-29 21:57:24,691 DEBUG Validating argument: –hostname
2010-09-29 21:57:24,692 DEBUG Validating argument: –ip
2010-09-29 21:57:24,692 DEBUG Validating argument: –nameserver
2010-09-29 21:57:24,692 DEBUG Validating argument: –netmask
2010-09-29 21:57:24,693 DEBUG Validating argument: –nodns
2010-09-29 21:57:24,693 DEBUG Validating argument: –vlanid
2010-09-29 21:57:24,700 DEBUG command: %post found
2010-09-29 21:57:24,703 DEBUG Branch Created: {‘–ignorefailure’: ‘true’, ‘–interpreter’: ‘python’, ‘–unsupported’: None}
2010-09-29 21:57:24,703 DEBUG Validating argument: –ignorefailure
2010-09-29 21:57:24,704 DEBUG argument is optional
2010-09-29 21:57:24,704 DEBUG Validating argument: –interpreter
2010-09-29 21:57:24,704 DEBUG argument is optional
2010-09-29 21:57:24,705 DEBUG Validating argument: –timeout
2010-09-29 21:57:24,705 DEBUG Validating argument: –unsupported
2010-09-29 21:57:24,706 DEBUG section-contents: “import time\nstampFile = open(‘/finished.stamp’, mode=’w’)\nstampFile.write( time.asctime() )\n”
2010-09-29 21:57:24,707 DEBUG scripts: {‘realPath’: None, ‘script’: “import time\nstampFile = open(‘/finished.stamp’, mode=’w’)\nstampFile.write( time.asctime() )\n”, ‘relativePath’: ‘tmp/ks-script’, ‘interp’: ‘/usr/bin/python’, ‘inChroot’: False, ‘timeoutInSecs’: 0, ‘ignoreFailure’: True}
2010-09-29 21:57:24,707 DEBUG Validating command: %firstboot
2010-09-29 21:57:24,708 DEBUG Validating command: %include
2010-09-29 21:57:24,708 DEBUG Validating command: %packages
2010-09-29 21:57:24,708 DEBUG Validating command: %post
2010-09-29 21:57:24,709 DEBUG command is optional
2010-09-29 21:57:24,709 DEBUG Validating command: %pre
2010-09-29 21:57:24,709 DEBUG Validating command: %vmlicense_text
2010-09-29 21:57:24,710 DEBUG Validating command: accepteula
2010-09-29 21:57:24,710 DEBUG Validating command: announcehost
2010-09-29 21:57:24,710 DEBUG Validating command: auth
2010-09-29 21:57:24,710 DEBUG Validating command: authconfig
2010-09-29 21:57:24,711 DEBUG Validating command: autopart
2010-09-29 21:57:24,711 DEBUG Requires: install
2010-09-29 21:57:24,711 DEBUG Validating command: autostep
2010-09-29 21:57:24,712 DEBUG Validating command: bootloader
2010-09-29 21:57:24,712 DEBUG Validating command: clearpart
2010-09-29 21:57:24,712 DEBUG Validating command: cmdline
2010-09-29 21:57:24,713 DEBUG Validating command: device
2010-09-29 21:57:24,713 DEBUG Validating command: deviceprobe
2010-09-29 21:57:24,713 DEBUG Validating command: dryrun
2010-09-29 21:57:24,714 DEBUG Validating command: esxlocation
2010-09-29 21:57:24,714 DEBUG Validating command: firewall
2010-09-29 21:57:24,714 DEBUG Validating command: firewallport
2010-09-29 21:57:24,715 DEBUG Validating command: firstboot
2010-09-29 21:57:24,715 DEBUG Validating command: harddrive
2010-09-29 21:57:24,715 DEBUG Validating command: ignoredisk
2010-09-29 21:57:24,715 DEBUG Validating command: include
2010-09-29 21:57:24,716 DEBUG Validating command: install
2010-09-29 21:57:24,716 DEBUG command is optional
2010-09-29 21:57:24,716 DEBUG Validating command: interactive
2010-09-29 21:57:24,717 DEBUG Validating command: keyboard
2010-09-29 21:57:24,717 DEBUG Validating command: lang
2010-09-29 21:57:24,717 DEBUG Validating command: langsupport
2010-09-29 21:57:24,718 DEBUG Validating command: lilo
2010-09-29 21:57:24,718 DEBUG Validating command: lilocheck
2010-09-29 21:57:24,718 DEBUG Validating command: logvol
2010-09-29 21:57:24,719 DEBUG Validating command: mouse
2010-09-29 21:57:24,719 DEBUG Validating command: network
2010-09-29 21:57:24,719 DEBUG command is optional
2010-09-29 21:57:24,720 DEBUG Validating command: paranoid
2010-09-29 21:57:24,720 DEBUG Validating command: part
2010-09-29 21:57:24,720 DEBUG Validating command: partition
2010-09-29 21:57:24,720 DEBUG Validating command: raid
2010-09-29 21:57:24,721 DEBUG Validating command: reboot
2010-09-29 21:57:24,721 DEBUG Validating command: rootpw
2010-09-29 21:57:24,721 DEBUG Validating command: serialnum
2010-09-29 21:57:24,722 DEBUG Validating command: skipx
2010-09-29 21:57:24,722 DEBUG Validating command: text
2010-09-29 21:57:24,722 DEBUG Validating command: timezone
2010-09-29 21:57:24,723 DEBUG Validating command: upgrade
2010-09-29 21:57:24,723 DEBUG Validating command: virtualdisk
2010-09-29 21:57:24,723 DEBUG Validating command: vmaccepteula
2010-09-29 21:57:24,724 DEBUG Validating command: vmlicense
2010-09-29 21:57:24,724 DEBUG Validating command: vmserialnum
2010-09-29 21:57:24,724 DEBUG Validating command: vnc
2010-09-29 21:57:24,725 DEBUG Validating command: volgroup
2010-09-29 21:57:24,725 DEBUG Validating command: xconfig
2010-09-29 21:57:24,725 DEBUG Validating command: xdisplay
2010-09-29 21:57:24,725 DEBUG Validating command: zerombr
2010-09-29 21:57:24,727 INFO  * STEP GETBIN
2010-09-29 21:57:24,728 WARNING Running task restarting (GETBIN)
2010-09-29 21:57:24,729 WARNING Attempted to load iso9660 module twice
2010-09-29 21:57:24,730 DEBUG executing: /sbin/vsish -e set /vmkModules/iso9660/mount mpx.vmhba32:C0:T0:L0
2010-09-29 21:57:24,905 DEBUG command exited with status 0
2010-09-29 21:57:24,905 INFO
2010-09-29 21:57:24,937 WARNING A task finished that has not started
2010-09-29 21:57:24,939 INFO  * STEP Clearpart
2010-09-29 21:57:24,940 INFO  * STEP Checkpart
2010-09-29 21:57:24,942 INFO  * STEP WRITEBIN
2010-09-29 21:57:24,942 WARNING Running task restarting (WRITEBIN)
2010-09-29 21:57:25,033 WARNING Attempted to load iso9660 module twice
2010-09-29 21:57:25,033 DEBUG executing: /sbin/vsish -e set /vmkModules/iso9660/mount mpx.vmhba32:C0:T0:L0
2010-09-29 21:57:25,168 DEBUG command exited with status 0
2010-09-29 21:57:25,169 INFO
2010-09-29 21:57:25,174 INFO Writing image to disk <vmkctl.DiskLun; proxy of <Swig Object of type ‘HostCtl::Storage::DiskLun *’ at 0x976c718> > at /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0
2010-09-29 21:57:25,180 INFO calculating md5 sum of source file
2010-09-29 21:59:51,231 INFO Rescanning…
2010-09-29 21:59:51,316 WARNING Attempted to load iso9660 module twice
2010-09-29 21:59:51,316 DEBUG executing: /sbin/vsish -e set /vmkModules/iso9660/mount mpx.vmhba32:C0:T0:L0
2010-09-29 21:59:51,541 DEBUG command exited with status 0
2010-09-29 21:59:51,543 INFO
2010-09-29 21:59:51,552 INFO found bootbank partition 5
2010-09-29 21:59:51,556 INFO found bootbank partition 6
2010-09-29 21:59:51,789 DEBUG Executing: fdisk -u /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0 < /tmp/fdisk_script
2010-09-29 21:59:52,000 INFO
The number of cylinders for this disk is set to 40960.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): Command action
l   logical (5 or over)
p   primary partition (1-4)
Partition number (1-4): First sector (1843200-83886079, default 1843200): Last sector or +size or +sizeM or +sizeK (1843200-83886079, default 83886079):
Command (m for help): Partition number (1-8): Hex code (type L to list codes): Changed system type of partition 2 to 6 (FAT16)

Command (m for help): Command action
l   logical (5 or over)
p   primary partition (1-4)
Selected partition 3
First sector (10229760-83886079, default 10229760): Last sector or +size or +sizeM or +sizeK (10229760-83886079, default 83886079): Using default value 83886079

Command (m for help): Partition number (1-8): Hex code (type L to list codes): Changed system type of partition 3 to fb (VMFS)

Command (m for help): The partition table has been altered!

Calling ioctl() to re-read partition table

2010-09-29 21:59:52,097 DEBUG   using auto-generated vmfs volume name — datastore1
2010-09-29 21:59:52,098 DEBUG executing: /usr/sbin/vmkfstools -C vmfs3 -b 1m -S datastore1 /vmfs/devices/disks/mpx.vmhba1:C0:T0:L0:3
2010-09-29 22:00:10,103 DEBUG command exited with status 0
2010-09-29 22:00:10,104 INFO Checking if remote hosts are using this device as a valid file system. This may take a few seconds…
Creating vmfs3 file system on “mpx.vmhba1:C0:T0:L0:3” with blockSize 1048576 and volume label “datastore1”.
Successfully created new volume: 4ca3b6e9-fd9ada85-a674-000c29e3db40

2010-09-29 22:00:10,105 WARNING A task finished that has not started
2010-09-29 22:00:10,105 INFO  * STEP ROOTPASS
2010-09-29 22:00:10,107 INFO  * STEP KEYBOARD
2010-09-29 22:00:10,108 INFO User has not chosen a keymap. Doing nothing.
2010-09-29 22:00:10,109 INFO  * STEP SERIAL
2010-09-29 22:00:10,110 INFO no license key entered, defaulting to evaluation mode
2010-09-29 22:00:10,110 INFO  * STEP Networking
2010-09-29 22:00:10,278 INFO Connecting vmnic0 via DHCP
2010-09-29 22:00:15,608 INFO Setting the host-wide networking options
2010-09-29 22:00:15,609 DEBUG using choices: {‘nameserver2’: None, ‘nameserver1’: None, ‘hostname’: None, ‘gateway’: None}
2010-09-29 22:00:15,649 INFO Setting hostname to localhost
2010-09-29 22:00:15,673 INFO Removing nameserver 192.168.108.2
2010-09-29 22:00:15,674 WARNING A task finished that has not started
2010-09-29 22:00:15,674 INFO  * STEP Scripts
2010-09-29 22:00:15,739 DEBUG executing: /sbin/vmkfstools -V
2010-09-29 22:00:15,968 DEBUG command exited with status 0
2010-09-29 22:00:15,969 INFO
2010-09-29 22:00:15,971 INFO Reading the boot.cfg file
2010-09-29 22:00:15,990 INFO Writing to the boot.cfg file
2010-09-29 22:00:16,038 INFO Staging the first-boot scripts in /tmp
2010-09-29 22:00:16,039 INFO Writing 61 chars to /tmp/etc/vmware/init/init.d/999.firstboot_remove
2010-09-29 22:00:16,040 INFO Writing 596 chars to /tmp/var/lib/firstboot/999.firstboot_remove.py
2010-09-29 22:00:16,042 INFO Writing 316 chars to /tmp/var/lib/firstboot/999.firstboot_password.py
2010-09-29 22:00:16,044 INFO Writing 63 chars to /tmp/etc/vmware/init/init.d/999.firstboot_password
2010-09-29 22:00:16,046 INFO Copying /etc/resolv.conf to /tmp/etc/resolv.conf
2010-09-29 22:00:16,047 DEBUG executing: /bin/busybox chmod +t /tmp/etc/resolv.conf
2010-09-29 22:00:16,155 DEBUG command exited with status 0
2010-09-29 22:00:16,156 INFO
2010-09-29 22:00:16,157 INFO Copying /etc/hosts to /tmp/etc/hosts
2010-09-29 22:00:16,158 DEBUG executing: /bin/busybox chmod +t /tmp/etc/hosts
2010-09-29 22:00:16,259 DEBUG command exited with status 0
2010-09-29 22:00:16,260 INFO
2010-09-29 22:00:16,261 INFO Copying /etc/vmware/esx.conf to /tmp/etc/vmware/esx.conf
2010-09-29 22:00:16,263 DEBUG executing: /bin/busybox chmod +t /tmp/etc/vmware/esx.conf
2010-09-29 22:00:16,365 DEBUG command exited with status 0
2010-09-29 22:00:16,365 INFO
2010-09-29 22:00:16,367 INFO Copying /var/log/esxi_install.log to /tmp/var/log/esxi_install.log

Leave a comment