You can use this script to configure and boot multiple zones on your system. The script takes the following parameters:
The number of zones to be created
The zonename prefix
The directory to use as the base directory
You must be the global administrator in the global zone to execute the script. The global administrator has superuser privileges in the global zone or assumes the Primary Administrator role.
#!/bin/ksh # # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" if [[ -z "$1" || -z "$2" || -z "$3" || -z "$4" ]]; then echo "usage: $0 <#-of-zones> <zonename-prefix> <basedir> <template zone>" exit 2 fi if [[ ! -d $3 ]]; then echo "$3 is not a directory" exit 1 fi state=`zoneadm -z $4 list -p 2>/dev/null | cut -f 3 -d ":"` if [[ -z "$state" || $state != "installed" ]]; then echo "$4 must be an installed, halted zone" exit 1 fi template_zone=$4 nprocs=`psrinfo | wc -l` nzones=$1 prefix=$2 dir=$3 ip_addrs_per_if=`ndd /dev/ip ip_addrs_per_if` if [ $ip_addrs_per_if -lt $nzones ]; then echo "ndd parameter ip_addrs_per_if is too low ($ip_addrs_per_if)" echo "set it higher with 'ndd -set /dev/ip ip_addrs_per_if <num>" exit 1 fi i=1 while [ $i -le $nzones ]; do zoneadm -z $prefix$i clone $template_zone > /dev/null 2>&1 if [ $? != 0 ]; then echo configuring $prefix$i F=$dir/$prefix$i.config rm -f $F echo "create -t SUNWlx" > $F echo "set zonepath=$dir/$prefix$i" >> $F zonecfg -z $prefix$i -f $dir/$prefix$i.config 2>&1 | \ sed 's/^/ /g' else echo "skipping $prefix$i, already configured" fi i=`expr $i + 1` done i=1 while [ $i -le $nzones ]; do j=1 while [ $j -le $nprocs ]; do if [ $i -le $nzones ]; then if [ `zoneadm -z $prefix$i list -p | \ cut -d':' -f 3` != "configured" ]; then echo "skipping $prefix$i, already installed" else echo installing $prefix$i mkdir -pm 0700 $dir/$prefix$i chmod 700 $dir/$prefix$i zoneadm -z $prefix$i install -s -d /path/to/ISOs > /dev/null 2>&1 & sleep 1 # spread things out just a tad fi fi i=`expr $i + 1` j=`expr $j + 1` done wait done i=1 para=`expr $nprocs \* 2` while [ $i -le $nzones ]; do date j=1 while [ $j -le $para ]; do if [ $i -le $nzones ]; then echo booting $prefix$i zoneadm -z $prefix$i boot & fi j=`expr $j + 1` i=`expr $i + 1` done wait done |