Home

create_zone.sh




Purpose

create_zone.sh is a shell script for creating zones in Solaris 10 unattended.

Using this script you can create zones without user interaction for example in a jumpstart environment. create_zone.sh can configure

You can also define a profile for the zone.

In addition you can define a finish script for the zone which runs after the zone is created and configured but before the zone is booted in the global zone.

And you can define a customize script for the zone. The customize scripts runs while first rebooting the zone. The script can be in one of the milestones single-user, multi-user, or multi-user-server.

A site specific SMF profile is also supported.

One or more template directories with additional files that should be copied to the zone are also supported. You can also define files that should be copied from the global zone to the non-global zone.

The zone installation can be done via normale installation, via cloning an existing zone or using an flash image. The script also supports a config-only mode (configure the zone but do not install the zone).


Like all of my scripts based on scriptt.sh create_zone.sh also supports a configuration file in which you can define mostly all values to be used for the zone configuration.




Back to top

License


# CDDL HEADER START
#
# The contents of this file and the script are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License").  You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END



Back to top

History


Version
Releasedate
         Description
v1.1.26
19.07.2013
##   19.07.2013 v1.1.26/bs
##     added support for capped-cpu (parameter -x zone_capped_cpu_count)
##     added initial support for branded zones (parameter -x brand)
v1.1.25
26.03.2013
##   26.03.2013 v1.1.25/bs
##     corrected some bugs for configure only tasks
##     use "cp -p" instead of "cp " to copy files
v1.1.24
13.02.2013
##   13.02.2013 v1.1.24/bs
##     corrected invalid options for ZFS filesystems for the zone (ro instead rw)
v1.1.23
10.01.2013
##   10.01.2013 v1.1.23/bs
##     added the parameter -x zone_hostid=<hostid>
##     create_zone.sh will now NOT stop or delete a zone if -O and -B are
##     used added the keyword zone_set_global_option for -x
v1.1.21
17.12.2012
##   17.12.2012 v1.1.21 /bs
##     added code to workaround a "bug" in the zfs list command
##     (zfs list <dirname> returns always 0)
v1.1.20
08.11.2012
##   07.11.2012 v1.1.20 /bs
##     added the parameter -P <zone_path_absolute>
##     ZFS filesystems are now supported for the global directories to be used by
##       the zone (parameter -w and -R)
##     added support for flash image installations (-x zone_flashimage)
##     -x zone_netmask= is now also used for shared IP stack configurations
##     code cleanup${THIS_MOUNTPOOINT
##     added more parameter checks

v1.1.19
01.11.2012
##   01.11.2012 v1.1.19 /bs
##     corrected a bug in the TIMEZONE handling

v1.1.18
25.10.2012
##   25.10.2012 v1.1.18 /bs
##     changed the code to cleanup existing zone directories -- now it only deletes the
##     files and directories in the zone directory and not the zone directory

v1.1.17
22.03.2011
##   22.03.2011 v1.1.17 /bs
##     added a check for additional directories for the zone
##     removed the restriction to run only once at a time
##     added the keyword zone_add_network_interface to define additional network
##       interfaces for the zone
##     added the parameter -B (zone_config_only)
##     some cosmetic changes

v1.l.16
29.09.2010
##   29.09.2010 v1.1.16/bs
##     added a workaround for a bug in the zoneadm commands

v1.1.15
17.09.2009
##   17.09.2009 v1.1.14 /bs
##     not released
##   17.09.2009 v1.1.15 /bs
##     added code to copy files from the global zone to the non-global zone
##     (parameter -c)
##     the home directory for root is now configured like in the global zone

v1.1.13
09.09.2009
##   09.09.2009 v1.1.13 /bs
##     the script did not handle incomplete resolv.conf files correct. Fixed

v1.1.12
03.09.2009
##   03.09.2009 v1.1.12 /bs
##     the script did not handle timezones with a slash "/" correct. Fixed.
v1.1.11
31.08.2009
##   31.08.2009 v1.1.11 /bs
##     corrected a bug in the format of the created sysidcfg file
##     added code to set the timezone in the file /etc/TIMEZONE in the zone to avoid one reboot
##     added
##        svcadm disable svc:/application/cde-printinfo:default
##     to the builtin customize script for the zones
##
##     The default run level for the customize script is now rcS.d:
##        DEFAULT_ZONE_CUSTOMIZE_SCRIPT_TARGET="/etc/rcS.d/S99customize_script"
##
##     The script noew creates a config file inside the zone with the zone configuration
##     variables called
##         /etc/create_zone.cfg
##     (this are all variables used in this script with a name beginning with ZONE_)
##
v1.1.10
29.03.2009
##    29.03.2009 v1.1.10 /bs
##      added the parameter -R (--readonlydir) to configure add. read-only directories for the
##      zone
v1.1.9
28.02.2009
##    28.02.2009 v1.1.9 /bs
##      the default for the zone template directories (parameter -t) is now
##        "${DEFAULT_ZONE_PATH}/template_dir"
##     if that directory exist
##     create_zones.sh now creates a correct sysidcfg file if USE_EXISTING_NAMESERVER_CONFIG
##     is set to y

v1.1.8
25.02.2009
##    25.02.2009 v1.1.8 /bs
##      added support for new dladm options
##      added the parameter -t (--templatedir)
##      added the config options zone_netmask for zones with exclusive IP stack
##      create_zone.sh did not create a complete sysidcfg for zones with exclusive IP. Fixed.
##      removed the call of prtdiag; __MACHINE_SUBTYPE is now always empty

v1.1.7
18.02.2009
##    18.02.2009 v1.1.7 /bs
##      added support for other global config entries
##      added suport for devices for the zone
v1.1.6
15.02.2009
##    15.02.2009 v1.1.6 /bs
##      added support for ZFS datasets (parameter -Z)
##      added support for cloning a zone (parameter -N)
v1.1.5
08.02.2009
##    08.02.2009 v1.1.5 /bs
##    added support for the defrouter configuration for zones in Solaris U6 and newer
##      The list of file that are copied to a zone with exclusive IP stack can now be
##      configured in the config file; see the variable EXCLUSIVE_IP_STACK_CONFIG_FILES
v1.1.4
16.05.2008
##    15.05.2008 v1.1.4 /bs
##      added workaround for the "GLDv3 support" for the ce adapter
##         see: http://sunsolve.sun.com/search/document.do?assetkey=1-61-234401-1
##      added the config options zone_gldv3_check
v1.1.3
18.03.2008
##   18.03.2008 v1.1.3 /bs
##      added the config option zone_writabledir  and the option -w (writabledir)
##      improved the error handling
v1.1.2
17.03.2008
##   17.03.2008 v1.1.2 /bs
##      added the option -e (edit)
##      added the config option zone_inherited_dir and the option -d
##      added the syntax xx.xx.xx.xx/yy for the IP address (use /yy to specify the netmask)
v1.1.1
15.03.2008
##   15.03.2008 v1.1.1 /bs
##      added the config options zone_memory_limit, zone_swap_limit, zone_cpu_count, and zone_cpu_shares
v1.1.0
12.03.2008
##   12.03.2008 v1.1.0 /bs
##      added support for IP instances
##      use a newer version of the script template
v1.0.0
12.06.2006
initial public release
v0.9.0
07.06.2006 initial release; some tests were missing






Back to top

Operating system


Solaris 10 and newer



Back to top

Language / type


Kornshell Script



Back to top

Prerequisites

zones support must be installed



Back to top

Usage


