Sponsored Content
Operating Systems Solaris Modify the Hostid in a Solaris 11 Global Zone running on VMWare Post 302914464 by gull04 on Tuesday 26th of August 2014 04:44:29 AM
Old 08-26-2014
Change Hostid Script.

Hi Folks'

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

This User Gave Thanks to gull04 For This Post:
 

9 More Discussions You Might Find Interesting

1. Solaris

Solaris Zone : Non global Zone check failed

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)
Discussion started by: jegaraman
7 Replies

2. Solaris

Is there two different kernel`s running in global and non global zone?

Hi All, I want to know for non global zone there will be different kernal running? (1 Reply)
Discussion started by: vijaysachin
1 Replies

3. Solaris

Solaris 10 local zone on Solaris 11 global zone

Hi, A quick question: Can Solaris 10 local zones be moved to a Solaris 11 global zone and work well? Thank you in advance! (5 Replies)
Discussion started by: aixlover
5 Replies

4. Solaris

Not able to start non global zone on Solaris 11

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)
Discussion started by: solaris_1977
3 Replies

5. Solaris

Solaris non-global zone network vlan

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)
Discussion started by: Shirishlnx
0 Replies

6. Solaris

Solaris 11 global zone timezone

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)
Discussion started by: Shirishlnx
2 Replies

7. Programming

I can't compile (gcc) in Solaris 11.3 non global zone

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)
Discussion started by: sugar222
4 Replies

8. Solaris

Solaris 11 Global zone patching having Solaris 10 branded zone

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)
Discussion started by: amity
2 Replies

9. Solaris

Solaris 11 zone has no external network access (except to Global Zone)

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)
Discussion started by: GazinLincoln
2 Replies
All times are GMT -4. The time now is 01:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy