How to Change the Hostid of a Sun Solaris Machine?

Solaris

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.

http://www.easycalculation.com/hex-converter.php

Hexdecimal: 800a1b2c
Decimal: 2148145964

(2) Then, divide the decimal number to three parts:
2148
1459
64

(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
36 34

http://www.easycalculation.com/ascii-hex.php

You need to pad 0s to the 3rd part. So it will become:
32313438
31343539
36340000

Step 2: Save your original Hostid:
cd /etc
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:
# 32313438
# 31343539
# 36340000
# The following code will apply the new Hostid
adb -w -k /dev/ksyms /dev/mem </dev/null
hw_serial/W 0x32313438
hw_serial+4/W 0x31343539
hw_serial+8/W 0x36340000
END


Step 4: If you want to make the new hostid effective without reboot the machine, just type:
#sh S20sysetup

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.

标签: none

已有 5 条评论

  1. I can't change, my solaris getting error like this :

    # sh /etc/rc2.d/S20sysetup
    physmem 7f78e
    /etc/rc2.d/S20sysetup: lt: not found
    /etc/rc2.d/S20sysetup: /dev/null: cannot execute
    /etc/rc2.d/S20sysetup: hw_serial/W: not found
    /etc/rc2.d/S20sysetup: hw_serial+4/W: not found
    /etc/rc2.d/S20sysetup: hw_serial+8/W: not found
    /etc/rc2.d/S20sysetup: END: not found

    Do you have any solution?
    Thank you very much

  2. Brent Chivers Brent Chivers

    The line in step 3 where you actually run adb is garbled; the redirection I think you intended isn't there.

    But I used this as a starting point to write a script. I provide the desired hostid as an argument, validate it (length, hex-digits), convert it to decimal with bc, convert that to ascii-hex with sed, and then do the deed with adb. (We had to replace hardware, and it broke a license.)

    Thanks!

  3. I tried these steps but didn't work

  4. Care to fill in some blanks Brent?

    What would the correct adb syntax be?

    Finding similar issues with adb - with an identical root cause - ie original machine died and licence check fails on the replacment machine.

    @Brent Chivers

  5. Richard Rojas Richard Rojas

    Update first line like this and it will work.

    adb -w -k /dev/ksyms /dev/mem <<END
    hw_serial/W 0x32313438
    hw_serial+4/W 0x31343539
    hw_serial+8/W 0x36340000
    END

添加新评论