This article explains how to setup Scripted Install, and some of the features that might be useful to you when getting started. This is not a comprehensive guide, but should be used as a reference when setting up your Scripted Install environment. For more detailed information on setting up Scripted Install, see the ESXi and vCenter Server Installation and Setup guide.
The scripted install feature of ESXi 5.x provides an efficient way to deploy multiple ESXi hosts. You can quickly deploy ESXi hosts using unattended installations with Scripted Install. The installation script ( ks.cfg) contains settings for your ESXi hosts that can be modified to suit the needs of your environment. You can apply the script to all hosts that you want to have a similar configuration. This allows you to perform swift installations, in a shorter amount of time than it would by performing a manual installation. In addition, this ensures that all hosts have similar configurations and are built to the standard you want.
If you have used Scripted Install in the past with ESXi 4.x, before performing a Scripted Install with ESXi 5.x, you should be familiar with the differences between ESXi 4.x and ESXi 5.x scripted installation commands. These are the differences to note:
Some commands have been deprecated or changed:
Performing a Scripted Install with ESXi 5.x requires:
The installation script ( ks.cfg) can reside in any of these locations:
You can install ESXi 5.x on multiple machines using a single script or a separate script for each machine. You can start the installation script by two different methods:
Note: A ks= option must be given to specify the location of the installation script ( ks.cfg ) file. If ks= is omitted, the text installer proceeds as if it were a normal installation.
Note: When ESXi 5.x is being installed using a kickstart file via PXE with DHCP enabled; the DNS settings are not available and are not saved in the configuration file.
Options for the ks= command
Boot Option | Description |
BOOTIF=<MAC address> | Tries to use a network adapter device when looking for an installation script and installation media. |
gateway=<ip address> | Sets this network gateway as the default gateway |
ip=<ip address> | Sets up a static IP address to be used for downloading the installation script and the installation media. |
ks=cdrom:/<path\> | Performs a scripted installation with the script at path, which resides on the CD in the CD-ROM drive. |
ks=file://<path> | Performs a scripted installation with the script at path. |
ks=protocol://<serverpath> | Performs a scripted installation with a script located on the network at the given URL. Protocol can be HTTP, HTTPS, FTP, or NFS. |
ks=usb:</path</SPAN>> | Performs a scripted install, accessing the script from an attached USB drive. Searches for a file named ks.cfg. |
nameserver=<ip address> | Specifies a domain name server |
netdevice=<device> | Use network adapter device (MAC or vmnicN) |
netmask=<subnet mask> | Specifies subnet mask for the network interface |
vlanid=<vlanid> | Configure the network card to be on the specified VLAN |
ksdevice=device | Tries to use a network adapter device when looking for an installation script and installation media. Specify as a MAC address, for example, 00:50:56:C0:00:01. This location can also be a vmnicNN name. If not specified and files need to be retrieved over the network, the installer defaults to the first discovered network adapter that is plugged in. |
Example: Booting off an NFS share uses a command like this:
ks=nfs://192.168.0.101/FS2/isos/esxi-B.cfg nameserver=192.168.0.57 ip=192.168.0.3 netmask=255.255.255.0 gateway=192.168.0.254
In order to customize an ESXi installation a ks.cfg file must be created before performing the above boot process. The default installation script ks.cfg is located in the initial RAM disk at /etc/vmware/weasel/ks.cfg.
You can specify the location of the ks.cfg in the installation script with the boot option ks=file://etc/vmware/weasel/ks.cfg if you do not wish to perform any customizations.
Note: When you install ESXi using ks.cfg, the default root password is set to mypassword.
Example: This is what the ks.cfg file looks like in /etc/vmware/weasel:
#
# Sample scripted installation file
#
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and Tech Support Mode
rootpw mypassword
# The install media is in the CD-ROM drive
install --firstdisk --overwritevmfs
# Set the network to DHCP on the first network adapater
network --bootproto=dhcp --device=vmnic0
# A sample post-install script
%post --interpreter=python --ignorefailure=true
import time
stampFile = open('/finished.stamp', mode='w')
stampFile.write( time.asctime() )
Beyond this, you can further customize the script to suit your environment. The following tables show what commands you can use to customize your scripts. When using these tables, be aware that:
You can use these commands in your ks.cfg file:
Clearing partitions
Command | Function |
clearpart (optional) | Clear any existing partitions on the disk. Requires install command to be specified. |
--drives= | Remove partitions on a specified drive. |
--alldrives | Ignore the “--drives=" requirement and allows clearing partitions on every drive. |
--ignoredrives= | Remove partitions on all drives except those specified. Required unless the --drives= or --alldrives flags are specified. |
Permit overwriting of vmfs partitions on the specified drives. By default, overwrite vmfs partitions is not allowed. | |
- -overwritevmfs | |
--firstdisk(=<disk-type1>,[<disk-type2>, ...]) | Partitions the first eligible disk found. The order of the eligible disks is set to: |
1 locally attached storage (local) | |
2 network storage (remote) | |
3 usb disks (usb) | |
You can change the ordering of the disks by using a comma separated list appended to the argument. |
Examples:
Creating partitions
Command | Function |
part or partition (optional) | Creates an additional VMFS datastore on the system. Only one datastore per disk can be created. Cannot be used on the same disk as the install command. |
<datastore name> | Specifies where the partition is to be mounted |
--ondisk= or --ondrive= | Specifies the disk or drive where the partition is created. |
--onfirstdisk | Partitions the first eligible disk found. The order of the eligible disks are set to: |
(=<disk-type1>,[<disk-type2>, ...]) | 1 locally attached storage (local) |
2 network storage (remote) | |
3 usb disks (usb) | |
You can change the ordering of the disks by using a comma separated list appended to the argument. |
Examples:
Command | Function |
install | Specifies that this is a fresh installation. |
Replaces the deprecated autopart command used for ESXi 4.1 scripted installations. | |
One of the commands install, upgrade, or installorupgrade is required to determine which disk to install or upgrade ESXi on. | |
--disk= or --drive= | Specifies the disk to partition. |
--firstdisk= | Partitions the first eligible disk found. The order of the eligible disks is set to: |
disk-type1, | 1 locally attached storage (local) |
[disk-type2,...] | 2 network storage (remote) |
3 usb disks (usb) | |
You can change the ordering of the disks by using a comma separated list appended to the argument | |
--overwritevmfs | Required to overwrite any existing VMFS datastore on the disk before installation. |
--preservevmfs | Preserves an existing VMFS datastore on the disk during installation. |
--novmfsondisk | Prevents a VMFS partition from being created on this disk. Must be used with --overwritevmfs if a VMFS partition already exists on the disk. |
Examples:
Upgrade options
Command | Function |
upgrade | Specifies that this is a upgrade. |
Replaces the deprecated autopart command used for ESXi 4.1 scripted installations. | |
One of the commands install, upgrade, or installorupgrade is required to determine which disk to install or upgrade ESXi on. | |
--disk= or --drive= | Specifies the disk to partition. |
--firstdisk= | Partitions the first eligible disk found. The order of the eligible disks is set to: |
disk-type1, | 1 locally attached storage (local) |
[disk-type2,...] | 2 network storage (remote) |
3 usb disks (usb) | |
You can change the ordering of the disks by using a comma separated list appended to the argument | |
--deletecosvmdk | If the system is being upgraded from ESX, remove the directory containing the old Console VMDK file, cos.vmdk, to reclaim unused space in the VMFS datastore. |
Examples:
Install or Upgrade options
Command | Function |
installorupgrade | One of the commands install, upgrade, or installorupgrade is required to determine which disk to install or upgrade ESXi on. |
--disk= or --drive= | Specifies the disk to partition. |
--firstdisk= | Partitions the first eligible disk found. The order of the eligible disks is set to: |
disk-type1, | 1 locally attached storage (local) |
[disk-type2,...] | 2 network storage (remote) |
3 usb disks (usb) | |
You can change the ordering of the disks by using a comma separated list appended to the argument | |
--overwritevmfs | Install ESXi if a VMFS partition exists on the disk, but there is no ESX or ESXi installation. |
Unless this option is present, the installer fails if a VMFS partition exists on the disk, but there is no ESX or ESXi installation | |
Example:
Miscellaneous options
Command | Function |
keyboard | Set the keyboard type for the system to one of the following: Default, French, German, Japanese, Russian, 'United Kingdom' |
dryrun (optional) | Parse and check the kickstart file, but do not actually do the install. |
accepteula or vmaccepteula (required) | Accepts the VMware License Agreement (EULA). |
reboot | Reboot the machine after the scripted installation is finished. |
--noeject | Do not eject the CD after installation. |
rootpw (required) | Set the root (admin) password for the system. |
--iscrypted | Specifies that the password is already encrypted. |
paranoid (optional) | Causes any warning messages to interrupt the installation. If you omit this command, warning messages are logged. |
Examples:
Network options
Command | Function |
network (optional) | Specify a network address for the system. |
--bootproto= | Specify whether to obtain the network settings via DHCP or set it manually. |
[dhcp|static] | |
--device= | Either the MAC address of the network card or the device name, of the form vmnicN. This option refers to "uplink" device for the virtual switch. |
--ip= | Set the IP address for the system. This is used with the static bootproto option and is required if the static option is specified and ignored otherwise. This should be in the form xxx.xxx.xxx.xxx. |
--gateway= | Specify the network gateway. Should be in the form xxx.xxx.xxx.xxx. Used with the static bootproto option. If no option is specified, warn in the log file and continue with no gateway setting. |
-- nameserver= | Specify up to two nameservers. Used with the static bootproto option.Should be in the form xxx.xxx.xxx.xxx,[xxx.xxx.xxx.xxx]. |
--nodns | Not used. This is the same as not specifying --nameserver= or not appending any arguments to it. |
--netmask= | Netmask for the specified system. This should default to the proper netmask for the given type of ip address. Should be in the form “255.xxx.xxx.xxx". Used with the static bootproto option. |
--hostname= | Specifies the hostname for the system. |
--vlanid= | Specifies which VLAN the system is on. Used with either dhcp or static bootproto option. Should be an integer between 1 and 4094. |
--addvmportgroup= | Specifies whether or not to add the VM Network port group which is used by virtual machines. The default value is 1. |
(0|1) |
Examples:
Pre-, post-, and first boot script options
Command | Function |
%pre | Specifies a script to be executed before the kickstart configuration is to be evaluated. For example, it can be used to generate files to be included by the kickstart file. Requires the -unsupported argument. |
--interpreter= [python|busybox] | The script interpreter to use, defaults to busybox. |
%post | Execute the specified script after installation has been completed. If multiple %post sections are specified, they are executed in the order they are found in the kickstart file.. |
--interpreter= [python|busybox] | The script interpreter to use, defaults to busybox. |
--timeout=secs | Set a timeout for executing the script. If the script has not finished when the timeout expires, the script is forcefully terminated. |
--ignorefailure= | If true, then the installation is considered a success even if the %post script terminated with an error. |
[true|false] | |
%firstboot | Causes an init script to be created. The init script executes the commands specified in the %firstboot section during the first boot only; it has no effect on subsequent boots. If multiple %firstboot sections are specified and their level is the same, they are executed in the order they are found in the kickstart file. |
--interpreter= [python|busybox] | The script interpreter to use, defaults to busybox. |
%include OR include | Specify an additional kickstart file to parse. This command is treated similarly to a multi-line command, but takes only one argument. |
<filename> |
With the above options and the example ks.cfg file, you can start customizing your own ESXi 5.x host builds. For more detailed information regarding setting up a Scripted Install and doing PXE Boot installations, see the ESXi and vCenter Server Installation and Setup guide.
For other methods of installing ESXi 5.x, see these articles: