Search the VMware Knowledge Base (KB)
View by Article ID

Deploying ESXi 5.x using the Scripted Install feature (2004582)

  • 18 Ratings

Purpose

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.

Resolution

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.

Differences of Scripted Install between ESXi 4.x and 5.x

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:

  • In ESXi 5.x, because the installation image is loaded directly into the host RAM when the host boots, there is no need to include the location of the installation media in the installation script.
  • ESXi 5.x supports scripted upgrades in addition to scripted installation. In ESXi 4.x, you could only do fresh installations.
  • Some commands have been deprecated or changed:

    • Deprecated commands: auth/authconfig, bootloader, firewall, firewallport, timezone, virtualdisk, zerombr, %packages
    • Changed commands: autopart (replaced by install, upgrade, installorupgrade), esxlocation, serialnum / vmserialnum

Prerequisites

Performing a Scripted Install with ESXi 5.x requires:

  1. Creating a script ( ks.cfg) using the supported commands.
  2. Editing the installation script as needed to change settings that are unique for each host.
  3. Running the scripted installation process by either specifying boot options, or automatically booting using PXE boot.

The installation script ( ks.cfg) can reside in any of these locations:

  • FTP
  • HTTP/HTTPS
  • NFS Share
  • USB flash drive
  • CD/DVD device

How to specify booting off the customized ks.cfg file

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:

  • Boot up interactively by pressing Shift+O during the boot loader. Enter commands to locate the ks.cfg file.

    Example: ks=<location of installation script> <boot command line options>

  • To perform a more automated installation, you can pass options through the kernelopt line of the boot.cfg file for a PXE boot installation. Setting up a PXE boot server is beyond the scope of this article, and is unique in every environment. For more information on setting up a PXE boot, see the ESXi and vCenter Server Installation and Setup guide.

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>

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

Creating the ks.cfg file

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:

  • An argument is defined as any word which comes after a command, and usually (although not always) begins with two dashes.
  • A string is defined as any value which is assigned to a command or argument. Strings can be double-quoted, single-quoted, or contain no quotes providing they have no white space characters.
  • The ks.cfg script itself contains a non-ordered list of commands, most of which take additional arguments.
  • Commands can be either single- or multi-line, where multi-line commands always begin with the % character and finish either at the end of the script or when a separate multi-line command begins.
  • Comments can be added inside the script with the # character, providing it is outside of a string. All characters after the # are ignored.

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:

  • clearpart --firstdisk --overwritevmfs
  • clearpart --drives=mpx.vmhba1:C0:T1:L0 --overwritevmfs
  • clearpart --drives=vml.0000000000766d686261313a313a30 –overwritevmfs

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:

  • partition –ondisk=mpx.vmhba1:C0:T1:L0 datastore2
  • partition datastore2 --ondisk=mpx.vmhba1:C0:T2:L0
  • part datastore2 --firstdisk=ST3120814A,mptsas,local
Installation options
 

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:

  • install --firstdisk --overwritevmfs
  • install --overwritevmfs –-novmfsondisk

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:

  • upgrade --firstdisk
  • upgrade --firstdisk –deletecosvmdk

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:

  • installorupgrade --firstdisk –overwritevmfs

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:

  • vmaccepteula
  • rootpw vmware
  • keyboard 'United Kingdom' - For UK keyboard the quotes are required.

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:

  • network –bootproto=dhcp --device=vmnic0 --addvmportgroup=0
     
  • network --bootproto=static --device=vmnic0 --ip=123.123.123.123 --netmask=255.255.252.0 --gateway=123.123.123.120 --nameserver=123.123.123.4
     

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>

 
 
You may not need to use many of these commands, but they are useful when you need to specifically customize certain options on your ESXi hosts. The Scripted Install feature of ESXi 5.x is an advanced installation, and requires certain configuration in order for it to perform properly.

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:

Additional Information

Tags

esxi-scripted-install-how-to

See Also

Request a Product Feature

To request a new product feature or to provide feedback on a VMware product, please visit the Request a Product Feature page.

Feedback

  • 18 Ratings

Did this article help you?
This article resolved my issue.
This article did not resolve my issue.
This article helped but additional information was required to resolve my issue.

What can we do to improve this information? (4000 or fewer characters)




Please enter the Captcha code before clicking Submit.
  • 18 Ratings
Actions
KB: