2

Solaris 11.

I've found that the zone boot command (e.g. zoneadm -z myzone boot) returns before the zone is fully booted/configured. The problem is related to freshly created zones.

More precisely what I do is this:

zoneadm -z myzone install -c mytemplate.xml
zoneadm -z myzone boot

When the second line finishes the system reports that the zone is in running state (which is technically true). In reality the zone is still busy doing manifest importing, i.e. doing initial configuration. Therefore at this point there's no guarantee that the artifacts defined in mytemplate.xml (such as users) will actually exist. This will typically take an additional minute or two.

This is a problem in my scripted creation of zones. I can obviously do a very long sleep and hope that by then the zone has finished its configuration tasks but that seems like a stupid solution. I wouldn't know for how long to wait.

Is there a way for my script to ensure that the zone's background configuration processes have completed before I continue ?

2 Answers 2

2

One way would be to use a while loop that runs

zlogin <zone> svcs -xv

or

zlogin <zone> svcs svc:/milestone/multi-user | grep online

and uses the output from one of those commands to determine whether the zone is ready, or whether to sleep a little longer.

The second command might be better if you regularly have failed services that need manual intervention to fix, as your script might hang otherwise. You should probably also have a time-out value so that your script doesn't wait forever for a non-global that never meets your condition.

In my testing, I expected a non-zero exit code when the output from running svcs -xv outputted failed services, but the exit code is zero, so do be aware of this. For this reason if you use the zlogin <zone> svcs -xv command and you want to test the exit code, you may be better off running zlogin <zone> svcs -xv | grep State. A non-zero exit code to that will indicate no failed services and a zero exit code will indicate some failed services.

5
  • Thanks for this. I'll test it out. I thought it would be something like that. Strange that this is needed. Surely I cannot be the only one trying to script zone creation?
    – peterh
    Aug 11, 2014 at 4:59
  • I've scripted zone creation before, but always got stuck by needing to do a zlogin -C to get a zone console so that I can configure the name service, root password etc which I have done manually before running the script on the zone locally that configures users etc. I'm assuming that your -c paramter avoids the need for this by using a template which will be helpful for me to know in the future. I don't see the -c option in the Solaris 10 version of zoneadm which is all I have access to at the moment.
    – Warwick
    Aug 11, 2014 at 5:10
  • Yep. That's correct. What you should know is that -c is a brand specific option, so you cannot find it in the man page for zoneadm, rather in the man page for solaris(5). Still, as you say, this is Solaris 11. (you really should be upgrading, the advantages are many)
    – peterh
    Aug 11, 2014 at 5:50
  • Oh, I know. My previous role (where I write the scripts) was a Solaris 11 environment. My current role which ends in two weeks is Solaris 10. I know which I prefer :-)
    – Warwick
    Aug 11, 2014 at 5:52
  • Tested it. Works!. I'll mark this as the answer .. although I'm still open to other suggestions. :-)
    – peterh
    Aug 11, 2014 at 12:46
0

After a freshly created zone under Solaris 10, I usually needed to login to the zone's console to answer a few questions. zlogin -C <zonename>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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