How to change the host ID for Solaris 10 global/non-global zones and Solaris 8/9 containters.

December 16, 2009

In Solaris 10 you cannot change the host ID of the server without doing some major hardware replacement. I will explain a workaround hack to change the hostid for Solaris 10 later in this article. Some applications will not run if you install them on a different server other than the one it was licensed for. This is because the license is associated with the host ID, if it is different then the license check will fail and the application will not launch.

However you can specify a custom host ID for Solaris 8 or 9 containers (non-global zone) running in Solaris 10 global zone. This can be done with using the zonecfg -z command. The instructions for changing the hostid for Solaris 10 global and non-global zones is in the bottom half of this article.

myserver # zonecfg -z myzone1
zonecfg:myzone1> add attr
zonecfg:myzone1:attr> set name=123456
zonecfg:myzone1:attr> set type=string
zonecfg:myzone1:attr> set value=”123456″
zonecfg:myzone1:attr> end
zonecfg:myzone1> exit

Stop myzone1

myserver # zonecfg -z myzone1 halt

Start myzone1

myserver # zonecfg -z myzone boot

Check on the status of myzone1

myserver # zonecfg list -vc

Now logon to the console of myzone1 and check the hostid

myserver @ zlogin -C myzone1

After you enter the login ID and password, run the command hostid.

# hostid

Changing the hostid for Solaris 10 global and non-global zones.
Now you know how to change the host id for Solaris 8 and 9 containers. Here is a great script written by Brendan Gregg that can be used to change the host ID for Solaris 10 global and non-global zones. This script must run as a process in the background. Killing this process will revert the host ID to the factory ID imbedded in the hardware.

Cut and paste the below script to a file called zhostid, make the file executable. Change the following lines to refect the host IDs you want.
global 12345678
myzone1 90abcdef

# zhostid – demo changing hostids for Solaris Zones.
# Written using DTrace (Solaris 10 3/05).
# WARNING: This is a demonstration of DTrace, it is not intended as a
# standard daemon. In particular, hostids are used by Sun to track support
# calls, so changing hostids may make life somewhat confusing for all.
# 21-Jun-2005, ver 0.70 (first release)
# USAGE: zhostid &
# Edit the “Configuration” section below to set the zones and
# hostids to what is desirable.
# BASED ON: hostid.d by Iain Hayes, and idea by Jon Haslam.
# COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place – Suite 330, Boston, MA 02111-1307, USA.
# (
# 21-Jun-2005 Brendan Gregg Created this.

# Configuration
global 12345678
myzone1 90abcdef

‘ # simply modify the above by adding extra lines for each zone.

# Check hostids
print “$hostids” | while read zone hostid_hex; do
### Sanity check hostid
if [[ “$zone” == “” || “$zone” == “#” ]]; then continue; fi
if [[ “$hostid_hex” == *[g-zG-Z]* ]]; then
print “ERROR2: Invalid hostid $hostid_hex. ”
print “Please use hexadecimal.\n”
exit 2
if (( ${#hostid_hex} > 11 )); then
# see /usr/src/uts/common/conf/param.c for limit.
print “ERROR3: Length of hostid $hostid_hex too long. ”
print “Limit 11 chars.\n”
exit 3

### Convert hostid to decimal
typeset -i10 hostid_dec

### Build DTrace code
/zonename == \”$zone\” && self->command == 7/
copyoutstr(\”$hostid_dec\”, self->buffer, 11);

# Run DTrace
exec /usr/sbin/dtrace -n ‘

#pragma D option destructive
#pragma D option quiet
#pragma D option bufsize=32k

inline string hostid = “‘$hostid_dec'”;

self->command = arg0;
self->buffer = arg1;


self->command = 0;
self->buffer = 0;

Now run the zhostid file in the background as a process. The & option means to run in the background and it will give you back the prompt. This file must be run from the global zone.

myserver # ./zhostid &

Check the host ID with the hostid command.

myserver # hostid

Logon the the console of myzone1

# zlogin myzone1
[Connected to zone ‘myzone1’ pts/10]
Last login: Tue Jun 21 03:51:10 on pts/10
Sun Microsystems Inc. SunOS 5.10 Generic January 2005

myzone1 # hostid

Be Sociable, Share!

Tags: ,

7 Responses to “ How to change the host ID for Solaris 10 global/non-global zones and Solaris 8/9 containters. ”

  1. Zazexom on April 27, 2011 at 6:40 pm

    After successfully changing the hostid, I still unable to get the vendor daemon running. It keeps complaining about “not owner” and “cannot open daemon lock file”
    Any clue ?

    • Andrew Lin on May 26, 2011 at 1:51 pm

      Interesting problem, I am afraid I do not have the answer. But if you have figured it out, then please let me know how.

  2. atb on August 9, 2010 at 12:51 am

    The first attribute value should be set name=hostid then set type=string then set value=1234567

  3. Free Image Hosting on February 6, 2010 at 12:18 pm

    very nice.

  4. Tarsha Lyme on January 9, 2010 at 3:28 am

    Many thanks for the well-written article. I liked it. You have a very well-designed site.

  5. SuperSonic on December 17, 2009 at 12:05 pm

    Can i get a one small picture from your blog?
    Have a nice day

    • Andrew Lin on December 17, 2009 at 3:03 pm

      Please let me know what pic you are interested in. I have no issue as long as you provide a link back to my site.

Leave a Reply