It is generally not recommended to change the zone path of an installed Solaris zone . Yet, in some situations we want to do exactly that. You can use the same technique as you would use to move the whole zone from one system to another. And with a few extra commands, you can change the name and hostname of the zone as well.

Let me show you how.

Preparing the Solaris zone

First, you need to shut down the system. Either use the shutdown sub-command or the halt sub-command.

By running the shutdown scripts inside the zone, you shut it down in a clean manner. Use the following command to do this:

# zlogin <my-zone> shutdown

OR, to halt the zone, bypassing the shutdown scripts inside the zone, use the following command:

# zoneadm -z <my-zone> halt

Now, detach the zone as the first step to prepare for the change of directory name.

# zoneadm -z <my-zone> detach

Change the zone configuration

This leaves the Solaris zone in the configured state and removes it from the zoneadm list view. This way, we will be able to change the configuration of the zone to point to the new zone path directory. We will also be able to rename the zone if we desire to do that.

# mv <zonepath> <new_zonepath>
# zonecfg -z <my-zone>
zonecfg:my-zone> set zonename=<new-zonename>
zonecfg:new-zonename> set zonepath=<new_zonepath>
zonecfg:new-zonename> verify
zonecfg:new-zonename> commit
zonecfg:new-zonename> exit

What I did now was enter the configuration mode of the zone, and I renamed the zone to the desired name. I also set the new zone path directory I wanted to use before I committed the changes. Then, I exited configuration mode.

Finishing touches

The next thing to to do is attach the zone and boot it up. After that, I can enter the zone and change the hostname to reflect the zone name. This step is optional, but in my company we like to do it this way.

# zoneadm -z <new-zonename> attach
# zoneadm -z <new-zonename> boot

Ok, so far so good. Now, enter the zone (zlogin new-zonename) and edit the hostname of the changed zone. Do this in the following files:

/etc/hosts
/etc/nodename

On all Solaris systems, the text editor vi installs by default. You can use vi to edit these files, or you can use another editor if you have installed another one.

Finally, to activate the new hostname and nodename, reboot the zone from the global zone.

# zoneadm -z <new-zonename> reboot

That’s all there is to it. Enjoy your re-configured zone.

If you are unable to boot your zone, check the log files and configuration files. Also check your zone path for any errors. A simple typo when specifying the zone path might cause problems booting the zone.

Espen Acklam Solberg

Espen Acklam Solberg is a system administrator with over 25 years of experience. He has worked in the telecom industry, in the aviation industry and for the government, managing critical infrastructure. His expertise lies in linux systems, virtualization, storage, backup, scripting and automation.He also runs his own print shop, producing branded merchandise for businesses and individuals, and is fond of gadgets and new technology.

This Post Has 4 Comments

  1. Sudhakar

    Zone root file system is on the global zone root file system.Because of that root file system consumption is always high.We want to move zone file system to other free partition(Slice 5)please tell me the procedure to do it.

  2. Rafael

    Good tutorial buddy thanks

  3. Zack

    Do you have to move other existing filesystems too?

Leave a Reply