Renaming Solaris Container

Let’s say you made a mistake and you need to rename Solaris container. Start off by moving container’s zonepath. This will change zonepath for container oldzone to /export/home/zones/newzone:

bash-3.00# zoneadm -z oldzone move /export/home/zones/newzone
bash-3.00# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   3 ns2              running    /export/home/zones/ns2         native   shared
   4 nis2             running    /export/home/zones/nis2        native   shared
   - gold             installed  /export/home/zones/gold        native   shared
   - oldzone          installed  /export/home/zones/newzone     native   shared

Next you need to change the name of oldzone container:

bash-3.00# zonecfg -z oldzone
zonecfg:oldzone> set zonename=newzone
zonecfg:newzone> info
zonename: newzone
zonepath: /export/home/zones/newzone
brand: native
autoboot: false
bootargs: -m verbose
pool:
limitpriv:
scheduling-class: FSS
ip-type: shared
[cpu-shares: 5]
net:
        address: 10.1.1.1
        physical: aggr1
capped-memory:
        physical: 512M
        [swap: 1G]
attr:
        name: comment
        type: string
        value: "Old Server Zone"
rctl:
        name: zone.cpu-shares
        value: (priv=privileged,limit=5,action=none)
rctl:
        name: zone.max-swap
        value: (priv=privileged,limit=1073741824,action=deny)
zonecfg:newzone> commit
zonecfg:newzone> exit

To keep things tidy, you might want to change container’s comment (see above) to reflect the new purpose of the container. That’s it:

bash-3.00# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   3 ns2              running    /export/home/zones/ns2         native   shared
   4 nis2             running    /export/home/zones/nis2        native   shared
   - gold             installed  /export/home/zones/gold        native   shared
   - newzone          installed  /export/home/zones/newzone     native   shared