Loading

×Sorry to interrupt
Uncaught ReferenceError: addCTracking is not defined
throws at https://kb.vmware.com/resource/KM_TealiumTrackingJS?v=0.5:100:1

Refresh

Cookie Preference Center

General Information on cookies

When you visit our website, we use cookies to ensure that we give you the best experience. This information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies by clicking on the different category headings to find out more and change your settings. However, blocking some types of cookies may impact your experience on the site and the services we are able to offer. Further information can be found in our

Cookie Policy.

Strictly Necessary

Strictly Necessary

Always Active

Strictly Necessary

Strictly necessary cookies are always enabled since they are essential for our website to function. They enable core functionality such as security, network management, and website accessibility. You can set your browser to block or alert you about these cookies, but this may affect how the website functions. For more information please visit www.aboutcookies.org or www.allaboutcookies.org.

Cookie Details‎

Performance

Performance

Performance

Performance cookies are used to analyze the user experience to improve our website by collecting and reporting information on how you use it. They allow us to know which pages are the most and least popular, see how visitors move around the site, optimize our website and make it easier to navigate.

Cookie Details‎

Please confirm your settings by refreshing the page.

Functional

Functional

Functional

Functional cookies help us keep track of your past browsing choices so we can improve usability and customize your experience. These cookies enable the website to remember your preferred settings, language preferences, location and other customizable elements such as font or text size. If you do not allow these cookies, then some or all of these services may not function properly.

Cookie Details‎

Advertising

Advertising

Advertising

Advertising cookies are used to send you relevant advertising and promotional information. They may be set through our site by third parties to build a profile of your interests and show you relevant advertisements on other sites. These cookies do not directly store personal information, but their function is based on uniquely identifying your browser and internet device.

Cookie Details‎

Advertising Cookies

Consent Leg.Interest

Select All Vendors

Select All Vendors

Select All Hosts

Select All

Clear Filters

Information storage and access

Apply

Confirm My Choices Reject All Allow All

My Subscriptions

Loading

Knowledge Base

Setting the customization script for virtual machines in vSphere 7.x and 8.x (74880)

Last Updated: 5/1/2023Categories: InformationalTotal Views: 26715Language:
Chinese (Simplified)JapaneseEnglish

11 like this article

Subscribe to get an email
newsletter with new updates

11 people found this helpful Please provide article feedback:

Details

This article provides information on creating guest customization scripts for Linux virtual machines that will be applied before and after customization.

Solution

Prerequisites

Ensure that VMware Tools version 10.1.0 or later is installed.

Please note that the Linux version of VMware Tools is "open-vm-tools", which is separate from the Windows version. Please see https://docs.vmware.com/en/VMware-Tools/12.2.0/com.vmware.vsphere.vmwaretools.doc/GUID-8B6EA5B7-453B-48AA-92E5-DB7F061341D1.html

In the VMware Tools configuration, the enable-custom-scripts option is disabled by default for security and will need to be enabled to run the script.

To check the value of this option, launch below command in guest operating system:

vmware-toolbox-cmd config get deployPkg enable-custom-scripts

To enable this option, launch below command in guest operating system:

vmware-toolbox-cmd config set deployPkg enable-custom-scripts true

The customization script could be defined in “Customization script” page of a customization specification for Linux, the script:

Is called during guest operating system customization.

The default timeout period for the guest customization to complete is set to 100 seconds and includes the time for the script to run when using the precustomization command-line parameter. If you run scripts that will exceeding the timeout, the guest customization will fail.

Is called with the precustomization command line parameter before the guest customization begins.  As a result, the virtual NIC is disconnected and you cannot access the network

Is called with the postcustomization command line parameter after the guest customization finishes. As a result, the script is scheduled in the initialization process after the virtual machine powers on, the NIC is connected, and you can access the network.

The script could be Shell, Python or Perl etc.

Sample customization scripts for Linux virtual machines:

A Linux sample Shell script

#!/bin/sh
if [ x$1 = x"precustomization" ]; then
echo "Do Precustomization tasks"
elif [ x$1 = x"postcustomization" ]; then
echo "Do Postcustomization tasks"
fi

A Linux sample Python script

#!/usr/bin/env python
import sys
if sys.argv[1] == "precustomization":
print "Do Precustomization tasks"
elif sys.argv[1] == "postcustomization":
print "Do Postcustomization tasks"

A Linux sample Perl script

#!/usr/bin/perl
if ($ARGV[0] eq "precustomization") {
print "Do Precustomization tasks";
}
elsif ($ARGV[0] eq "postcustomization") {
print "Do Postcustomization tasks";
}

Note:
1. The length of customization script cannot be greater than 1500 characters in vSphere 7.x, this length
limitation has been increased to 65536 characters in vSphere 8.x.
2. The error in customization script can cause the customization failure, so please verify your customization
script in your VM before using it to customize the VM. Follow below steps as root to do the verification.
2.1 Save your script in a text, e.g. customization_script
2.2 Add execute permission for customization_script
chmod +x customization_script
2.3 Verify the script by below commands
./customization_script precustomization
./customization_script postcustomization

Detectable by VMware SkylineTM

Actions

Copy

link to clipboard
copied!

Print

Language:
Chinese (Simplified)JapaneseEnglish

Attachments

Additional Resources

KB
•
End Of General Availability of the Free vSphere Hypervisor (ESXi 7.x and 8.x) (2107518)

Result 1 of 1

Ask The Community

Get answers quickly from VMware experts in the community

Post Subject

CONTINUE IN COMMUNITIES

Related Products:

VMware vSphere ESXi

Related Versions:

VMware vSphere ESXi 8.0.x

VMware vSphere ESXi 7.x

Take Our Survey

Support Assistant