<chapter id="gdajn"><title>Configuring the <literal>lx</literal> Branded
Zone (Tasks)</title><highlights><para>This chapter describes how to configure an <literal>lx</literal> branded
zone on your x64 or x86 based system. The process is basically the same as
the procedure to configure a Solaris Zone. A few of the properties are not
needed to configure a branded zone.</para>
</highlights><sect1 id="gdbjd"><title>Planning and Configuring an <literal>lx</literal> Branded
Zone (Task Map)</title><para>Before
you set up your system to use zones, you must first collect information and
make decisions about how to configure the zones. The following task map summarizes
how to plan and configure an <literal>lx</literal> zone.</para><informaltable frame="all"><tgroup cols="3" colsep="1" rowsep="1"><colspec colwidth="33*"/><colspec colwidth="33*"/><colspec colwidth="33*"/><thead><row><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>For Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>Plan your zone strategy.</para>
</entry><entry><itemizedlist><listitem><para>Determine which applications you want to run in zones.</para>
</listitem><listitem><para>Assess the availability of disk space to hold the files in
the zone.</para>
</listitem><listitem><para>If you are also using resource management features, determine
how to align the zone with the resource management boundaries.</para>
</listitem><listitem><para>If you are using resource pools, configure the pools if necessary.</para>
</listitem>
</itemizedlist>
</entry><entry><para>See <olink targetptr="gcxax" remap="internal">System and Space Requirements</olink> and <olink targetptr="rmpool-114" remap="internal">Resource Pools Used in Zones</olink>.</para>
</entry>
</row><row><entry><para>Determine the name and the path for the zone.</para>
</entry><entry><para>Decide what to call the zone based on the naming conventions. A path
on a Zetabyte File System (ZFS) is recommended. When the source <literal>zonepath</literal> and the target <literal>zonepath</literal> both reside on ZFS and
are in the same pool, the <command>zoneadm</command> <literal>clone</literal> command
automatically uses ZFS to clone the zone.</para>
</entry><entry><para>See <olink targetptr="gdahx" remap="internal">Resource and Property Types</olink> and <olink targetdoc="zfsadmin" remap="external"><citetitle remap="book">Solaris ZFS Administration Guide</citetitle></olink>.</para>
</entry>
</row><row><entry><para>Obtain or configure IP addresses for the zone.</para>
</entry><entry><para>Depending on your configuration, you must obtain at least one IP address
for each non-global zone that you want to have network access.</para>
</entry><entry><para>See <olink targetptr="z.conf.start-4" remap="internal">Determine the Zone Host Name and
Obtain the Network Address</olink> and <olink targetdoc="sysadv3" remap="external"><citetitle remap="book">System Administration Guide: IP Services</citetitle></olink>.</para>
</entry>
</row><row><entry><para>Determine if you want to mount file systems in the zone.</para>
</entry><entry><para>Review your application requirements.</para>
</entry><entry><para>See <olink targetptr="z.config.ov-7" remap="internal">File Systems Mounted in Zones</olink> for
more information.</para>
</entry>
</row><row><entry><para>Determine which network interfaces should be made available in the zone.</para>
</entry><entry><para>Review your application requirements.</para>
</entry><entry><para>See <olink targetptr="z.admin.ov-12" remap="internal">Shared-IP Network Interfaces</olink> for
more information.</para>
</entry>
</row><row><entry><para>Determine whether you must alter the default set of non-global zone
permissions.</para>
</entry><entry><para>Check the set of privileges: default, privileges that can be added and
removed, and privileges that cannot be used at this time.</para>
</entry><entry><para>See <olink targetptr="gdahx" remap="internal">Resource and Property Types</olink> and <olink targetptr="z.admin.ov-18" remap="internal">Privileges in a Non-Global Zone</olink>.</para>
</entry>
</row><row><entry><para>Configure the zone.</para>
</entry><entry><para> Use <command>zonecfg</command> to create a configuration for the zone.</para>
</entry><entry><para>See <olink targetptr="gdbji" remap="internal">How to Configure, Verify, and Commit the
lx Branded Zone</olink>.</para>
</entry>
</row><row><entry><para>Verify and commit the configured zone.</para>
</entry><entry><para>Determine whether the resources and properties specified are valid on
a hypothetical system.</para>
</entry><entry><para>See <olink targetptr="gdbji" remap="internal">How to Configure, Verify, and Commit the
lx Branded Zone</olink>.</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="gcziw"><title>How to Configure the <literal>lx</literal> Branded
Zone</title><para>You use the <command>zonecfg</command> command described
in the <citerefentry><refentrytitle>zonecfg</refentrytitle><manvolnum>1M</manvolnum></citerefentry> man page to perform the following actions.</para><itemizedlist><listitem><para>Create the zone configuration</para>
</listitem><listitem><para>Verify that all required information is present</para>
</listitem><listitem><para>Commit the non-global zone configuration</para>
</listitem>
</itemizedlist><tip><para>If you know you will be using CDs or DVDs to install applications
in an <literal>lx</literal> branded zone, use <literal>add</literal> <literal>fs</literal> to
add read-only access to CD or DVD media in the global zone when you initially
configure the branded zone. A CD or DVD can then be used to install a product
in the branded zone. </para>
</tip><para>While configuring a zone with the <command>zonecfg</command> utility,
you can use the <literal>revert</literal> subcommand to undo the setting for
a resource. See <olink targetptr="z.conf.start-30" remap="internal">How to Revert a Zone Configuration</olink>.</para><para>A script to configure multiple zones on your system is provided in <olink targetptr="gdbkd" remap="internal">Script to Configure Multiple lx Branded Zones</olink>.</para><para>To display a non-global zone's configuration, see <olink targetptr="gdbiv" remap="internal">How to Display the Configuration of a Branded Zone</olink>.</para><tip><para>After you have configured the branded zone, it is a good idea to
make a copy of the zone's configuration. You can use this backup to restore
the zone in the future. As superuser or Primary Administrator, print the configuration
for the zone <literal>lx-zone</literal> to a file. This example uses a file
named <literal>lx-zone.config</literal>.</para><screen>global# <userinput>zonecfg -z lx-zone export > lx-zone.config</userinput></screen><para>See <olink targetptr="gbrmi" remap="internal">How to Restore an Individual Non-Global
Zone</olink> for more information.</para>
</tip><task id="gdbji"><title>How to Configure, Verify, and Commit the <literal>lx</literal> Branded
Zone</title><tasksummary><para>Note that you cannot use <literal>lx</literal> branded zones on a Trusted
Solaris system where labels are enabled. The <command>zoneadm</command> command
will not verify the configuration.</para><para>You must be the global administrator in the global zone to perform this
procedure.</para>
</tasksummary><procedure><step id="gdbkr"><para>Become superuser, or assume the Primary Administrator
role.</para><para>To create the role and assign the role to a user, see <olink targetdoc="sysadv1" targetptr="smcover-95" remap="external"><citetitle remap="section">Using the Solaris Management Tools With RBAC (Task Map)</citetitle> in <citetitle remap="book">System Administration Guide: Basic Administration</citetitle></olink>.</para>
</step><step id="gdbjf"><para>Set up a zone configuration with the zone name you
have chosen.</para><para>The name <literal>lx-zone</literal> is used in this
example procedure.</para><screen>global# <userinput>zonecfg -z lx-zone</userinput></screen><para>If this is the first time you have configured this zone, you will see
the following system message:</para><screen>lx-zone: No such zone configured
Use 'create' to begin configuring a new zone.</screen>
</step><step id="gdbkv"><para>Create the new <literal>lx</literal> zone configuration
by using the <literal>SUNWlx</literal> template.</para><screen>zonecfg:lx-zone> <userinput>create -t SUNWlx</userinput></screen><para>Alternatively, you can create a blank zone and explicitly set the brand:</para><screen>zonecfg:lx-zone> <userinput>create -b</userinput>
zonecfg:lx-zone> <userinput>set brand=lx</userinput></screen>
</step><step id="gdbiy"><para>Set the zone path, <literal>/export/home/lx-zone</literal> in
this procedure.</para><screen>zonecfg:lx-zone> <userinput>set zonepath=/export/home/lx-zone</userinput></screen>
</step><step id="gdbjn"><para>Set the autoboot value.</para><para>If set to <literal>true</literal>, the zone is automatically booted when the global zone is booted.
Note that for the zones to autoboot, the zones service <literal>svc:/system/zones:default</literal> must also be enabled. The default value is <literal>false</literal>.</para><screen>zonecfg:lx-zone> <userinput>set autoboot=true</userinput></screen>
</step><step><para>Set persistent boot arguments for a zone.</para><screen>zonecfg:lx-zone> <userinput>set bootargs="-i=<replaceable>altinit</replaceable>"</userinput></screen>
</step><step id="gdbiu"><para>If resource pools are enabled on your system, associate
a pool with the zone.</para><para>This example uses the default pool, named <literal>pool_default</literal>.</para><screen>zonecfg:lx-zone> <userinput>set pool=pool_default</userinput></screen><para>Because a resource pool can have an optional scheduling class assignment,
you can use the pools facility to set a default scheduler other than the system
default for a non-global zone. For instructions, see <olink targetptr="rmpool.task-22" remap="internal">How to Associate a Pool With a Scheduling Class</olink> and <olink targetptr="rmconfig-4" remap="internal">Creating the Configuration</olink>.</para>
</step><step><para>Revise the default set of privileges.</para><screen>zonecfg:lx-zone> <userinput>set limitpriv="default,proc_priocntl"</userinput></screen><para>The <literal>proc_priocntl</literal> privilege is used to run processes
in the real-time class.</para>
</step><step><para>Set five CPU shares.</para><screen>zonecfg:lx-zone> <userinput>set cpu-shares=5</userinput></screen>
</step><step><para>Add a memory cap.</para><screen>zonecfg:lx-zone> <userinput>add capped-memory</userinput></screen><substeps><step><para>Set the  memory cap.</para><screen>zonecfg:lx-zone:capped-memory> <userinput>set =50m</userinput></screen>
</step><step><para>Set the swap memory cap.</para><screen>zonecfg:lx-zone:capped-memory> <userinput>set swap=100m</userinput></screen>
</step><step><para>Set the locked memory cap.</para><screen>zonecfg:lx-zone:capped-memory> <userinput>set locked=30m</userinput></screen>
</step><step><para>End the specification.</para><screen>zonecfg:lx-zone:capped-memory> <userinput>end</userinput></screen>
</step>
</substeps>
</step><step id="gdbjg"><para>Add a file system.</para><screen>zonecfg:lx-zone> <userinput>add fs</userinput></screen><substeps><step id="gdbjw"><para>Set the mount point for the file system, <literal>/export/linux/local</literal> in this procedure.</para><screen>zonecfg:lx-zone:fs> <userinput>set dir=/export/linux/local</userinput></screen>
</step><step id="gdbjh"><para>Specify that <literal>/opt/local</literal> in the global
zone is to be mounted as <literal>/usr/local</literal> in the zone being configured.</para><screen>zonecfg:lx-zone:fs> <userinput>set special=/opt/local</userinput></screen><para>In the non-global zone, the <literal>/usr/local</literal> file system
will be readable and writable.</para>
</step><step id="gdbkf"><para>Specify the file system type, <literal>lofs</literal> in
this procedure.</para><screen>zonecfg:lx-zone:fs> <userinput>set type=lofs</userinput></screen><para>The type indicates how the kernel interacts with the file system.</para>
</step><step id="gdbkp"><para>End the file system specification.</para><screen>zonecfg:lx-zone:fs> <userinput>end</userinput></screen>
</step>
</substeps><para>This step can be performed more than once to add more than one file
system.</para>
</step><step id="gdbjk"><para>Add a network interface.</para><screen>zonecfg:lx-zone> <userinput>add net</userinput></screen><substeps><step id="gdbix"><para>Set the IP address in the form <replaceable>ip address
of zone</replaceable><literal>/</literal><replaceable>netmask</replaceable>.
In this procedure, <replaceable>10.6.10.233/24</replaceable> is used.</para><screen>zonecfg:lx-zone:net> <userinput>set address=10.6.10.233/24</userinput></screen>
</step><step id="gdbjq"><para>Set the physical device type for the network interface,
the <literal>bge</literal> device in this procedure.</para><screen>zonecfg:lx-zone:net> <userinput>set physical=bge0</userinput></screen>
</step><step><para>(Optional) Set the default router for the network interface, <literal></literal> in
this procedure.</para><screen>zonecfg:my-zone:net> <userinput>set defrouter=10.0.0.1</userinput></screen>
</step><step id="gdbjj"><para>End the specification.</para><screen>zonecfg:lx-zone:net> <userinput>end</userinput></screen>
</step>
</substeps><para>This step can be performed more than once to add more than one network
interface.</para>
</step><step id="gdbkm"><para>Enable an audio device present in the global zone in
this zone by using the <literal>attr</literal> resource type.</para><screen>zonecfg:lx-zone> <userinput>add attr</userinput></screen><substeps><step id="gdbkq"><para>Set the name to <literal>audio</literal>.</para><screen>zonecfg:lx-zone:attr> <userinput>set name=audio</userinput></screen>
</step><step id="gdbjo"><para>Set the type to <literal>boolean</literal>.</para><screen>zonecfg:lx-zone:attr> <userinput>set type=boolean</userinput></screen>
</step><step id="gdbiw"><para>Set the value to <literal>true</literal>.</para><screen>zonecfg:lx-zone:attr> <userinput>set value=true</userinput></screen>
</step><step id="gdbjs"><para>End the <literal>attr</literal> resource type specification.</para><screen>zonecfg:lx-zone:attr> <userinput>end</userinput></screen>
</step>
</substeps>
</step><step id="gdbkc"><para>Verify the zone configuration for the zone.</para><screen>zonecfg:lx-zone> <userinput>verify</userinput></screen>
</step><step id="gdbiz"><para>Commit the zone configuration for the zone.</para><screen>zonecfg:lx-zone> <userinput>commit</userinput></screen>
</step><step id="gdbka"><para>Exit the <command>zonecfg</command> command.</para><screen>zonecfg:lx-zone> <userinput>exit</userinput></screen><para>Note that even if you did not explicitly type <literal>commit</literal> at
the prompt, a <literal>commit</literal> is automatically attempted when you
type <literal>exit</literal> or an EOF occurs.</para>
</step>
</procedure><taskrelated-custom><title>Using Multiple Subcommands From the Command Line</title><tip><para>The <command>zonecfg</command> command also supports multiple subcommands,
quoted and separated by semicolons, from the same shell invocation.</para><screen>global# <userinput>zonecfg -z lx-zone "create -t SUNWlx; set zonepath=/export/home/lx-zone"</userinput></screen>
</tip>
</taskrelated-custom>
</task><sect2 id="gdbjm"><title>Where to Go From Here</title><para>See Installing and Booting <literal>lx</literal> Branded Zones<olink targetptr="z.inst.task-2" remap="internal">Installing and Booting Zones</olink> to install
your committed zone configuration.</para>
</sect2><sect2 id="gdbkd"><title>Script to Configure Multiple <literal>lx</literal> Branded
Zones</title><para>You can use this script to configure and boot multiple zones on
your system. The script takes the following parameters:</para><itemizedlist><listitem><para>The number of zones to be created</para>
</listitem><listitem><para>The <replaceable>zonename</replaceable> prefix</para>
</listitem><listitem><para>The directory to use as the base directory</para>
</listitem>
</itemizedlist><para>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.</para><screen>#!/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 &lt;#-of-zones> &lt;zonename-prefix> &lt;basedir> &lt;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 &lt;num>"
	    exit 1
