Wrote this script earlier and said to hicksd8 that I'd post it here, it's just a quick and dirty hack to change the hostid of a global zone on a Solaris Virtual running under a hypervisor - manes and ID changed to protect the inocent.
Code:
#!/usr/bin/bash
################################################################################
#
# Script to change hostid on a Solaris 11.1 virtual machine running in VMWare
# where there is a requirement for the hostid of the GLOBAL zone to be changed.
# If changing the hostid of a non global zone this can be done using the normal
# process for a Solaris Zone.
#
################################################################################
################################################################################
#
# Title - Set Hostid
#
# Author - Dave Hoojikaflip
# Date - 19/04/2014
# Version - 1.00.01
#
################################################################################
# Dependencies.
#
# 1 This script requires standard Solaris 11.1 install.
#
# 2 This script required the standard logging utility to be in the BINDIR
#
################################################################################
# Deprecated.
#
# 1 No longer requires the hostid to be passed as an argument.
#
################################################################################
#
# History - Please enter changes here - latest at the top.
#
################################################################################
#
# Version 1.00.01
#
# Hostid now embedded in the script, tested on license servers with Solaris 11.1
# and the CAD environment set in anticipation of consolidation excercise.
#
# Version 1.00.00
#
# Created to set hostid manually, will implement as a service with logging when
# time allows. The desired hostid must be passed as an argument, will set a
# default option in a later version of the script.
#
################################################################################
################################################################################
#
# Set Globals here.
#
################################################################################
MAX=0
THISPROG=/usr/local/bin/set_hostid.sh
NAME=`uname -n`
DATE=`date +%m/%d/%y`
export NAME DATE THISPROG MAX
OTYP=`uname`
BINDIR=/usr/local/bin
LIBDIR=/usr/local/lib
TMPDIR=/tmp
MAILFILE=/tmp/hostid_set_ok.txt
export OTYP BINDIR LIBDIR TMPDIR MAILFILE
################################################################################
#
# Set the required hostid below.
#
################################################################################
HOSTID=0x80cfe985
export HOSTID
################################################################################
#
# Setup the logging functions.
#
################################################################################
STARTMSG ()
{
/usr/local/bin/logger.sh "${THISPROG} $* STARTED"
}
MSG ()
{
/usr/local/bin/logger.sh "${THISPROG} $*"
}
JMSG ()
{
echo "${THISPROG} $*"
}
ERR ()
{
/usr/local/bin/logger.sh "${THISPROG} $*"
/usr/local/bin/logger.sh "${THISPROG} FAILS"
exit 1
}
ENDMSG ()
{
/usr/local/bin/logger.sh "${THISPROG} COMPLETED"
exit 0
}
################################################################################
#
# Set the hostid for a Solaris Global in a virtual under VSphere, should work
# for most Hypervisors.
#
################################################################################
################################################################################
#
# Put the start message in the logfile allong with calling script and time stamp.
#
################################################################################
STARTMSG
################################################################################
#
# Print the screen message to advise user of actions.
#
################################################################################
echo "This licence server replaces edinburgh.noobab.com - with a hostid of 80cfe985"
echo ""
################################################################################
#
# Set the hostid here and test results, use standard day log for output.
#
################################################################################
################################################################################
#
# Convert the Hex hostid variable to a sequence of Ascii.
#
################################################################################
ascii=`echo $((${HOSTID})) | od -t x1 | head -1 | cut -f2-100 -d" "`
if [[ $? != "0" ]]
then
MSG "Conversion of Hex string to Ascii has failed."
ERR "Check that the HOSTID variable is formatted as 0xFFFFFFFF."
else
MSG "Successful conversion Hex to Ascii."
fi
################################################################################
#
# Open the serial module for writing and insert the new hostid.
#
################################################################################
echo "hw_serial/v "${ascii:0:$((${#ascii}-2))}"00 0" | mdb -kw
if [[ $? != "0" ]]
then
MSG "Inserion of hostid in core module has failed."
ERR "Check that the module debugger is installed."
else
MSG "Successful hostid change."
fi
################################################################################
#
# Print the new hostid on the screen and output to logfile.
#
################################################################################
JMSG "hostid is now set to: "`hostid`
MSG "hostid is now set to: "`hostid`
ENDMSG
Once again, thank you for this. Knowing that this technique works on Solaris 11 is new knowledge. I must say for clarity of future reading that this code only applies to Solaris x86. Where did you put this script to execute automatically at boot time?
(If you are in a position to develop and test a Solaris SPARC version then I'll post that code too.)
Last edited by hicksd8; 11-08-2014 at 12:22 PM..
Reason: correct typo
The script is located in /usr/local/bin which is where I tend to put anything that I write to complete an admin function.
At the moment it is a manual job to run the script, however I will probably implement it as a service at some point and I'll put a copy in /etc/init.d just for completeness.
Would quite like to try this with a sparc based M/C and can't actually see why it wouldn't work although it would probably require the adb as against the mdb But right now I have only got access to 2 * Ultra 10's one running 2.6 amd one running 2.7 so not much chance of a proof of concept there.
Obviously it will be the same situation on a sparc and the hostid won't persist across a reboot.
Regards
Dave
Last edited by rbatte1; 08-27-2014 at 12:30 PM..
Reason: Changed CODE tags to ICODE tags
You're not wrong. On SPARC I use adb to modify the hostid. On both x86 and SPARC I insert lines at the end of /etc/rc2.d/S20sysetup so that they execute every time the machine boots.
Following below is a copy of the S20sysetup file from my SPARC system.
Again, I've not tested this code on Solaris 11 but it works great on Solaris 10.
All this stuff makes a good knowledge base for future readers and also means that you can help out on any hostid and lmgrd questions too. There doesn't seem to be too much knowledge about on this.
Best
hicksd8
---------- Post updated at 07:57 PM ---------- Previous update was at 07:54 PM ----------
Here's my S20sysetup...........(for SPARC)
Code:
#!/sbin/sh
#
# Copyright (c) 1984-1998 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident "@(#)sysetup 1.18 98/10/09 SMI"
if [ -z "$_INIT_PREV_LEVEL" ]; then
set -- `/usr/bin/who -r`
_INIT_PREV_LEVEL="$9"
fi
[ $_INIT_PREV_LEVEL != S -a $_INIT_PREV_LEVEL != 1 ] && exit 0
# Uncomment this line to print the complete system configuration on startup
#[ -x /usr/sbin/prtconf ] && /usr/sbin/prtconf
# If there are trademark files, print them.
[ -d /etc/tm ] && /usr/bin/cat /etc/tm/* 2>/dev/null
#
# Savecore is enabled by default.
# See dumpadm(1M) on how to customize
# system dump configuration.
#
# **** Additional lines added to this file to set hostid ****
#
# Change Host ID to Hex 807a6e94
# Convert to a decimal value = 2155507348
# Use HEXADECIMAL to BINARY conversion, HEX to Decimal converter, Hexdecimal convertor to do this
#
# Divide into 3 parts: 2155 5073 48
# Hex value of the above ASCII chars
# Use above web site for this too
# 32 31 35 35
# 35 30 37 33
# 34 38
#
# After padding out
# 32313535
# 35303733
# 34380000
#
# o let's set the new hostid
# Comment out the following lines in a virtualised environment
# Container will set the hostid
# hicksd8 14 July 2011
adb -w -k /dev/ksyms /dev/mem /dev/null<<END
hw_serial/W 0x32313535
hw_serial+4/W 0x35303733
hw_serial+8/W 0x34380000
END
# That's it!
No wonder license server support people are still asking these types of questions!!! I just dealt with another one (locally).
It seems that people bought extremely expensive perpetual software licenses years ago which are protected by license servers like lmgrd (FlexLM). The hardware it is running on (eg, Sun Ultra1's) are now completely knackered and end-of-life but the original software company has gone bust, been taken over (several times), or the company is trying to sell their new software, and so to get the license file regenerated for a new host is impossible. However, the end user has a legal right to run the software and simply wants to move servers.
The software company simply doesn't understand, or deliberately won't understand the problem.
I hope this thread becomes the definitive place to look for help on this.
You and me both, just for completeness - here are the guts of the logger.sh script that all my scripts call to log to a single journal/log file for the day.
Code:
# Description.
#
# Callable logging utility allowing all working shell scripts and utilities to
# log to a single log file or journal.
#
# The utility should be called from within the shell scripts that require the
# log function.
#
###############################################################################
#
# History.
#
# Initial Version - 2013/10/03
#
##############################################################################
#
# Check if the calling shell knows about a logfile, if it doesn't create one.
#
##############################################################################
if [ ${LOG} ]
then
:
else
LOG="/var/log/day_log_`date +%Y``date +%m%d`"
fi
###############################################################################
#
# Set the MSG variable, to log with the calling shell.
#
###############################################################################
MSG="`date '+%d %b %T'` $*"
###############################################################################
#
# Test if the log is writeable, if not correct it.
#
###############################################################################
if [ -f ${LOG} ]
then
:
else
touch ${LOG}
chmod 666 ${LOG}
fi
if echo "`date '+%d %b %T'` $*" >> ${LOG}
then
:
else
ERROR=$?
echo "LOGGER FAILED TO WRITE TO LOG FILE, error=${ERROR}"
exit ${ERROR}
fi
This just allows multiple scripts to log as required - all to the same output file - handy for error checking etc.
Hi, hoping someone can help, its been a while since I used Solaris.
After creating a NGZ (non global zone), the NGZ can access the GZ (Global Zone) and the GZ can access the NGZ (using ssh, zlogin)
However, the NGZ cannot access any other netwqork devices, it can't even see the default router
... (2 Replies)
I am planning to do solaris 11 global zone patching having solaris 10 branded zone. I have a doubts on step 8 specially
Can someone clear my step 8 doubts or if anything wrong between step 1 to step 9 please correct that also as I have pretty good idea about Step 10 mean patching in solaris 10... (2 Replies)
I can't compile anything, the final make error says "Command failed for target `install-recursive'", but I am not able to identify the root cause of that error, I tried with cc, gcc 4.5, also gcc 5.2, using make, using gmake 3.82, ld 5.11, gld 2.31... and I am totally stuck yet... please help, to... (4 Replies)
Am new on Solaris
If I compare with ESXi default timezone is UTC and we have to set BIOS timezone to UTC too .
What we follow and best practice in Solaris Sparc servers .
Thanks in advance . (2 Replies)
Have 2 nics on physical system
net0 phys 1500 up --
net1 phys 1500 up --
1. I want to create a link aggregation with LACP enabled with above 2 nics
2. Create port-group(Like we create on ESXi) with VLAN-ID 2141
3. And assign this... (0 Replies)
I have configured three zones on Solaris-11. These are non-global zones contain Solaris-11 only. One of the zone is not booting up, complaining about IP address in use, while it is not.
root@tdpdmsp02 # zoneadm list -icv
ID NAME STATUS PATH BRAND IP... (3 Replies)
Hi All ,
I try to install some packages in my global zone...
On the execution of the installion of the script it quits by saying the error
"Non global zone check failed"
Kindly help me in this regard
Thanks in advance,
jeganr (7 Replies)