The only mandatory parameter for create_zone.sh are the parameter for the name of the zone (-z <zone_name> or -x zone_name=<zone_name>, the IP address of the zone (-i <zone_ip_address or -x zone_ip_address=<zone_ip_address>), and the path for the zone (-p <zone_path> or -x zone_path=<zone_path>) if it is not the default value (/zones).

All other parameter are optional.

Note: A "big" zone is a "whole root zone"; a "small" zone is a "sparse root zone".




[20.07.2013 11:22:20] create_zone.sh v1.1.26 started on Sat Jul 20 11:22:20 CEST 2013 
[20.07.2013 11:22:20] No config file ("create_zone.conf") found (use -C to create a default config file)
  create_zone.sh v1.1.26 - create Solaris zones unattended

  Usage: create_zone.sh [-v|+v] [-q|+q] [-h] [-l logfile|+l] [-y|+y] [-n|+n]
                        [-D|+D] [-a|+a] [-O|+O] [-f|+f] [-C] [-H] [-S n] [-V] [-T]

                        -z zone_name -i zone_ip_address
                        [-p zone_path|-P zone_path_absolute] [-r zone_def_router]
                        [-A zone_network_adapter] [-b|+b] [-s freespace] [-x key=value] [-t templatedir]
                        [-e] [-d dir_to_inherit] [-w zonedir:globaldir] [-R zonedir:globaldir] [-Z dataset]
                        [-N sourcezone] [-c sourcefile] [-I|+I] [-B|+B] [-F|+F]

  Known keys for the parameter -x :
    zone_name zone_ip_address zone_network_interface zone_mode zone_ip_stack zone_netmask zone_default_router
    zone_root_password zone_tz zone_locale zone_terminal zone_timeserver zone_gldv3_check zone_path
    zone_path_absolute zone_customize_script_source zone_customize_script_target zone_finish_script
    zone_autboot boot_the_zone_now free_space_for_the_zone zone_profile zone_hostid
    use_existing_nameserver_config zone_add_network_interface
    zone_memory_limit zone_swap_limit zone_cpu_count zone_cpu_shares zone_capped_cpu_count
    zone_inherited_dir zone_writabledir zone_readonly_dir zone_dataset    
    zone_clone_source zone_device zone_global_option zone_set_global_option zone_brand
    zone_template_dir zones_copy_file zone_config_only zone_flashimage no_zone_config_checks

  The parameter -d, -R, -w, -t, -c, -Z, and -x can be used multiple times.



  # Example using only the mandatory parameter
  #
  create_zone.sh -z rtdev02zone005 -i 10.225.111.158/24

  # Example using some more parameter
  #
  create_zone.sh -z rtdev02zone005 -i 10.225.111.158/24 \
    -A vnet1 -r 10.225.111.254 \
    -x zone_add_network_interface=vnet4:10.225.247.157/24 \
    -x zonepath=/zones/rtdev02zone005 \
    -w /applications:/zones/rtdev02zone005/data/applications \
    -w /usr/sys/inst.images/SunOS:/zones/rtdev02zone005/data/usr/sys/inst.images/SunOS
 

 Note: Use -{switch} or --{longswitch} to turn an option on;
       use +{switch} or ++{longswitch} to turn an option off

       The long format of the parameter (--parameter/++parameter) is not supported by all ksh implementations
      
      
    Parameter:

      -v|+v - turn verbose mode on/off; current value: y
              Long format: --verbose / ++verbose
      -q|+q - turn quiet mode on/off; current value: n
              Long format: --quiet / ++quiet
      -h    - show usage
              Long format: --help
      -l    - set the logfile
              current value: /var/tmp/create_zone.LOG
              Long format: --logfile     
      +l    - do not write a logfile
              Long format: ++logfile
      -y|+y - assume yes to all questions or not
              Long format: --yes / ++yes
      -n|+n - assume no to all questions or not
              Long format: --no /++no
      -D|+D - run main in single step mode (and turn colors on); current value: n
              Long format: --debug / ++debug
      -a|+a - turn colors on/off; current value: n
              Long format: --color / ++color
      -O|+O - overwrite existing files or not; current value: n
              Long format: --overwrite / ++overwrite
      -f|+f - force; do it anyway; current value: n
              Long format: --force / ++force
      -C    - write a default config file in the current directory and exit
              Long format: --writeconfigfile
      -H    - write extended usage to STDERR and exit
              Long format: --doc
      -S n  - print error/warning summaries:
              n = 0 no summariess, 1 = print error msgs,
              2 = print warning msgs, 3 = print error and warning mgs
              Current value: 0
              Long format: --summaries
      -V    - write version number to STDOUT and exit
              Long format: --version
      -T    - append STDOUT and STDERR to the file "/var/tmp/create_zone.sh.6722.tee.log"
              Long format: --tee

      -F/+F - do not check the zone configuration if set (-F)
              Current value: n
              Long format: --no_zone_config_checks
      -B/+B - configure the zone but do NOT install the zone if set (-B)
              Current value: n
              Long format: --only_configure_zone             
      -z    - zone name, mandatory, no default
              Current value:
              Long format: --zone_name
      -i    - zone ip address, mandatory, no default
              Current value:      
              use xx.xx.xx.xx/yy to specifiy a netmask
              Long format: --zone_ip_address
      -r      default router for the zone;
              current value
              use none to unset the default router
              Long format: --zone_default_router
      -I/+I - use an exclusive IP stack (-I) or a shared IP stack (+I);
              current value SHARED
              Long format: --zone_ip_stack / ++zone_ip_stack
      -p    - zone path;
              current value: /zones
              Long format: --zone_path
              Note: The zone will be created in the directory
                    <zone_path>/<zone_name>
                    Use either -p or -P
      -P    - absolute zone path;
              current value:
              Long format: --zone_path_absolute             
              Note: The zone will be created in the directory
                    <zone_path_absolute>
                    Use either -p or -P
      -N    - create the zone by cloning another zone
              Current value:
              Long format: --clone
      +N    - create the zone by installing it from the global zone
              Long format: ++clone
      -A    - zone network adapter
              Current value:
              Long format: --zone_network_interface
      -b    - create a big zone (= whole root zone)
              Current value: small
              Long format: --big
      +b    - create a small zone (= sparse zone)
              Long format:  ++big
      -s    - freespace in KB necessary for the zone
              Current value:
              Use 0 to suppress the free space check
              Long format: --free_space
      -e|+e - edit the zone configuration before creating the zone
              current value: n
              If this parameter is found, the script calls the standard
              editor (environment variable EDITOR or vi if not set) for
              the zone configuration before creating the zone
              Long format: --edit
      -d    - directory to inherit by the zone (*)
              Current Value:
              Directory names with spaces or tabs are NOT supported
              Long format: --inherit
      +d    - remove all additional inherited directories and add the
              new directory to the list of directories to inherit
              (use none to delete the complete list)
              This parameter will undo all previous found -d parameter
              and also delete the default values from the config file
              Long format: ++inherit
      -R    - directory to mount readonly in the zone (*)
              Current value:
              Format of the entry: zone_dir:global_dir
              Directory names with spaces or tabs are NOT supported
              If the directory global_dir does not exist it will be
              created.
              global_dir can also be a ZFS filesystem
              Long format: --readonlydir
      +R    - reset the list of readonly directories and add the new
              directory to the list of readonly directories
              (use none to delete the complete list)             
              Format of the entry: zone_dir:global_dir
              If the directory global_dir does not exist it will be
              created.
              global_dir can also be a ZFS filesystem
              This parameter will undo all previous found -R parameter
              and also delete the default values from the config file
              Long format: ++readonlydir
      -w    - directory to mount writable in the zone (*)
              Current value:
              Format of the entry: zone_dir:global_dir
              Directory names with spaces or tabs are NOT supported
              If the directory global_dir does not exist it will be
              created.
              global_dir can also be a ZFS filesystem
              Long format: --writabledir
      +w    - reset the list of writable directories and add the new
              directory to the list of writable directories
              (use none to delete the complete list)             
              Format of the entry: zone_dir:global_dir
              If the directory global_dir does not exist it will be
              created.
              global_dir can also be a ZFS filesystem
              This parameter will undo all previous found -w parameter
              and also delete the default values from the config file
              Long format: ++writabledir
      -t    - template directory for the zone (*)
              Current value:
              All files and directories in this directory will be
              copied to the root filesystem of the zone after the zone
              is created.
              Directory names with spaces or tabs are NOT supported
              Long format: --templatedir
      +t    - reset the list of template dirs and add a new directory
              directory to the list of template directories
              (use none to delete the complete list)             
              This parameter will undo all previous found -t parameter
              and also delete the default values from the config file
              Long format: ++templatedir
      -c    - copy a file from the global zone to the non-global zone (*)
              Long format: ++copyfile
      +c    - reset the list of files to copy to the zone and add a new
              file to the list of files to copy
              (use none to delete the complete list)             
              This parameter will undo all previous found -c parameter
              and also delete the default values from the config file
              Long format: ++copyfile
      -Z    - ZFS dataset for the zone (*)
              Current Value:
              Long format: --dataset
      +Z    - reset the list of ZFS datasets for the zone and add the
              new ZFS dataset to the zone
              (use none to delete the complete list)             
              This parameter will undo all previous found -Z parameter
              and also delete the default values from the config file
              Long format: ++dataset
      -x key=value (*)
            - define various config parameter for the zone (see below)
              Long format: --config

    The parameter marked with (*) can be used multiple times.


    Known key/value pairs for the parameter -x are
    (keys marked with (*) can be used more than once):

      no_zone_config_checks=yes|no
        Do not check the zone configuration
        current value: n
        default: check the zone configuration
        shortcut: -F
       
      zone_config_only=yes|no
        Only configure the zone but do not install the zone
        current value: n
        default: configure and install the zone
        shortcut: -B
       
      zone_name=name_of_the_zone
        current value:
        no default
        shortcut: -z

      zone_brand=brand_of_the_zone
        example: SUNWsolaris8
        current value:
        no default
  
      zone_clone_source=name_of_the_zone_to_clone
        Create the zone by cloning an existing zone
        current value:
        no default
        shortcut: -N

      zone_memory_limit=memory_limit
        current value:
        memory limit for the zone; no default

      zone_swap_limit=swap_limit
        current value:
        no default
        swap limit for the zone

      zone_cpu_shares=no_of_cpu_shares
        current value:
        no default
        no of CPU shares for the zone

      zone_capped_cpu_count=no_of_cpus
        current value:
        no default
        max no. of cpus for the zone
      
      zone_cpu_count=no_of_cpus
        current value:
        no default
        no. of cpus for the zone

      address=ip_address_for_the_zone
    or
      zone_ip_address=ip_address_for_the_zone
        current value:
        speficy the IP address for the zone; use xx.xx.xx.xx/yy to
        specify a netmask also
        no default
        shortcut: -i

      zone_network_interface=network_interface_for_the_zone
    or
      physical=network_interface_for_the_zone
        current value:
        the default depends on the IP address choosen for the zone
        When configuring a zone with exclusive IP stack (-I) there is no
        default for this parameter and therefore this parameter is
        mandatory
        shortcut: -A

      zone_default_router=ip_address_of_the_default_router
        current value:
        The default router for the zone;
        no default
        use none to unset the default router

      zone_netmask=netmask_for_the_zone
        current value:
        This is the netmask for zones with exclusive IP stack
        no default

      zone_add_network_interface=interface:address:defrouter  (*)
        current value:
        Additional network interfaces for the zone
        no default

      zone_ip_stack={shared|exclusive}
        current value: SHARED
        this is the type of the IP stack for the zone
        default: shared IP stack
        shortcut: -I

      zone_gldv3_check={yes|no}
        current value: yes
        if this key is set to no, the script will not check if the
        network adapter for the zone uses a GLDv3 driver
        default: do not check

      zone_mode=[small|big]
        current value: small
        shortcut: -b|+b
        default: small (= sparse zone)

      zonepath=path_for_the_zone
    or
      zone_path=path_for_the_zone
        current value: /zones
        shortcut: -p
        The zone will be created in the directory [zone_path]/[zone_name]
        no default
        Use either zone_path or zone_path_absolute -- not both
       
      zone_path_absolute=absolute_path_for_the_zone
        current value:
        shortcut: -P
        The zone will be created in the directory [absolute_zonepath]
        no default
        Use either zone_path or zone_path_absolute -- not both

      zone_flashimage=flashimage_for_the_zone
        current value:
        flashimage to be used to install the zone
        no default
             
      zone_root_password=encrypted_password_for_root
        current value:
        The default is the passwort from the root user in the global zone
        Use none for no root user password
       
      zone_tz=timezone_for_the_zone
        current value:
        The default is the current TIMEZONE of the global zone

      zone_locale=locale_for_the_zone
        current value: C
        The default is the current locale

      zone_terminal=terminal_type_for_the_zone
        current value: xterm
        The default is the value of the variable TERM
        or vt100 if the variable TERM is not set

      zone_timeserver=timeserver_for_the_zone
        current value: localhost
        no default

      zone_finish_script=finish_script_for_the_zone
        current value:
        The finish script runs in the global zone after the zone is
        created and configured but before it is booted. The parameter
        for the finish_script is the directory used for the zone
        Use none for no finish script
        no default
       
      zone_customize_script_source=customize_script_for_the_zone
        current value: builtin
        The customization script runs inside the new zone
        while first booting the zone.

        Use builtin for the builtin customize script; use none for
        no customize script
       
        The builtin customize script is:

        # --- built in script starts

  echo "Customization of the zone is running ..."

  echo "Disabling sendmail ..."
  svcadm disable sendmail
  svcadm disable svc:/application/cde-printinfo:default

  echo " ... customization done. Removing the customize script"
  rm $0

        # --- built in script ends

        (defined in the variable DEFAULT_ZONE_CUSTOMIZE_SCRIPT_CONTENTS
          in the config file)

      zone_customize_script_target=fqn_of_the_customize_script
        FQN of the customize script inside the zone
        current value: /etc/rcS.d/S99customize_script

      zone_profile=smf_profile_for_the_zone
        current value:

      use_existing_nameserver_config=[yes|no]
        current value: y
        If this variable is true the files


/etc/resolv.conf
/etc/nsswitch.conf


        from the global zone are copied to the new zone
        (the list of files is defined in the variable NAME_SERVER_CONFIG_FILES
         in the config file)
        
      zone_autoboot=[yes|no]
    or
      autoboot=[yes|no]
        current value: n
     
      boot_the_zone_now=[yes|no]
        current value: n
        if yes, the zone will be booted automatically if configured and
        created without errors.

      free_space_for_the_zone=freespace_necessary_in_kb
        The defaults are
          for big zones: 3500000 kb
          for small zones: 200000 kb
        Use 0 to suppress the free space check
        shortcut: -s

      zone_inherited_dir=dir_name  (*)
        current value:
        Directory which should be inherited by the zone.
        The default is only to inherit the default directories
        Directories with space or tabs in the name are NOT supported!
        shortcut: -d

      zone_readonly_dir=zone_dir:global_dir  (*)
        current value:
        Directory which should be mounted readonly in the zone.
        Directories with space or tabs in the name are NOT supported!
        If the directory in the global zone does not exist it will
        be created.
        global_dir can be either a directory or a ZFS filesystem;
        ZFS filesystems must already exist
        shortcut: -R

      zone_writable_dir=zone_dir:global_dir  (*)
        current value:
        Directory which should be mounted writable in the zone.
        Directories with space or tabs in the name are NOT supported!
        If the directory in the global zone does not exist it will
        be created.
        global_dir can be either a directory or a ZFS filesystem;
        ZFS filesystems must already exist       
        shortcut: -w

      zone_template_dir=dir_name  (*)
        current value:
        All files and directories in this directory wil be copied to the
        root filesystem of the zone
        Directories with space or tabs in the name are NOT supported
        shortcut: -t

      zone_copy_file=source_file (*)
        current value:
        copy a file from the global zone to the non-global zone
        filenames with space or tabs in the name are NOT supported
        shortcut: -c
       
      zone_dataset=zpool (*)
        current value:
        ZFS dataset for the zone
        shortcut: -Z

      zone_device=device (*)
        current value:
        device for the zone

      zone_global_option=option (*)
        current value:
        Add. global options that use the syntax "option=value" or
        "option" can be defined using this keyword.
        These entries are NOT checked by the script!

      zone_set_global_option=option (*)
        current value:
        Add. global options set use the syntax "set options=value" or
        "set option" can be defined using this keyword.
        These entries are NOT checked by the script!

      zone_hostid=hostid
        current value:
       
Please note that you need Solaris 10 8/07 or newer for the configuration
options

  zone_memory_limit, zone_swap_limit, zone_cpu_count, and zone_cpu_shares

Please note that you need Solaris 10 6/08 or newer for the configuration
options

  zone_default_router (shortcut -r)
 



  # Example using only the mandatory parameter
  #
  create_zone.sh -z rtdev02zone005 -i 10.225.111.158/24

  # Example using some more parameter
  #
  create_zone.sh -z rtdev02zone005 -i 10.225.111.158/24 \
    -A vnet1 -r 10.225.111.254 \
    -x zone_add_network_interface=vnet4:10.225.247.157/24 \
    -x zonepath=/zones/rtdev02zone005 \
    -w /applications:/zones/rtdev02zone005/data/applications \
    -w /usr/sys/inst.images/SunOS:/zones/rtdev02zone005/data/usr/sys/inst.images/SunOS
 
[20.07.2013 11:22:20] The log file used was "/tmp/create_zone.sh.6722.TEMP" 
[20.07.2013 11:22:20] create_zone.sh v1.1.26 ended on Sat Jul 20 11:22:20 CEST 2013.
[20.07.2013 11:22:20] The RC is 1.

 



Examples



Example 1 :  Creating a zone with create_zone.sh v1.1.8 with only the mandatory parameter

$ create_zone.sh -z testzone13 -i 192.168.1.77
[26.02.2009 23:17:49] create_zone.sh v1.1.8 started on Thu Feb 26 23:17:49 CET 2009 
[26.02.2009 23:17:49] Reading the config file "./create_zone.conf" ...
[26.02.2009 23:17:49] Using the log file "/var/tmp/create_zone.LOG" 
 
[26.02.2009 23:17:49] Creating the zone "testzone13"
[26.02.2009 23:17:49] No memory limit configured for the zone
[26.02.2009 23:17:49] No swap limit configured for the zone
[26.02.2009 23:17:49] No dedicated cpus configured for the zone
[26.02.2009 23:17:49] No CPU shares configured for the zone
[26.02.2009 23:17:49] No additional directories to be inherited by the zone
[26.02.2009 23:17:49] The path for the zone is "/zones/testzone13" 
[26.02.2009 23:17:49] The mode for the zone is "small" 
[26.02.2009 23:17:49] The IP address of the zone is "192.168.1.77"
[26.02.2009 23:17:49] The zone uses a(n) "SHARED" IP stack
[26.02.2009 23:17:50] No default router configured for the zone.
[26.02.2009 23:17:50] Check the GLDv3 driver: "yes" 
[26.02.2009 23:17:50] The zone uses the network interface "ipmp0"
[26.02.2009 23:17:50] The locale for the zone is "C" 
[26.02.2009 23:17:50] The timezone for the zone is "Europe/Berlin" 
[26.02.2009 23:17:50] The encrypted root password for the zone is "5ZtCsAEwWfHIg"
[26.02.2009 23:17:50] The terminal type for the zone is "vt100"
[26.02.2009 23:17:50] The timeserver for the zone is "localhost"
[26.02.2009 23:17:50] The finish script for the zone is ""
[26.02.2009 23:17:50] The customize script for the zone is "builtin" 
[26.02.2009 23:17:50] The customize script inside the zone is "/etc/rc3.d/S99customize_script"
[26.02.2009 23:17:50] The SMF profile for the zone is ""
[26.02.2009 23:17:50] Use the existing name server configuration: y
[26.02.2009 23:17:50] Set autoboot to enable for the zone: n
[26.02.2009 23:17:50] Boot the zone after installation: n
[26.02.2009 23:17:50] Free space in KB necessary for creating the zone is: 200000
[26.02.2009 23:17:50] 
[26.02.2009 23:17:50] Edit the zone config before creating the zone: n
 
Create the zone (y/N)?  y
[26.02.2009 23:18:06] Checking the zone configuration ...
[26.02.2009 23:18:07] The zone configuration seems to be okay 
[26.02.2009 23:18:07] Configuring the zone "testzone13" ...
[26.02.2009 23:18:07] Installing the zone "testzone13" ...
A ZFS file system has been created for this zone.
Preparing to install zone <testzone13>.
Creating list of files to copy from the global zone.
Copying <9658> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1596> packages on the zone.
Initialized <1596> packages on zone.                                
Zone <testzone13> is initialized.
Installation of <1> packages was skipped.
The file </zones/testzone13/root/var/sadm/system/logs/install_log> contains a log of the zone installation.
[26.02.2009 23:35:56] Preparing the zone "testzone13" for running applications ...
[26.02.2009 23:35:58] Post configuring the zone "testzone13"  ...
[26.02.2009 23:35:58] Changing the nameserver configuration of the zone "testzone13" ...
[26.02.2009 23:35:58] Processing the file "/etc/resolv.conf" ...
[26.02.2009 23:35:58] Processing the file "/etc/nsswitch.conf" ...
[26.02.2009 23:35:58] Installing the customize script "/etc/rc3.d/S99customize_script" in the zone "testzone13" ...
[26.02.2009 23:35:58]  ... done. zone "testzone13" installed and configured
[26.02.2009 23:35:58] The log file used was "/var/tmp/create_zone.LOG" 
[26.02.2009 23:35:58] create_zone.sh v1.1.8 ended on Thu Feb 26 23:35:58 CET 2009.
[26.02.2009 23:35:58] The RC is 0.




Example 2 :  Creating a zone with create_zone.sh v1.1.8 using the zoneadm clone features

$ create_zone.sh -z testzone14 -i 192.168.1.78 -N template
[26.02.2009 23:49:34] create_zone.sh v1.1.8 started on Thu Feb 26 23:49:34 CET 2009 
[26.02.2009 23:49:34] Reading the config file "./create_zone.conf" ...
[26.02.2009 23:49:34] Using the log file "/var/tmp/create_zone.LOG" 
 
[26.02.2009 23:49:34] Creating the zone "testzone14"
[26.02.2009 23:49:34] The zone will be created by cloning the zone "template" 
[26.02.2009 23:49:34] No memory limit configured for the zone
[26.02.2009 23:49:34] No swap limit configured for the zone
[26.02.2009 23:49:34] No dedicated cpus configured for the zone
[26.02.2009 23:49:34] No CPU shares configured for the zone
[26.02.2009 23:49:34] No additional directories to be inherited by the zone
[26.02.2009 23:49:35] The path for the zone is "/zones/testzone14" 
[26.02.2009 23:49:35] The mode for the zone is "small" 
[26.02.2009 23:49:35] The IP address of the zone is "192.168.1.78"
[26.02.2009 23:49:35] The zone uses a(n) "SHARED" IP stack
[26.02.2009 23:49:35] No default router configured for the zone.
[26.02.2009 23:49:35] Check the GLDv3 driver: "yes" 
[26.02.2009 23:49:35] The zone uses the network interface "ipmp0"
[26.02.2009 23:49:35] The locale for the zone is "C" 
[26.02.2009 23:49:35] The timezone for the zone is "Europe/Berlin" 
[26.02.2009 23:49:35] The encrypted root password for the zone is "5ZtCsAEwWfHIg"
[26.02.2009 23:49:35] The terminal type for the zone is "vt100"
[26.02.2009 23:49:35] The timeserver for the zone is "localhost"
[26.02.2009 23:49:35] The finish script for the zone is ""
[26.02.2009 23:49:35] The customize script for the zone is "builtin" 
[26.02.2009 23:49:35] The customize script inside the zone is "/etc/rc3.d/S99customize_script"
[26.02.2009 23:49:35] The SMF profile for the zone is ""
[26.02.2009 23:49:35] Use the existing name server configuration: y
[26.02.2009 23:49:35] Set autoboot to enable for the zone: n
[26.02.2009 23:49:35] Boot the zone after installation: n
[26.02.2009 23:49:35] Free space in KB necessary for creating the zone is: 200000
[26.02.2009 23:49:35] 
[26.02.2009 23:49:35] Edit the zone config before creating the zone: n
 
Create the zone (y/N)?  y
[26.02.2009 23:49:40] Checking the zone configuration ...
[26.02.2009 23:49:42] The zone configuration seems to be okay 
[26.02.2009 23:49:42] Configuring the zone "testzone14" ...
[26.02.2009 23:49:42] Installing the zone "testzone14" by cloning the zone "template"...
Cloning snapshot rpool/zones/template@SUNWzone7
Instead of copying, a ZFS clone has been created for this zone.
sys-unconfig started Thu Feb 26 23:49:48 2009
rm: /a/etc/vfstab.sys-u: No such file or directory
sys-unconfig completed Thu Feb 26 23:49:49 2009
[26.02.2009 23:49:52] Preparing the zone "testzone14" for running applications ...
[26.02.2009 23:50:00] Post configuring the zone "testzone14"  ...
[26.02.2009 23:50:00] Changing the nameserver configuration of the zone "testzone14" ...
[26.02.2009 23:50:00] Processing the file "/etc/resolv.conf" ...
[26.02.2009 23:50:00] Processing the file "/etc/nsswitch.conf" ...
[26.02.2009 23:50:00] Installing the customize script "/etc/rc3.d/S99customize_script" in the zone "testzone14" ...
[26.02.2009 23:50:00]  ... done. zone "testzone14" installed and configured
[26.02.2009 23:50:01] The log file used was "/var/tmp/create_zone.LOG" 
[26.02.2009 23:50:01] create_zone.sh v1.1.8 ended on Thu Feb 26 23:50:01 CET 2009.
[26.02.2009 23:50:01] The RC is 0.





Example 3 :  Creating a zone with create_zone.sh v1.1.3 using some more parameter


[Tue Mar 18 18:22:15 root@sol9 /]
# EDITOR=cat ; /var/tmp/create_zone.sh --zone_name testzone3 --zone_ip_address 10.1.2.5/24  --zone_path /export \
--zone_network_interface hme0  --config zone_locale=de -x inherited_dir=/bootcd --config inherited_dir=/sol10ramfs \
 -x inherited_dir=/sol9ramfs  -w /tftpboot:/var/zones/testzone3/tftpboot -w /usr/local:/var/zones/testzone3/usr/local \
-e -O
[18.03.2008 18:22:19] create_zone.sh v1.1.3 started on Tue Mar 18 18:22:19 MET 2008 
[18.03.2008 18:22:19] Reading the config file "./create_zone.conf" ...
[18.03.2008 18:22:20] Using the log file "/var/tmp/create_zone.LOG" 
 
[18.03.2008 18:22:20] Creating the zone "testzone3"
[18.03.2008 18:22:20] No memory limit configured for the zone
[18.03.2008 18:22:20] No swap limit configured for the zone
[18.03.2008 18:22:20] No dedicated cpus configured for the zone
[18.03.2008 18:22:20] No CPU shares configured for the zone
[18.03.2008 18:22:20] Additional directories inherited by the zone are:
[18.03.2008 18:22:20]     /bootcd
[18.03.2008 18:22:20]     /sol10ramfs
[18.03.2008 18:22:21]     /sol9ramfs
[18.03.2008 18:22:21] Writable directories in the zone are:
[18.03.2008 18:22:21]     (zone) /tftpboot = (global) /var/zones/testzone3/tftpboot
[18.03.2008 18:22:21]     (zone) /usr/local = (global) /var/zones/testzone3/usr/local
[18.03.2008 18:22:21] The path for the zone is "/export/testzone3" 
[18.03.2008 18:22:21] The mode for the zone is "small" 
[18.03.2008 18:22:21] The IP address of the zone is "10.1.2.5/24"
[18.03.2008 18:22:21] The zone uses a(n) "SHARED" IP stack
[18.03.2008 18:22:21] The zone uses the network interface "hme0"
[18.03.2008 18:22:21] The locale for the zone is "de" 
[18.03.2008 18:22:21] The timezone for the zone is "MET" 
[18.03.2008 18:22:21] The encrypted root password for the zone is "4l/EjawSj1b7."
[18.03.2008 18:22:21] The terminal type for the zone is "ansi"
[18.03.2008 18:22:21] The timeserver for the zone is "localhost"
[18.03.2008 18:22:21] The finish script for the zone is ""
[18.03.2008 18:22:21] The customize script for the zone is "builtin" 
[18.03.2008 18:22:21] The customize script inside the zone is "/etc/rc3.d/S99customize_script"
[18.03.2008 18:22:21] The SMF profile for the zone is ""
[18.03.2008 18:22:21] Use the existing name server configuration: y
[18.03.2008 18:22:21] Set autoboot to enable for the zone: n
[18.03.2008 18:22:21] Boot the zone after installation: n
[18.03.2008 18:22:21] Free space in KB necessary for creating the zone is: 200000
[18.03.2008 18:22:21] 
[18.03.2008 18:22:21] Edit the zone config before creating the zone y
 
[18.03.2008 18:22:22] WARNING: The zone "testzone3" already exists; the status is "configured" 
 
Recreate the zone (y/N)?  y
[18.03.2008 18:22:23] Checking the zone configuration ...
[18.03.2008 18:22:25] The zone configuration seems to be okay 
[18.03.2008 18:22:25] Deleting the existing zone "testzone3" ...
cannot manage a zone which is in state 'configured'
zoneadm: zone 'testzone3': could not start zoneadmd
[18.03.2008 18:22:25] WARNING: Error calling zoneadm -z testzone3 halt
zoneadm: zone 'testzone3': is already in state 'configured'.
[18.03.2008 18:22:26] Removing the existing zone directory "/export/testzone3" ...
[18.03.2008 18:22:27] Configuring the zone "testzone3" ...
[18.03.2008 18:22:27] Calling the editor "cat" to edit the zone configuration \"/tmp/create_zone.sh.14320.14305.TEMP1\" ...

create
set autoboot=false
set zonepath=/export/testzone3

add net
set address=10.1.2.5/24 
set physical=hme0
end

add inherit-pkg-dir
set dir=/bootcd
end
add inherit-pkg-dir
set dir=/sol10ramfs
end
add inherit-pkg-dir
set dir=/sol9ramfs
end
add fs
set dir=/tftpboot
set special=/var/zones/testzone3/tftpboot
set type=lofs
add options rw
end
add fs
set dir=/usr/local
set special=/var/zones/testzone3/usr/local
set type=lofs
add options rw
end
commit
exit

Continue creating the zone (y/N)?  y
[18.03.2008 18:22:28] Installing the zone "testzone3" ...
Preparing to install zone <testzone3>.
Creating list of files to copy from the global zone.
Copying <8701> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1213> packages on the zone.
Initialized <1213> packages on zone.                                
Zone <testzone3> is initialized.
The file </export/testzone3/root/var/sadm/system/logs/install_log> contains a log of the zone installation.
[18.03.2008 19:07:02] Preparing the zone "testzone3" for running applications ...
[18.03.2008 19:07:05] Post configuring the zone "testzone3"  ...
[18.03.2008 19:07:05] Changing the nameserver configuration of the zone "testzone3" ...
[18.03.2008 19:07:05] Processing the file "/etc/resolv.conf" ...
[18.03.2008 19:07:05] Processing the file "/etc/nsswitch.conf" ...
[18.03.2008 19:07:06] Installing the customize script "/etc/rc3.d/S99customize_script" in the zone "testzone3" ...
[18.03.2008 19:07:06]  ... done. zone "testzone3" installed and configured
[18.03.2008 19:07:06] The log file used was "/var/tmp/create_zone.LOG" 
[18.03.2008 19:07:06] create_zone.sh v1.1.3 ended on Tue Mar 18 19:07:06 MET 2008.
[18.03.2008 19:07:06] The RC is 0.

[Tue Mar 18 19:07:06 root@sol9 /]
#


# check the results:

[Tue Mar 18 19:13:31 root@sol9 /]
# zonecfg -z testzone3 info
zonename: testzone3
zonepath: /export/testzone3
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
        dir: /lib
inherit-pkg-dir:
        dir: /platform
inherit-pkg-dir:
        dir: /sbin
inherit-pkg-dir:
        dir: /usr
inherit-pkg-dir:
        dir: /bootcd
inherit-pkg-dir:
        dir: /sol10ramfs
inherit-pkg-dir:
        dir: /sol9ramfs
fs:
        dir: /tftpboot
        special: /var/zones/testzone3/tftpboot
        raw not specified
        type: lofs
        options: [rw]
fs:
        dir: /usr/local
        special: /var/zones/testzone3/usr/local
        raw not specified
        type: lofs
        options: [rw]
net:
        address: 10.1.2.5/24
        physical: hme0

[Tue Mar 18 19:13:39 root@sol9 /]
# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP   
   0 global           running    /                              native   shared
   1 gcc              running    /zones/gcc                     native   shared
   2 sunstudio12      running    /zones/sunstudio12             native   shared
   3 template         running    /zones/template                native   shared
   4 test             running    /zones/test                    native   shared
   7 testzone         ready      /zones/testzone                native   excl 
   8 testzone3        ready      /export/testzone3              native   shared

[Tue Mar 18 19:13:45 root@sol9 /]
#



Example 4 :  Creating a zone with create_zone.sh v1.1.20 using some more parameter


# time EDITOR=cat  /var/tmp/create_zone.sh  -z rtdev02zone002.rze.de.db.com  -i 10.225.104.243 -x zone_add_network_interface=vnet0:10.225.244.34/25  -x zone_netmask=255.255.255.0  -P /devzones/test/rtdev02zone002.rze.de.db.com  -e -w /test:rpool/ROOT/zfsroot/devzones/test11  -w /test1:/zones  -v -x zone_flashimage=/mnt1/flashimages/sol10000_00_os_1009_us_1.gbl.flashsun4v_iplno.fsh -O -x zone_template_dir=/template1 -x zone_template_dir=/template2 -x zone_copy_file=/var/tmp/TestFile  -x zone_copy_file=/var/tmp/create_cdm_user.sh -x zone_device=/dev/console -x zone_cpu_count=2 -x zone_memory_limit=2g -x zone_swap_limit=4g -x zone_terminal=vt100
[08.11.2012 15:51:53] create_zone.sh v1.1.20 started on Thu Nov  8 15:51:53 CET 2012
[08.11.2012 15:51:53] Reading the config file "/etc/create_zone.conf" ...
[08.11.2012 15:51:54] Using the log file "/var/tmp/create_zone.LOG"
[08.11.2012 15:51:54] INFO: Checking for the mandatory zone parameter ...
[08.11.2012 15:51:54] INFO: Checking some optional parameter ...
[08.11.2012 15:51:54] INFO: ZONE_PATH is "/devzones/test"
[08.11.2012 15:51:54] INFO: ZONE_SUBDIR is "rtdev02zone002.rze.de.db.com"
[08.11.2012 15:51:54] INFO: ZONE_PATH_ABSOLUTE is "/devzones/test/rtdev02zone002.rze.de.db.com"
[08.11.2012 15:51:54] INFO: Converting the zone path "/devzones/test" to an absolute name ...
[08.11.2012 15:51:54] INFO:   ... the zone path is now "/devzones/test"
[08.11.2012 15:51:54] INFO: Setting the missing optional zone parameter using default values ...
[08.11.2012 15:51:54] INFO: Getting the network mask for the zone ...
[08.11.2012 15:51:54] INFO:    ... the network mask for the zone is "/24".
[08.11.2012 15:51:54] INFO: Setting the network interface for the zone ...
[08.11.2012 15:51:54] INFO:   ... the network interface for the zone is "vnet1".
[08.11.2012 15:51:54] INFO: Retrieving the status of the new zone ...

[08.11.2012 15:51:54] Creating the zone "rtdev02zone002.rze.de.db.com"
[08.11.2012 15:51:54] The zone will be installed using the flash image "/mnt1/flashimages/sol10000_00_os_1009_us_1.gbl.flashsun4v_iplno.fsh"
[08.11.2012 15:51:54] The path for the zone is "/devzones/test/rtdev02zone002.rze.de.db.com"
[08.11.2012 15:51:54] The mode for the zone is "small"
[08.11.2012 15:51:54] The memory limit for the zone is "2g"
[08.11.2012 15:51:54] The swap limit for the zone is "4g"
[08.11.2012 15:51:54] The number of CPUs for the zone is "2"
[08.11.2012 15:51:54] No CPU shares configured for the zone
[08.11.2012 15:51:54] No additional directories to be inherited by the zone
[08.11.2012 15:51:54] Writable directories in the zone are:
[08.11.2012 15:51:54]     (zone) /test = (global) rpool/ROOT/zfsroot/devzones/test11
[08.11.2012 15:51:54]     (zone) /test1 = (global) /zones
[08.11.2012 15:51:54] Check the GLDv3 driver: "yes"
[08.11.2012 15:51:54] The zone uses the network interface "vnet1"
[08.11.2012 15:51:54] The zone uses the "SHARED" IP stack
[08.11.2012 15:51:54] The IP address of the zone is "10.225.104.243/24"
[08.11.2012 15:51:54] No default router configured for the zone.
[08.11.2012 15:51:54] Additional network interfaces for the zones:
[08.11.2012 15:51:54]   Interface: vnet0, IP: 10.225.244.34/25, DefRouter:
[08.11.2012 15:51:54] The locale for the zone is "C"
[08.11.2012 15:51:54] The timezone for the zone is "Europe/Berlin"
[08.11.2012 15:51:54] The encrypted root password for the zone is "EnFQsCk8TXWVU"
[08.11.2012 15:51:54] The terminal type for the zone is "vt100"
[08.11.2012 15:51:54] The timeserver for the zone is "localhost"
[08.11.2012 15:51:54] The finish script for the zone is ""
[08.11.2012 15:51:54] The customize script for the zone is "/applications/SunTools/CURRENT/scripts/zone_customize_script.sh"
[08.11.2012 15:51:54] The customize script inside the zone is "/etc/rcS.d/S99customize_script"
[08.11.2012 15:51:54] The SMF profile for the zone is ""
[08.11.2012 15:51:54] The zone template directories are:
[08.11.2012 15:51:54]     /template1
[08.11.2012 15:51:54]     /template2
[08.11.2012 15:51:54] The files to copy to the zone are:
[08.11.2012 15:51:54]     /var/db/var/query_postinstall.conf
[08.11.2012 15:51:54]     /var/db/var/installed_x_services
[08.11.2012 15:51:54]     /etc/ssh/sshd_config
[08.11.2012 15:51:54]     /var/tmp/TestFile
[08.11.2012 15:51:54]     /var/tmp/create_cdm_user.sh
[08.11.2012 15:51:54] Use the existing name server configuration: y
[08.11.2012 15:51:54] Set autoboot to enable for the zone: n
[08.11.2012 15:51:54] Boot the zone after installation: n
[08.11.2012 15:51:54] Free space in KB necessary for creating the zone is: 200000
[08.11.2012 15:51:54] Devices for the zone:

/dev/console
[08.11.2012 15:51:54]
[08.11.2012 15:51:54] Edit the zone config before creating the zone: y

Create the zone (y/N)?  y
[08.11.2012 15:52:23] Checking the zone configuration ...
[08.11.2012 15:52:23] INFO: Checking the flash image for the zone ...
[08.11.2012 15:52:23] INFO: Checking the zone path ...
[08.11.2012 15:52:23] INFO: Checking the directories to inherit to the zone ...
[08.11.2012 15:52:23] INFO: Checking the directory names ...
[08.11.2012 15:52:23] INFO: "rpool/ROOT/zfsroot/devzones/test11" is not an absolute path - checking if it's a ZFS filesystem ...
[08.11.2012 15:52:24] INFO: "rpool/ROOT/zfsroot/devzones/test11" is a ZFS filesystem.
[08.11.2012 15:52:24] INFO: Checking the SMF profile ...
[08.11.2012 15:52:24] INFO: Checking the finish script for the zone ...
[08.11.2012 15:52:24] INFO: Checking the customization script for the zone ...
[08.11.2012 15:52:24] INFO: Checking the network configuration for the zone ...
[08.11.2012 15:52:26] INFO: Checking the mode for the zone ...
[08.11.2012 15:52:26] INFO: Checking the ZFS datasets for the zone ...
[08.11.2012 15:52:26] INFO: Checking the template directories for the zone ...
[08.11.2012 15:52:26] INFO: Checking the free space for the zone ...
[08.11.2012 15:52:26] The zone configuration seems to be okay
[08.11.2012 15:52:26] Removing the existing files in the zone directory "/devzones/test/rtdev02zone002.rze.de.db.com" ...
[08.11.2012 15:52:26] Configuring the zone "rtdev02zone002.rze.de.db.com" ...
[08.11.2012 15:52:26] Calling the editor "cat" to edit the zone configuration file "/tmp/create_zone.sh.4470.13852.TEMP1"...

create
set autoboot=false
set zonepath=/devzones/test/rtdev02zone002.rze.de.db.com


add net
set address=10.225.104.243/24
set physical=vnet1

end


add device
set match=/dev/console
end

add fs
set dir=/test
set special=rpool/ROOT/zfsroot/devzones/test11
set type=zfs
add options ro
end

add fs
set dir=/test1
set special=/zones
set type=lofs
add options rw
end

add net
set address=10.225.244.34/25
set physical=vnet0

end


add capped-memory
set physical=2g
set swap=4g
end

add dedicated-cpu
set ncpus=2
end
commit
exit

Continue creating the zone (y/N)?  y
[08.11.2012 15:52:31] Installing the zone "rtdev02zone002.rze.de.db.com" using the flashimage "/mnt1/flashimages/sol10000_00_os_1009_us_1.gbl.flashsun4v_iplno.fsh" ...
      Log File: /var/tmp/rtdev02zone002.rze.de.db.com.install_log..jaavj
    Installing: This may take several minutes...
Postprocessing: This may take a while...
   Postprocess: Updating the zone software to match the global zone...
   Postprocess: Zone software update complete
   Postprocess: Updating the image to run within a zone

        Result: Installation completed successfully.
      Log File: /devzones/test/rtdev02zone002.rze.de.db.com/root/var/log/rtdev02zone002.rze.de.db.com.install4718.log
[08.11.2012 16:12:37] Waiting up to 180 seconds for the zone to shutdown ..
...................
[08.11.2012 16:12:49] INFO: Executing the workaround for a bug in zone create: 'pkgadm sync -R "/devzones/test/rtdev02zone002.rze.de.db.com/root"  -q'
[08.11.2012 16:12:49] Preparing the zone "rtdev02zone002.rze.de.db.com" for running applications ...
[08.11.2012 16:12:50] Post configuring the zone "rtdev02zone002.rze.de.db.com"  ...
[08.11.2012 16:12:50] Copying additional files to the zone ...
[08.11.2012 16:12:50] Copying files from the template directory "/template1" ...
0 blocks
[08.11.2012 16:12:50] Copying files from the template directory "/template2" ...
0 blocks
[08.11.2012 16:12:50] Copying file "/var/db/var/query_postinstall.conf" to the non-global zone ...
[08.11.2012 16:12:50] WARNING: The file "/var/db/var/installed_x_services" does not exist in the global zone. Ignoring this entry.
[08.11.2012 16:12:50] Copying file "/etc/ssh/sshd_config" to the non-global zone ...
[08.11.2012 16:12:50] Copying file "/var/tmp/TestFile" to the non-global zone ...
[08.11.2012 16:12:50] Copying file "/var/tmp/create_cdm_user.sh" to the non-global zone ...
[08.11.2012 16:12:50] INFO: Changing the file "/devzones/test/rtdev02zone002.rze.de.db.com/root/etc/TIMEZONE" ...
[08.11.2012 16:12:50] Changing the nameserver configuration of the zone "rtdev02zone002.rze.de.db.com" ...
[08.11.2012 16:12:50] Processing the file "/etc/resolv.conf" ...
[08.11.2012 16:12:50] Processing the file "/etc/nsswitch.conf" ...
[08.11.2012 16:12:50] Installing the customize script "/etc/rcS.d/S99customize_script" in the zone "rtdev02zone002.rze.de.db.com" ...
[08.11.2012 16:12:50] Creating the zone creation config file "/devzones/test/rtdev02zone002.rze.de.db.com/root/etc/create_zone.cfg" ...
[08.11.2012 16:12:51]  ... done. zone "rtdev02zone002.rze.de.db.com" installed and configured
[08.11.2012 16:12:51] The log file used was "/var/tmp/create_zone.LOG"
[08.11.2012 16:12:51] create_zone.sh v1.1.20 ended on Thu Nov  8 16:12:51 CET 2012.
[08.11.2012 16:12:51] The RC is 0.

real    20m58.328s
user    9m45.594s
sys     8m29.274s



Back to top

Internas


Note: See also the documentation for the script template used for this script: scriptt.sh

Sample config file for create_zone.sh v1.1.15 (using the parameter -C):


# config file for create_zone.sh v1.1.15, created Fri Sep 18 18:04:02 CEST 2009


# extension for backup files

  DEFAULT_BACKUP_EXTENSION=".$$.backup"

## EXCLUSIVE_IP_STACK_CONFIG_FILES
##   network configuration files that will be copied from the global zone
##   to the non-global zone if an exclusive IP stack is used
##   Note: Add only fully qualified filenames here!
##
  EXCLUSIVE_IP_STACK_CONFIG_FILES="
/etc/netmasks
/etc/networks
/etc/defaultrouter
/etc/hosts
"

## NAME_SERVER_CONFIG_FILES
##   name server configuration files
##   Note: Add only fully qualified filenames here!
##
  NAME_SERVER_CONFIG_FILES="
/etc/resolv.conf
/etc/nsswitch.conf
"

## DEFAULT_FREE_SPACE_FOR_THE_ZONE
##   free space neccessary for the zone in KB
##   (the default depends on the type of the zone)
##
  DEFAULT_FREE_SPACE_FOR_THE_ZONE=""

## DEFAULT_FREE_SPACE_FOR_A_BIG_ZONE
##   default free space needed for a big zone in kb
##
  DEFAULT_FREE_SPACE_FOR_A_BIG_ZONE=3500000

## DEFAULT_FREE_SPACE_FOR_A_SMALL_ZONE
##   default free space needed for a small zone in kb
##
  DEFAULT_FREE_SPACE_FOR_A_SMALL_ZONE=200000

## DEFAULT_ZONE_MODE
##   default type of the new zone;
##   possible values: small (= sparse zone) or big (= whole root zone)
##
  DEFAULT_ZONE_MODE="small"

## DEFAULT_ZONE_CLONE_SOURCE
##   source zone for cloning
##
  DEFAULT_ZONE_CLONE_SOURCE=""
 
## DEFAULT_ZONE_PATH
##   base directory for zones (can be a symbolic link;
##   this will be resolved by the script)
##
  DEFAULT_ZONE_PATH="/zones"

## DEFAULT_ZONE_ROOT_PASSWORD
##   default for the root password is the password
##   of the existing root user
## 
  DEFAULT_ZONE_ROOT_PASSWORD="$( grep root /etc/shadow 2>/dev/null | cut -f2 -d ":" )"

## DEFAULT_ZONE_TZ
##   the default timezone is the timezone of the machine
##
  DEFAULT_ZONE_TZ="$( grep "^TZ=" /etc/TIMEZONE 2>/dev/null | cut -f2 -d"=" )"
  [ "${DEFAULT_TZ}"x = ""x ] && DEFAULT_TZ="${TZ}"

## DEFAULT_ZONE_LOCALE
##   default locale is the current locale
##
  DEFAULT_ZONE_LOCALE="${LANG}"
  [ "${DEFAULT_ZONE_LOCAL}"x = ""x ] && DEFAULT_ZONE_LOCALE="C"

## DEFAULT_ZONE_TERMINAL 
##   default terminal type for the zone
##
  DEFAULT_ZONE_TERMINAL="${TERM:-vt100}"

## DEFAULT_ZONE_TIMESERVER
##   default timeserver for the zones
##
  DEFAULT_ZONE_TIMESERVER="localhost"

## DEFAULT_ZONE_CUSTOMIZE_SCRIPT_SOURCE 
##   default customize script for the zone
##   Possible values for this variabe are:
##       "builtin", "none", or the name of an existing script
##   The customize script runs inside the new zone
##   while first rebooting the zone
##
  DEFAULT_ZONE_CUSTOMIZE_SCRIPT_SOURCE="builtin"

## DEFAULT_ZONE_CUSTOMIZE_SCRIPT_TARGET
##   fully qualified name of the customize script inside the zone
##
##   Note: The runlevel in which the script runs depends on the path of the
##         customize scripts
##         The default is rcS.d = multi-user-server
##      
  DEFAULT_ZONE_CUSTOMIZE_SCRIPT_TARGET="/etc/rcS.d/S99customize_script"

## DEFAULT_ZONE_SMF_PROFILE
##   SMF site profile for the zone; default: none
##
  DEFAULT_ZONE_SMF_PROFILE=""

## DEFAULT_ZONE_IP_ADDRESS 
##   there is no default IP address for the zone
##
  DEFAULT_ZONE_IP_ADDRESS=""

## DEFAULT_ZONE_IP_STACK
##   this can be either SHARED or EXCLUSIVE; the default is SHARED
##
  DEFAULT_ZONE_IP_STACK="SHARED"

## DEFAULT_ZONE_NETMASK
##  netmask for the zone (only used for zones with exclusive IP stack!)
##
  DEFAULT_ZONE_NETMASK=""
 
## DEFAULT_ZONE_DEFAULT_ROUTER
##  default router for the zones
##  Note: A default router for a zone can only be configured for zones in Solaris 10 Update 6 and newer
##
  DEFAULT_ZONE_DEFAULT_ROUTER=""
#  $(  netstat -rn | grep "^default" | tr -s " " | cut -f2 -d " " | head -1 )"
 
## ZONE_GLDV3_CHECK
##   Do check the GLDv3 capabiltiy (yes, default) of the network adapter or not (no)
##
  DEFAULT_ZONE_GLDV3_CHECK="yes"

## DEFAULT_ZONE_NAME
##   there is no default name for the zone
##
  DEFAULT_ZONE_NAME=""

## DEFAULT_ZONE_GLOBAL_OPTIONS
##   additional global options for the zone
##   (e.g. bootargs, pool, limitpriv, etc)
##   Please note that the script DOES not check the syntax or semantic for these entries!
##
  DEFAULT_ZONE_GLOBAL_OPTIONS=""
  
## DEFAULT_USE_EXISTING_NAMESERVER_CONFIG
##   default nameserver configuration is:
##     use the existing nameserver configuration
##
  DEFAULT_USE_EXISTING_NAMESERVER_CONFIG=${__TRUE}

## DEFAULT_ZONE_AUTOBOOT
##   enable zone autoboot?; default is false
##
  DEFAULT_ZONE_AUTOBOOT=${__FALSE}

## DEFAULT_ZONE_NETWORK_INTERFACE
##   the default network interface for the zone
##   The default is the network interface which hosts the
##   network with the IP address for the zone
##
  DEFAULT_ZONE_NETWORK_INTERFACE=""

## DEFAULT_BOOT_THE_ZONE_NOW
##   boot the zone after installation?
##
  DEFAULT_BOOT_THE_ZONE_NOW=${__FALSE}

## DEFAULT_ZONE_MEMORY_LIMIT
##   the memory limit for the zone
##   There is no default for this keyword
##   Note that this configuration is only supported in
##   Solaris 10 8/07 and newer!
## 
  DEFAULT_ZONE_MEMORY_LIMIT=""

## DEFAULT_ZONE_SWAP_LIMIT
##   the swap limit for the zone
##   There is no default for this keyword
##   Note that this configuration is only supported in
##   Solaris 10 8/07 and newer!
##
  DEFAULT_ZONE_SWAP_LIMIT=""

## DEFAULT_ZONE_CPU_COUNT
##   the number of CPUs for the zone
##   There is no default for this keyword
##   Note that this configuration is only supported in
##   Solaris 10 8/07 and newer!
##
  DEFAULT_ZONE_CPU_COUNT=""

## DEFAULT_ZONE_CPU_SHARES
##   the number of CPU shares for the zone
##   There is no default for this keyword
##   Note that this configuration is only supported in
##   Solaris 10 8/07 and newer!
##
  DEFAULT_ZONE_CPU_SHARES=""

## DEFAULT_ZONE_INHERITED_DIRS
##   add. directories that should be inherited by the zone
##   Note: Directories with space or tabs in the name are NOT supported!
##
  DEFAULT_ZONE_INHERITED_DIRS=""

## DEFAULT_ZONE_WRITABLE_DIRS
##   directories that should be mounted r/w in the zone
##   Format of the entries:
##      zone_dir:global_dir
##   Note: Directories with space or tabs in the name are NOT supported!
##
  DEFAULT_ZONE_WRITABLE_DIRS=""

## DEFAULT_ZONE_READONLY_DIRS
##   directories that should be mounted r/o in the zone
##   Format of the entries:
##      zone_dir:global_dir
##   Note: Directories with space or tabs in the name are NOT supported!
##
  DEFAULT_ZONE_READONLY_DIRS=""

## DEFAULT_ZONE_DATASETS
##   ZFS datasets for the zone
##
  DEFAULT_ZONE_DATASETS=""

## DEFAULT_ZONE_DEVICES
##
  DEFAULT_ZONE_DEVICES=""
 
## DEFAULT_EDIT_ZONE_CONFIG
##   edit the zone configuration before creating the zone
##   after exiting the editor the user can choose to continue
##   or to abort the zone installation
##
  DEFAULT_EDIT_ZONE_CONFIG=${__FALSE}

## DEFAULT_ZONE_TEMPLATE_DIRS
##   Template directories for the zone; all files and directories in the
##   directories listed in this variable are copied to the root dir of the
##   zone
  if [ -d "${DEFAULT_ZONE_PATH}/template_dir" ] ; then
    ZONE_TEMPLATE_DIRS="${DEFAULT_ZONE_PATH}/template_dir"
  else
    ZONE_TEMPLATE_DIRS=""
  fi

## DEFAULT_ZONE_FILES_TO_COPY
##   File which should be copied from the global zone to the non-global zone
##   The file(s) are copied to the same location in the non-global zone
##
  DEFAULT_ZONE_FILES_TO_COPY=""

## DEFAULT_ZONE_FINISH_SCRIPT
##
##   finish script for creating the zone
##   This script is called in the global zone after the new
##   zone is created and configured but before it is booted
##   The parameters for the script are
##     - the fully qualified name of the directory for the zone
##
##   Note: Please write your finish scripts so that they handle multiple parameter correct
##         because there may be additional parameter in a future version of this script!
##
##   The finish script must return 0 if everything is okay; everthing else
##   is interpreted as error and the zone creation is aborted
##
##   Note that you can change the configuration of the zone from within the finish script
##   with a few exceptions (e.g. you can NOT add directories to inherit here)
##
##   All environment variables beginning with ZONE_ are exported and can be used by the
##   finish script. The exported variables are:
##
##     ZONE_AUTOBOOT
##     ZONE_CLONE_SOURCE
##     ZONE_CUSTOMIZE_SCRIPT_CONTENTS
##     ZONE_CUSTOMIZE_SCRIPT_SOURCE
##     ZONE_CUSTOMIZE_SCRIPT_TARGET
##     ZONE_FINISH_SCRIPT
##     ZONE_IP_ADDRESS
##     ZONE_LOCALE
##     ZONE_MODE
##     ZONE_NAME
##     ZONE_NETWORK_INTERFACE
##     ZONE_PATH
##     ZONE_ROOT_PASSWORD
##     ZONE_SMF_PROFILE
##     ZONE_TERMINAL
##     ZONE_TIMESERVER
##     ZONE_TZ
##     ZONE_IP_STACK
##     ZONE_NETMASK
##     ZONE_DEFAULT_ROUTER
##     ZONE_MEMORY_LIMIT
##     ZONE_SWAP_LIMIT
##     ZONE_CPU_COUNT
##     ZONE_CPU_SHARES
##     ZONE_INHERITED_DIRS
##     ZONE_WRITABLE_DIRS
##     ZONE_READONLY_DIRS
##     ZONE_DATASETS
##     ZONE_GLDV3_CHECK
##     ZONE_GLOBAL_OPTIONS
##     ZONE_DEVICES
##     ZONE_TEMPLATE_DIRS
##     ZONE_FILES_TO_COPY
##
##
  DEFAULT_ZONE_FINISH_SCRIPT=""

## DEFAULT_ZONE_CUSTOMIZE_SCRIPT_CONTENTS
##   builtin customize script for the zones
##   The customize script runs inside the new zone while first
##   booting the zone
##
  DEFAULT_ZONE_CUSTOMIZE_SCRIPT_CONTENTS="
  echo \"Customization of the zone is running ...\"

  echo \"Disabling sendmail ...\"
  svcadm disable sendmail
  svcadm disable svc:/application/cde-printinfo:default

  echo \" ... customization done. Removing the customize script\"
  rm \$0
"
 
# only change the following variables if you know what you are doing #

  ZONE_CONFIG_FILE="/etc/create_zone.cfg"

# no further internal variables defined yet
#
# Note you can redefine any variable that is initialized before calling
# ReadConfigFile here!








Back to top

Notes

Please see the source code of the script for additional information

See also zadmin - a script to maintain zones in Solaris


Back to top

Download


Download create_zone.sh




Back to top