<!-- 
The contents of this Documentation are subject to the Public Documentation
License Version 1.01 (the "License"); you may only use this Documentation if
you comply with the terms of this License. A copy of the License is
available at http://www.opensolaris.org/os/community/documentation/license.
-->

<chapter id="image"><title>Creating and Managing Images</title><highlights><para>IPS enables you to create and manage images on your OpenSolaris system. <emphasis role="strong">An installed OpenSolaris system constitutes an image</emphasis>.
Packages can be installed directly within this image. New images are created
to mark a boundary between the packages installed in different images.</para>
</highlights><sect1><title>Why Should You Create an Image?</title><para>The <command>pkg</command> command can be used to create and manage
images. The <command>pkg image-create</command> subcommand sets up a relationship
between the image, a publisher and a package repository that can be used to
retrieve package information and content and perform packaging operations
within an image.</para><para>An image is a location on your system where packages and their associated
files, directories, links, and dependencies can be installed.</para><para>An image can be one of these types:</para><itemizedlist><listitem><para>Full images, capable of providing a complete system</para>
</listitem><listitem><para>Partial images, which are linked to a full image (parent image),
but do not provide a complete system on their own</para>
</listitem><listitem><para>User images, which contain only relocatable packages</para>
</listitem>
</itemizedlist><para>After you have completed the installation of the OpenSolaris 2009.06
release on your system, the root file system and its contents are already
contained within an image.  As a result, you do not need to create an image
to perform software management tasks for the installed system.  However, creating
images is required to provide logical separation between different software
applications, such as those that occur during a zone creation process.</para><para>The following figure shows the concept of an image:</para><figure id="giiit"><title>Concept of an Image</title><mediaobject><imageobject><imagedata entityref="image"/>
</imageobject><textobject><simpara></simpara>
</textobject>
</mediaobject>
</figure><para>See the Zones section in the <ulink url="http://docs.sun.com/app/docs/doc/817-1592/zone?l=en&amp;a=view&amp;q=zones" type="text"><citetitle>Solaris Containers - Resource Management and Solaris
Zones</citetitle></ulink> guide to learn about zones.</para><para>The following image creation and image management tasks are supported:</para><note><para>See the <olink type="auto-generated" targetptr="pkgtbl" remap="internal"></olink> section
for a complete list of options supported with each pkg(1) command.</para>
</note><itemizedlist><listitem><para><olink type="auto-generated" targetptr="giifi" remap="internal"></olink></para>
</listitem><listitem><para><olink type="auto-generated" targetptr="giigl" remap="internal"></olink></para>
</listitem><listitem><para><olink type="auto-generated" targetptr="giiji" remap="internal"></olink></para>
</listitem><listitem><para><olink type="auto-generated" targetptr="giiiq" remap="internal"></olink></para>
</listitem><listitem><para><olink type="auto-generated" targetptr="gikyb" remap="internal"></olink></para>
</listitem>
</itemizedlist><task id="giifi"><title>How to Create an Image</title><taskprerequisites><para>Ensure that you have write privileges to the directory where you are
attempting to create an image.</para><para>See the <olink type="auto-generated" targetptr="gilfr" remap="internal"></olink> section
for important information about image creation.</para>
</taskprerequisites><procedure remap="single-step"><step><para>Use the following command to create an image. A user image is
created by default.</para><para><command>$ pfexec pkg image-create <option>[R]</option><option>[FfPUz]</option> <option>p</option> <replaceable>prefix=repository_url</replaceable> <replaceable>directory_location</replaceable></command></para>
</step>
</procedure><example><title>Creating a Full Image</title><para>In this example, a full image is created with a package repository located
at <literal>http://pkg.example.com</literal>, with <literal>example.com</literal> set
as the preferred publisher. The image is created in the directory <literal>/aux0/example_root</literal>. The <option>p</option> option is used to specify the location
of the package repository such as http://pkg.example.com/.</para><screen><command>$ pfexec pkg image-create -F -p 
example.com=http://pkg.example.com/ /aux0/example_root</command></screen>
</example>
</task><task id="giigl"><title>How to Display Image Properties</title><procedure remap="single-step"><step><para>Use the following command to view the properties of an image :</para><para><command>$ pkg property [<option>H</option>] [<replaceable>propname</replaceable>]</command></para><para>The following properties are displayed :</para><informaltable frame="topbot"><tgroup cols="2" colsep="0" rowsep="0"><colspec colwidth="50*"/><colspec colwidth="50*"/><tbody><row><entry><para>Property Name</para>
</entry><entry><para>Description</para>
</entry>
</row><row><entry><para>send-uuid</para>
</entry><entry><para>This property causes the client to include a Universally Unique Identifier
(UUID) in transactions with servers for the image. This property enables the
server to uniquely identify clients. </para>
</entry>
</row><row><entry><para>require-optional</para>
</entry><entry><para>This property forces packages that are listed as an optional dependency
of another package to be installed during installation, upgrade, or removal
of a package.</para>
</entry>
</row><row><entry><para>flush-content-cache-on-success</para>
</entry><entry><para>A value of <filename>True</filename> will cause the download cache to
be purged for the image upon successful completion of a packaging operation
such as installation, uninstallation, or an image-update.</para>
</entry>
</row><row><entry><para>display-copyrights</para>
</entry><entry><para>Read&mdash;only for OpenSolaris 2009.06 release.</para>
</entry>
</row><row><entry><para>preferred-publisher</para>
</entry><entry><para>Read&mdash;only for OpenSolaris 2009.06 release.</para>
</entry>
</row><row><entry><para>pursue-latest</para>
</entry><entry><para>Read&mdash;only for OpenSolaris 2009.06 release.</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</step>
</procedure><example id="giijk"><title>Displaying Image Property</title><screen>$ pkg property 
PROPERTY                       VALUE 
send-uuid                      False 
require-optional               False 
flush-content-cache-on-success  False 
display-copyrights             True 
preferred-publisher            opensolaris.org 
pursue-latest                  True</screen>
</example>
</task><task id="giiji"><title>How to Set Image Properties</title><procedure remap="single-step"><step><para>Use the following command to set the property of an image:</para><para><command>$ pfexec pkg set-property <replaceable>propname</replaceable></command></para><note><para>The following properties are read-only and cannot be set using
this command.</para><itemizedlist><listitem><para>display-copyrights</para>
</listitem><listitem><para>preferred-publisher</para>
</listitem><listitem><para>pursue-latest</para>
</listitem>
</itemizedlist>
</note>
</step>
</procedure><example id="giifk"><title>Set the Value of an Image Property</title><para>This example sets the value of the <filename>send-uuid</filename> property.</para><screen>$ pkg  property
PROPERTY                       VALUE
send-uuid                      False
require-optional               False
flush-content-cache-on-success False
display-copyrights             True
preferred-publisher            opensolaris.org
pursue-latest                  True

