Changing the HostID on Linux

The hostid on some systems, like Suns, is set in the hardware and uniquely identifies the system. On Linux, the hostid is more of a suggestion than a hard-and-fast rule. It's usually generated at install time, and can be changed with a few lines of python code:

#!/usr/bin/python
from struct import pack
hostid = pack("I",int("0x210a2500",16))
filename = "/etc/hostid"
open(filename,"wb").write(hostid)

You can check this then with the hostid command.

  # hostid
  210a2500

Protip: It's always a good idea to back up /etc/hostid first, just in case.

This can help workaround issues with applications like flexlm, that naively assume that hostid is in some way significant on Linux.

blog comments powered by Disqus