Change SmartOS hostname

2014, Aug 10  —  ...

As my adventures with Joyent's SmartOS continue, every so often a little thing will bug me. For example when you provision a SmartOS instance on Joyent, the hostname defaults to the same as the UUID. It makes sense but it's not very human readable so I sought out the proper way to change the hostname of the instance. Thanks to johngrasty_ on the #smartos IRC channel, I have a solution:

$ hostname "the-new-hostname" && hostname > /etc/nodename

Thanks to Lloyd Dewolf, who left a comment, we have another likely better option:

$ sudo sm-set-hostname the-new-hostname

Updated: April 18, 2015 with another method to set hostname