Prefetch Technologies // Keeping your cache lines cozy

Changing the zone path of a pre-existing zone

So, the hostname of one of our zones changed, and we create ZFS file systems for the zones using path/zonename

Easy enough of a fix...

$ zoneadm list -cv
ID NAME             STATUS     PATH                           BRAND
IP
0 global           running    /                              native
shared
1 blah         running    /local2/data/zones/blah    native   shared
5 blah1          running    /local/data/zones/blah1      native
shared
$ zonecfg -z blah1
zonecfg:blah1> set zonename=blah2
blah1: Zone state is invalid for the requested operation
So lets shut down the zone and change the zone name.
$ zoneadm -z blah1 halt
$ zonecfg -z blah1 info
zonename: blah1
zonepath: /local/data/zones/blah1
$ zonecfg -z blah1
zonecfg:blah1> set zonename=blah2
zonecfg:blah2> verify
zonecfg:blah2> commit
zonecfg:blah2> exit

So now that we've changed the zone name, I also wanted to update the ZFS file system to reflect the new hostname...

$ zfs rename pool0/local/data/zones/blah1
pool0/local/data/zones/blah2

Easy enough. Lets boot the zone.

$ zoneadm list -cv
ID NAME             STATUS     PATH                           BRAND
IP
0 global           running    /                              native
shared
1 blah         running    /local2/data/zones/blah    native   shared
- blah2    installed  /local/data/zones/blah1      native   shared
$ zoneadm -z blah2 boot
zoneadm: /local/data/zones/blah1: No such file or directory
could not verify zonepath /local/data/zones/blah1 because of the above
errors.
zoneadm: zone blah1 failed to verify

DOH. Forgot to change the zone path.. So lets go fix this...

$ zonecfg -z blah2
zonecfg:blah2> set zonepath=/local/data/zones/blah2
Zone blah2 already installed; set zonepath not allowed.

WHAT?!?! Come on now zonecfg, this shouln't be brain surgery....

So, lets go poke at the source of truth -- /etc/zones.

$ grep blah1
index:blah2:installed:/local/data/zones/blah1:6b9891a3-7029-ef67-9581-aa01475c9b
6e
blah2.xml:<zone name="blah2" zonepath="/local/data/zones/blah1"
autoboot="true">

So, go and edit blah2.xml to change the zone path, as well as index. (Make backup copies of these before doing so please)

Once the modifications were done, I was able to boot up the zone with the newly changed zonepath.

$ zoneadm list -cv
ID NAME             STATUS     PATH                           BRAND
IP
0 global           running    /                              native
shared
1 blah         running    /local2/data/zones/blah    native   shared
- blah2    installed  /local/data/zones/blah2 native   shared
$ zoneadm -z blah2 boot
$ zoneadm list -cv
ID NAME             STATUS     PATH                           BRAND
IP
0 global           running    /                              native
shared
1 blah         running    /local2/data/zones/blah    native   shared
6 blah2    running    /local/data/zones/blah2 native   shared
root@db@blah-global:/etc/zones#zlogin blah2
[Connected to zone 'blah2' pts/1]
Last login: Fri Mar 27 17:14:03 from blah-global
Sun Microsystems Inc.    SunOS 5.10    Generic    January 2005
#

Sun, could we please extend zonecfg to do this for us? The header of /etc/zones/index is scary.

$ cat /etc/zones/index
## Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
## Use is subject to license terms.
#
## ident "@(#)zones-index        1.2     04/04/01 SMI"
#
## DO NOT EDIT: this file is automatically generated by zoneadm(1M)
## and zonecfg(1M).  Any manual changes will be lost.
#