Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a Solaris server which has two zones on it. I need to remove one zone and change the remaining zone into the server's main operating system.

What is the best way to do this?

I was thinking of backing up a the zone that needs to be kept, reinstalling the OS on the server and then restoring the files from the backed up zone. Are there easier ways?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

I cannot think of an easy way to to this. You want to be very careful, though, because local zones differ from global zones. You don't want to just restore the local zone's entire directory structure over the global zone. That could have unintended consequences.


Some questions to guide you:

1. Is the local zone a full root zone, or is it a sparse root zone?

If the zone is a sparse root zone, then it's inheriting directories like /usr and /sbin, etc. You can tell this by looking in /etc/zones/<zonename>.xml.

2. Are there particular reasons why you want to make the local zone into the global zone?

Do you have particular applications installed? user configurations? Is there a reason why having the local zone remain as a local zone is not an option?

3. Is your server a ZFS root system, or UFS root?

If UFS, is there enough free disk space to allow you to use Live Upgrade?


If it's a sparse root zone, you may be in luck. Since a sparse root zone inherits all the "Solaris specific" filesystems from the global, then all the package and patch databases will be in sync, and then you're really only looking at the differences between the custom data from the local zone to the global zone. Things like home directories, /etc/passwd, /etc/shadow, etc.

Here's how I would do it. My examples will not be very verbose, due to the fact that there are almost too many considerations involved with individual systems, and options, and variables found in the wild. Instead they're just based on my own experience with systems that use ZFS root. You should be able to translate these examples into the syntax specific to your own needs with some light man page reading.

1 - Create a new boot environment.

for example: lucreate -n s10-2011-11-23

  • YMMV depending on whether you're system is UFS or ZFS, and whether your zones are installed as part of the local filesystem, or in their own individual zpool.

2 - Mount the new boot environment

for example: lumount s10-2011-11-23

  • this will mount the new boot environment on /.alt.s10-2011-11-23

3 - Sync the filesystems you want

for example, if you only need /opt and /export/home from the local zone:

rsync -avHP /<zonepath>/root/opt/ /.alt.s10-2011-11-23/opt/
rsync -avHP /<zonepath>/root/export/home/ /.alt.s10-2011-11-23/export/home/
  • *this is your chance to copy any data from the zone path to the global zone filesystems.

4 - Unmount the new boot environment

for example: luumount s10-2011-11-23

    • this unmounts the /.alt.s10-2011-11-23 directory. You need to do this to activate the new boot environment in the next step.

5 - Activate the new boot environment

for example: luactivate s10-2011-11-23

  • Copy and save the warnings printed out here. You may need them to recover

6 - Reboot into the new boot environment

for example: init 6

  • *now the new boot environment is created, synced with the content you want, and active. Now you just need to reboot into it. You cannot use the reboot command to do that. You MUST use the init or shutdown commands. I recommend just using init 6.

The nice thing about using live upgrade is that you can always boot back into the previous boot environment following the steps you copied and saved in step 5.

This means if something doesn't work, or goes horribly wrong, you can recover at least to the state of your system prior to making any changes.

We always use live upgrade when patching or making changes to systems, simply for the ease of rollback.

share|improve this answer
    
Thanks for the detailed post. Its given me alot to think about. –  AndyM Nov 24 '11 at 11:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.