Tuesday, October 11, 2011

How to change hostid for solaris X86 system

change hostid for solaris X86 system:


Step 1:take the backup of current hostid

echo `hostid` > /etc/hostid_bkp

Step2: Change the new hostid hex value in decimal.

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

exp : 1dd01266

5001 7546 2

Step 3: Change decimal string in to ascii/hexa

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



exp :

35 30 30 31

37 35 34 36

32 00 0



Step 4: Run below command

exp : echo "hw_serial/v 35 30 30 31 37 35 34 36 32 00 0"  | mdb –kw



Step 4:

Add above command in /etc/rc2.d/S20sysetup



Step 5: Reboot the server

8 comments:

  1. I could not get the changes done, I have even used the same commands as mentioned above in the example with the same values to test but the hostid kept appearing the same.

    echo "hw_serial/v 35 30 30 31 37 35 34 36 32 00 0"
    mdb –kw

    ReplyDelete
    Replies
    1. echo "hw_serial/v 35 30 30 31 37 35 34 36 32 00 0" | mdb –kw

      run this command you have missed | between both command

      Delete
  2. Here's a script to do the whole thing. Thanks for providing this info.

    #!/usr/bin/bash

    if [ $# -ne 1 ]
    then
    echo "Usage: changehostid NEWHOSTID"
    exit 1
    fi

    ascii=`echo $((0x$1)) | od -t x1 | head -1 | cut -f2-100 -d" "`
    echo "hw_serial/v "${ascii:0:$((${#ascii}-2))}"00 0" | mdb -kw
    echo "hostid is now set to: "`hostid`;echo " "

    ReplyDelete
  3. "bash-3.2# echo "hw_serial/v 35 30 30 31 37 35 34 36 32 00 0" | mdb –kw
    mdb: failed to open –kw: No such file or directory"

    When i run your command, it have a fail message like this.
    How could i make it take effect?

    ReplyDelete
  4. I tried again, although this command couldn't run in the console but after add it to /etc/rc2.d/S20sysetup and run ./S20sysetup, it works!

    Thanks!

    ReplyDelete
  5. Placing descibed above hostid modification into rc.d scripts didn't work for me.
    zpool was complaining that hostid is different anyway. I think zpool was starting before the rc.d script.

    I placed hosid modification script into /lib/svc/method/svc-hostid

    Now everything works fine. zpool doesn't complain.

    ReplyDelete