Thursday, September 5, 2013

Faster Solaris 10 Zone Creation

These are my notes on a faster way creating Solaris 10 zones. If you're not familiar with Solaris 10 zones might I suggest you first read my notes on creating Solaris 10 zones. These notes will go over making a whole root zone with a shared network interface. For the purpose of this guide. We will use the hostname, earth for our Global zone (host). We will create a zone named moon.

Create the zone
root@earth> zonecfg -z moon "create -b; set zonepath=/export/zones/test; set autoboot=true; add net; set physical=e1000g0; set address=10.1.1.232/24; end; verify; commit; exit"

Alternately you can put all the sub-commands into a file.

Install zone
root@earth> zoneadm -z moon  install
A ZFS file system has been created for this zone.
Preparing to install zone moon.
Creating list of files to copy from the global zone.
Copying 82181 files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize 783 packages on the zone.
Initialized 783 packages on zone.
Zone moon is initialized.
Installation of 1 packages was skipped.
The file contains a log of the zone installation.

Check the zone (Optional)
root@earth> zoneadm list -cv
ID NAME     STATUS      PATH                            BRAND      IP
0   global        running        /                                 native          shared
-    moon        installed       /export/zones/moon     native          shared

Make an answer file
You must create the sysidcfg configuration file and put it in the zone's /etc directory. For example: /export/zones/moon/root/etc/. This must be done after the zone install but before the you boot the zone. Below is an example of a sysiccfg that worked for my setup.

system_locale=en_US
timezone=US/Eastern
terminal=vt100
timeserver=localhost
root_password=$1$w/3YH4kq$R3Tk2lHWRIL2FiiJ2eJqQ1
network_interface=PRIMARY {hostname=moon
                     default_route=NONE
                     ip_address=10.1.1.232
                     netmask=255.255.254.0
                     protocol_ipv6=no}
nfs4_domain=sun
security_policy=NONE
name_service=NONE


Get remote console on the zone
Run this command in a different terminal.
root@earth> zlogin -C moon
Note -C option gives you a persistent console. To get back to the global zone type .~

Boot the zone
root@earth> zoneadm -z moon boot
After you run the command above, look at the other terminal where you ran zlogin. You should see the zone booting up. After the zone boots up, you should see a login prompt. If instead the setup process starts up, then there is an error with the sysidcfg file. I that case you will have to delete you zone. Check out my notes on how to uninstall and delete a zone. If there are no issues then your done.

I hope this was helpful to someone. If you have any questions or comments please post them below.

Related posts on this blog:
Creating Solaris 10 zones
Uninstall and delete a zone