Powered By Blogger

2011/12/01

Renaming Solaris Local Zone


This is just a short post to describe how to rename a Local Zone on Solaris. Initially, zonename property is  also used as the Local Zone hostname, changes are applied from the Global Zone.
From the Global Zone, Change the zonename property using zonecfg as seen below. The local zone to rename must be stopped while performing this change. My old zonename was "myzone1" and my new name is "myzone2"

root@gz # zoneadm -z myzone1  halt
root@gz # zonecfg -z myzone1      
zonecfg:myzone1> set zonename=myzone2
zonecfg:myzone2> info
zonename: myzone2
zonepath: /zpool_myzone1/myzone1
brand: native
autoboot: false
bootargs: 
pool: 
scheduling-class: 
ip-type: shared
hostid: 
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
net:
        address: 192.168.25.200/24
        physical: nxge5
        defrouter: 192.168.25.1
zonecfg:myzone2> verify
zonecfg:myzone2> commit
zonecfg:myzone2> exit


#Modify the /etc/nodename and set the new hostname      
#/zpool_myzone1/myzone1 is my zonepath
root@gz # cat /zpool_myzone1/myzone1/root/etc/nodename
myzone2 
#Modify the /etc/hosts and set the new hostname      
root@gz # cat /zpool_myzone1/myzone1/root/etc/hosts #
# Internet host table
#
::1     localhost
127.0.0.1       localhost
192.168.25.200    myzone2  loghost   
root@gz # zoneadm -z myzone2 boot
root@gz # zlogin myzone2
root@myzone2 # hostname
myzone2

Done.