fi

i=1
while [ $i -le $nzones ]; do
	zoneadm -z $prefix$i clone $template_zone > /dev/null 2>&amp;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>&amp;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>&amp;1 &amp;
				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 &amp;
		fi
		j=`expr $j + 1`
		i=`expr $i + 1`
	done
	wait
done</screen>
</sect2><task id="gdbiv"><title>How to Display the Configuration of a Branded Zone</title><tasksummary><para>You must be the global administrator in the global zone to perform this
procedure.</para>
</tasksummary><procedure><step><para>Become superuser, or assume the Primary Administrator role.</para><para>To create the role and assign the role to a user, see <olink targetdoc="sysadv1" targetptr="smcover-95" remap="external"><citetitle remap="section">Using the Solaris Management Tools With RBAC (Task Map)</citetitle> in <citetitle remap="book">System Administration Guide: Basic Administration</citetitle></olink>.</para>
</step><step><para>Display the configuration of a zone.</para><screen>global# <userinput>zonecfg -z zonename info</userinput></screen>
</step>
</procedure>
</task>
</sect1><sect1 id="gdbke"><title>Modifying, Reverting, or Removing Zone Configurations</title><para>The following sections contain procedures for modifying, reverting,
or removing a zone configuration.</para><itemizedlist><listitem><para><olink targetptr="z.conf.start-63" remap="internal">How to Modify a Resource
Type in a Zone Configuration</olink></para>
</listitem><listitem><para><olink targetptr="fpjpi" remap="internal">How to Clear a Property Type  in
a Zone Configuration</olink></para>
</listitem><listitem><para><olink targetptr="gbrfh" remap="internal">How to Rename a Zone</olink></para>
</listitem><listitem><para><olink targetptr="z.conf.start-30" remap="internal">How to Revert a Zone Configuration</olink></para>
</listitem><listitem><para><olink targetptr="z.conf.start-82" remap="internal">How to Delete a Zone Configuration</olink></para>
</listitem>
</itemizedlist>
</sect1>
</chapter>