How to Change the Hostid of a Sun Solaris Machine?
The Hostid is a globally unique ID for a Sun Solaris Machine. Sometimes, you need to change this hostid for whatever purpose. For example, you current machine is down for hardware failure and you purchased a new machine. However, all your current running software are based on this old hostid, and you must bring the new machine up within a very short time. The quick solution is to change the new machine's hostid to be as same as the old one.
There are several ways to do so, including using a program to flush NVRAM which will change the hostid permanently. I did following experiment to change the Hostid in a Solaris 10 machine temperately. It adds several lines in the /etc/rc2.d/S20sysetup file. If you want to restore the original hostid, you just need to remove these lines and reboot the machine.
My environment is:
# uname -a
SunOS myhostname 5.10 Generic_127111-11 sun4v sparc SUNW,SPARC-Enterprise-T5120
Step 1: Calculate your new Hostid
(1) If you want to change your hostid to 800a1b2c (hexdecimal format), you need to calculate its decimal first. You can use following online calculator to do this.
(2) Then, divide the decimal number to three parts:
(3) You treat the above 3 parts as string combined by ASCII Characters. Use following calculator to get the HEX value:
32 31 34 38
31 34 35 39
You need to pad 0s to the 3rd part. So it will become:
Step 2: Save your original Hostid:
cat hostid > hostid.orig
Step 3: Change the /etc/rc2.d/S20sysetup file
At the bottom of this file, add following code:
# Change Host ID to Hexdecimal: 800a1b2c
# It's Decimal Value: 2148145964
# Divide to 3 parts: 2148 1459 64
# Hex value of the above ASCII Characters:
# 32 31 34 38
# 31 34 35 39
# 36 34
# After padding:
# The following code will apply the new Hostid
adb -w -k /dev/ksyms /dev/mem </dev/null
Step 4: If you want to make the new hostid effective without reboot the machine, just type:
Otherwise, you can reboot the machine. If you want restore the original factory hostid, you can just comment out the above several lines of code in S20sysetup file.