{"id":572,"date":"2009-12-16T08:00:27","date_gmt":"2009-12-16T13:00:27","guid":{"rendered":"http:\/\/www.gamescheat.ca\/?p=572"},"modified":"2019-09-04T19:57:40","modified_gmt":"2019-09-05T00:57:40","slug":"how-to-change-the-host-id-for-solaris-10-globalnon-global-zones-and-solaris-89-containters","status":"publish","type":"post","link":"http:\/\/www.gamescheat.ca\/?p=572","title":{"rendered":"How to change the host ID for Solaris 10 global\/non-global zones and Solaris 8\/9 containters."},"content":{"rendered":"<p>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.<\/p>\n<p>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.<\/p>\n<blockquote><p>myserver # zonecfg -z myzone1<br \/>\nzonecfg:myzone1> add attr<br \/>\nzonecfg:myzone1:attr> set name=123456<br \/>\nzonecfg:myzone1:attr> set type=string<br \/>\nzonecfg:myzone1:attr> set value=\u201d123456\u2033<br \/>\nzonecfg:myzone1:attr> end<br \/>\nzonecfg:myzone1> exit<\/p><\/blockquote>\n<p>Stop myzone1<\/p>\n<blockquote><p>myserver # zonecfg -z myzone1 halt<\/p><\/blockquote>\n<p>Start myzone1<\/p>\n<blockquote><p>myserver # zonecfg -z myzone boot<\/p><\/blockquote>\n<p>Check on the status of myzone1<\/p>\n<blockquote><p>myserver # zonecfg list -vc<\/p><\/blockquote>\n<p>Now logon to the console of myzone1 and check the hostid<\/p>\n<blockquote><p>myserver @ zlogin -C myzone1<\/p><\/blockquote>\n<p>After you enter the login ID and password, run the command hostid.<\/p>\n<blockquote><p># hostid<br \/>\n123456<\/p><\/blockquote>\n<p><strong>Changing the hostid for Solaris 10 global and non-global zones.<\/strong><br \/>\nNow 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.<\/p>\n<div style=\"float: right;\"><div style=\"margin: 15px 15px 15px 15px\";><script type=\"text\/javascript\"><!--\ngoogle_ad_client = \"pub-3319935785736004\";\ngoogle_alternate_color = \"FFFFFF\";\ngoogle_ad_width = 300;\ngoogle_ad_height = 250;\ngoogle_ad_format = \"300x250_as\";\ngoogle_ad_type = \"text_image\";\ngoogle_ad_channel =\"\";\ngoogle_color_border = \"cccccc\";\ngoogle_color_link = \"cc0000\";\ngoogle_color_bg = \"ffffff\";\ngoogle_color_text = \"000000\";\ngoogle_color_url = \"008000\";\n\/\/--><\/script>\n<script type=\"text\/javascript\"\n  src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">\n<\/script><\/div><\/div><p>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.<br \/>\nglobal\t\t12345678<br \/>\nmyzone1\t        90abcdef <\/p>\n<blockquote><p>#!\/usr\/bin\/ksh<br \/>\n#<br \/>\n# zhostid \u2013 demo changing hostids for Solaris Zones.<br \/>\n#           Written using DTrace (Solaris 10 3\/05).<br \/>\n#<br \/>\n# WARNING: This is a demonstration of DTrace, it is not intended as a<br \/>\n# standard daemon. In particular, hostids are used by Sun to track support<br \/>\n# calls, so changing hostids may make life somewhat confusing for all.<br \/>\n#<br \/>\n# 21-Jun-2005, ver 0.70\t\t(first release)<br \/>\n#<br \/>\n# USAGE:\tzhostid &<br \/>\n#<br \/>\n# Edit the \u201cConfiguration\u201d section below to set the zones and<br \/>\n# hostids to what is desirable.<br \/>\n#<br \/>\n# BASED ON: hostid.d by Iain Hayes, and idea by Jon Haslam.<br \/>\n#<br \/>\n# COPYRIGHT: Copyright (c) 2005 Brendan Gregg.<br \/>\n#<br \/>\n#  This program is free software; you can redistribute it and\/or<br \/>\n#  modify it under the terms of the GNU General Public License<br \/>\n#  as published by the Free Software Foundation; either version 2<br \/>\n#  of the License, or (at your option) any later version.<br \/>\n#<br \/>\n#  This program is distributed in the hope that it will be useful,<br \/>\n#  but WITHOUT ANY WARRANTY; without even the implied warranty of<br \/>\n#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br \/>\n#  GNU General Public License for more details.<br \/>\n#<br \/>\n#  You should have received a copy of the GNU General Public License<br \/>\n#  along with this program; if not, write to the Free Software Foundation,<br \/>\n#  Inc., 59 Temple Place \u2013 Suite 330, Boston, MA  02111-1307, USA.<br \/>\n#<br \/>\n#  (http:\/\/www.gnu.org\/copyleft\/gpl.html)<br \/>\n#<br \/>\n# 21-Jun-2005\tBrendan Gregg\tCreated this.<\/p>\n<p>#<br \/>\n#  Configuration<br \/>\n#<br \/>\nhostids=\u2019<br \/>\n\t\tglobal\t\t12345678<br \/>\n\t\tmyzone1  \t90abcdef<\/p>\n<p>\u2018 # simply modify the above by adding extra lines for each zone.<\/p>\n<p>#<br \/>\n#  Check hostids<br \/>\n#<br \/>\nprint \u201c$hostids\u201d | while read zone hostid_hex; do<br \/>\n\t### Sanity check hostid<br \/>\n\tif [[ \u201c$zone\u201d == \u201c\u201d || \u201c$zone\u201d == \u201c#\u201d ]]; then continue; fi<br \/>\n\tif [[ \u201c$hostid_hex\u201d == *[g-zG-Z]* ]]; then<br \/>\n\t\tprint \u201cERROR2: Invalid hostid $hostid_hex. \u201d<br \/>\n\t\tprint \u201cPlease use hexadecimal.\\n\u201d<br \/>\n\t\texit 2<br \/>\n\tfi<br \/>\n\tif (( ${#hostid_hex} > 11 )); then<br \/>\n\t\t# see \/usr\/src\/uts\/common\/conf\/param.c for limit.<br \/>\n\t\tprint \u201cERROR3: Length of hostid $hostid_hex too long. \u201d<br \/>\n\t\tprint \u201cLimit 11 chars.\\n\u201d<br \/>\n\t\texit 3<br \/>\n\tfi<\/p>\n<p>\t### Convert hostid to decimal<br \/>\n\ttypeset -i10 hostid_dec<br \/>\n\thostid_dec=16#$hostid_hex<\/p>\n<p>\t### Build DTrace code<br \/>\n\tbody=\u201d$body<br \/>\n\t\tsyscall::systeminfo:return<br \/>\n\t\t\/zonename == \\\u201d$zone\\\u201d && self->command == 7\/<br \/>\n\t\t{<br \/>\n\t\t\tcopyoutstr(\\\u201d$hostid_dec\\\u201d, self->buffer, 11);<br \/>\n\t\t}\u201d<br \/>\ndone<\/p>\n<p>#<br \/>\n#  Run DTrace<br \/>\n#<br \/>\nexec \/usr\/sbin\/dtrace -n \u2018<\/p>\n<p> #pragma D option destructive<br \/>\n #pragma D option quiet<br \/>\n #pragma D option bufsize=32k<\/p>\n<p> inline string hostid = \u201c\u2018$hostid_dec'\u201d;<\/p>\n<p> syscall::systeminfo:entry<br \/>\n {<br \/>\n\tself->command = arg0;<br \/>\n\tself->buffer = arg1;<br \/>\n }<\/p>\n<p> \u2018\u201d$body\u201d\u2018<\/p>\n<p> syscall::systeminfo:return<br \/>\n {<br \/>\n\tself->command = 0;<br \/>\n\tself->buffer = 0;<br \/>\n }<br \/>\n\u2018 <\/p><\/blockquote>\n<p>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.<\/p>\n<blockquote><p>myserver # .\/zhostid &<\/p><\/blockquote>\n<p>Check the host ID with the hostid command.<\/p>\n<blockquote><p>myserver # hostid<br \/>\n12345678<\/p><\/blockquote>\n<p>Logon the the console of myzone1<\/p>\n<blockquote><p># zlogin myzone1<br \/>\n[Connected to zone \u2018myzone1\u2019 pts\/10]<br \/>\nLast login: Tue Jun 21 03:51:10 on pts\/10<br \/>\nSun Microsystems Inc.   SunOS 5.10      Generic January 2005<\/p>\n<p>myzone1 # hostid<br \/>\n90abcdef<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>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&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/www.gamescheat.ca\/?p=572\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"tags":[43,64],"_links":{"self":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/572"}],"collection":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=572"}],"version-history":[{"count":5,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/572\/revisions"}],"predecessor-version":[{"id":982,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=\/wp\/v2\/posts\/572\/revisions\/982"}],"wp:attachment":[{"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=572"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gamescheat.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}