$ pkg -R set-property send-uuid True
$ pkg property
PROPERTY                       VALUE
send-uuid                      True
require-optional               False
flush-content-cache-on-success False
display-copyrights             True
preferred-publisher            local
pursue-latest                  True </screen>
</example>
</task><task id="giiiq"><title>How to Remove Image Properties</title><procedure remap="single-step"><step><para>Use the following command to remove one or more properties of
an image.</para><para><command>$ pfexec pkg unset-property <replaceable>propname</replaceable></command></para><para>The <command>pkg unset-property</command> command removes the specified
properties and resets the property to the default value the next time a <citerefentry><refentrytitle>pkg</refentrytitle><manvolnum>1</manvolnum></citerefentry>command
is executed.</para><note><para>The following properties are read-only and cannot be removed by
using this command.</para><itemizedlist><listitem><para>display-copyrights</para>
</listitem><listitem><para>preferred-publisher</para>
</listitem><listitem><para>pursue-latest</para>
</listitem>
</itemizedlist>
</note>
</step>
</procedure><example id="giigw"><title>Remove an Image Property</title><para>This example removes the <filename>send-uuid</filename> property. </para><screen>$ pkg unset-property send-uuid
$ pkg property
PROPERTY                       VALUE
send-uuid                      False
require-optional               False
flush-content-cache-on-success False
display-copyrights             True
preferred-publisher            local
pursue-latest                  True </screen>
</example>
</task><task id="gikyb"><title>How to Update an Image (Update All Installed Packages)</title><tasksummary><para>This task updates all installed packages in the current image to the
latest available version.</para><note><para>All packages that have been updated in the repository will be
downloaded and installed.</para><para>All packages for the publishers configured
in the image, excluding disabled publishers, will be retrieved and upgraded
for those that have newer versions available. If more than one publisher offers
the same package, then the package will be downloaded from the preferred publisher.</para>
</note>
</tasksummary><procedure remap="single-step"><step><para>Use the following command to update all packages in the current
image to the latest version.</para><para><command>$ pfexec pkg image-update</command></para>
</step>
</procedure><example id="gilsd"><title></title><screen>$ pfexeec pkg image-update 
A clone of opensolaris exists and has been updated and activated.
On next boot the Boot Environment opensolaris-1 will be mounted on '/'.  
Reboot when ready to switch to this updated BE.
os# beadm list  
BE     Active Active on Mountpoint Space
Name  reboot               Used 
----   ------ --------- ---------- -----
opensolaris   yes    no   legacy   57.5K 
opensolaris-1 no     yes       -    2.59G </screen><para>In this example, the initial boot environment created by the installer
is named opensolaris. The boot environment created by the <command>pkg image-update</command> command is automatically named opensolaris-1.</para><para>After rebooting to the changed boot environment, any inactive boot environment
can be destroyed to save space by running the <command>beadm destroy</command> command.
For more information regarding boot environments and the <command>beadm(1)</command> command,
see the <ulink url="http://dlc.sun.com/osol/docs/content/IPS/snap3.html" type="text">Upgrading and Managing Your Boot Environments</ulink> section.</para>
</example><example id="gikzz"><title>Update an Image in a Mounted, Inactive Boot Environment</title><para>This example updates an image in a boot environment that is mounted
at <filename>/mnt</filename>. </para><screen># beadm mount BE1 /mnt
# pkg -R /mnt image-update</screen>
</example><taskrelated role="see-also"><para><olink type="auto-generated" targetptr="giloe" remap="internal"></olink></para>
</taskrelated>
</task><sect2 id="gilfr"><title>Image Creation: Important Considerations</title><itemizedlist><listitem><para>When using the <command>image-create</command> subcommand,
avoid creating an image at the location of an already existing image such
as <filename>/</filename> for an installed system or within a directory contained
within an existing package such as <filename>/usr</filename>. This will cause
you to lose packaging information within an image, or prevent IPS from properly
managing packages within the image.</para>
</listitem><listitem><para>You must set publisher and package repository information
when you create an image. Use the <option>p</option> option to provide this
information.</para>
</listitem><listitem><para>When you have multiple images on your system, use the <literal>PKG_IMAGE</literal> environment variable or the <option>R</option> option to specify
what image you're operating on.</para>
</listitem><listitem><para>The current design of IPS assumes that only one version of
a package is installed in a single image. To install multiple versions of
the same package, ensure that the name of the package includes the version
number, and dependencies reflect the version number and bind to the appropriate
package version.</para>
</listitem>
</itemizedlist>
</sect2><sect2 id="giloe"><title>Updating Your Image: Important Considerations</title><itemizedlist><listitem><para>When you run the <command>pkg image-update</command> command
or update your image using the Package Manager, the process of updating all
the packages automatically creates a clone: a new, bootable environment. The
process of updating all the packages applies the changes to the clone instead
of to the original boot environment. After the successful completion of the
changes to the clone and system reboot, the new clone is provided as the default,
active boot environment in the GRUB menu. The original boot environment remains
on the GRUB menu as an alternate selection.</para><para>A clone of the boot
environment includes everything hierarchically under the main root dataset
of the original boot environment. Shared file systems are not under the root
dataset and are not cloned. Instead, the boot environment accesses the original
shared file systems.</para>
</listitem><listitem><para>The <command>pkg image-update</command> command <emphasis role="strong">does not upgrade</emphasis> zones. If you have included zones
in your OpenSolaris environment, the <command>pkg image-update</command> command
clones these existing zones into the new boot environment, but these zones
are not upgraded. You must manually upgrade each of these zones.</para>
</listitem><listitem><para>After upgrading an image or boot environment, you can use
the <command>beadm list</command> command to see a list of the boot environments
on the system, including the new boot environment that was created by the <command>pkg image-update</command> command.</para>
</listitem>
</itemizedlist>
</sect2>
</sect1>
</chapter>