<chapter id="topdown-tasks-chap"><title>Top-Down
Volume Creation (Tasks)</title><highlights><para>This chapter provides tasks associated with Solaris Volume Manager top-down volume
creation using the <command>metassist</command> command.</para><para>This is a list of the information in this chapter:</para><itemizedlist><listitem><para><olink targetptr="tasks-topdown-13" remap="internal">Top-Down Volume Creation
(Task Map)</olink></para>
</listitem><listitem><para><olink targetptr="tasks-topdown-15" remap="internal">Prerequisites for Top-Down
Volume Creation</olink></para>
</listitem><listitem><para><olink targetptr="ewaus" remap="internal">Creating Volumes Automatically</olink></para>
</listitem><listitem><para><olink targetptr="tasks-topdown-16" remap="internal">Working With File-Based
Data Using the metassist Command</olink></para>
</listitem><listitem><para><olink targetptr="tasks-topdown-12" remap="internal">Changing the Default Behavior
of the metassist Command</olink></para>
</listitem>
</itemizedlist><para>For conceptual information about top-down volume creation, see <olink targetptr="topdown-overview" remap="internal">Chapter&nbsp;22, Top-Down Volume Creation (Overview)</olink>.</para>
</highlights><sect1 id="tasks-topdown-13"><title>Top-Down Volume Creation (Task Map)</title><para>The following task map identifies the procedures needed to create Solaris Volume Manager volumes
using the <command>metassist</command> command. This command enables you to
specify volumes based on quality-of-service characteristics and to create
sets of layered volumes with a single command. </para><informaltable frame="topbot"><tgroup cols="3" colsep="0" rowsep="0"><colspec colwidth="33*"/><colspec colwidth="33*"/><colspec colwidth="33*"/><thead><row rowsep="1"><entry><para>Task</para>
</entry><entry><para>Description</para>
</entry><entry><para>Instructions</para>
</entry>
</row>
</thead><tbody><row><entry><para>Create volumes automatically</para>
</entry><entry><para>Enables you to use the <command>metassist</command> command to create
one or more Solaris Volume Manager volumes. </para><para>Also, enables you to control the amount of information about the volume
creation process that the <command>metassist</command> command provides for
troubleshooting or for diagnosing problems. </para>
</entry><entry><para><olink targetptr="ewaus" remap="internal">Creating Volumes Automatically</olink></para><para><olink targetptr="ewaut" remap="internal">Analyzing Volume Creation by Specifying Output
Verbosity</olink></para>
</entry>
</row><row><entry><para>Create a command file</para>
</entry><entry><para>Helps you create a shell script with the <command>metassist</command> command
to generate the volumes that the command specifies. </para>
</entry><entry><para><olink targetptr="tasks-topdown-9" remap="internal">Creating a Volume Configuration File
With the metassist Command</olink></para>
</entry>
</row><row><entry><para>Create a volume with a shell script</para>
</entry><entry><para>Shows you how to create the Solaris Volume Manager volumes that the <command>metassist</command> command specified with the shell script previously generated by
the command.</para>
</entry><entry><para><olink targetptr="tasks-topdown-25" remap="internal">Creating a Volume With a Saved Shell
Script Created by the metassist Command</olink></para>
</entry>
</row><row><entry><para>Create a volume configuration file</para>
</entry><entry><para>Helps you create a volume configuration file, describing the characteristics
of the volumes you want to create. </para>
</entry><entry><para><olink targetptr="tasks-topdown-9" remap="internal">Creating a Volume Configuration File
With the metassist Command</olink></para>
</entry>
</row><row><entry><para>Change the volume defaults file</para>
</entry><entry><para>Allows you to set default volume characteristics to customize the behavior
of <command>metassist</command> command.</para>
</entry><entry><para><olink targetptr="tasks-topdown-130" remap="internal">Changing the Volume Defaults File</olink></para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</sect1><sect1 id="tasks-topdown-15"><title>Prerequisites for Top-Down Volume Creation</title><para>Creating volumes and volume configurations automatically using the <command>metassist</command> command requires that you have a functional Solaris Volume Manager configuration.
Before you begin, you should have the following:</para><itemizedlist><listitem><para>Superuser access, or be able to assume an equivalent role-based
access control (RBAC) role. See <olink targetdoc="sysadv1" targetptr="smcover-149" remap="external"><citetitle remap="section">Becoming Superuser (root)
or Assuming a Role</citetitle> in <citetitle remap="book">System Administration
Guide: Basic Administration</citetitle></olink> for more information.</para>
</listitem><listitem><para>State database replicas, distributed appropriately for your
system. See <olink targetptr="about-state-db-replicas-8" remap="internal">About the Solaris
Volume Manager State Database and Replicas</olink> for more information about
state database replicas.</para>
</listitem><listitem><para>Available disks for creating volumes. The <command>metassist</command> command
uses disk sets to help manage storage. Completely unused disks (or an existing
disk set) must be available to create new volumes using the <command>metassist</command> command.
See <olink targetptr="ewatu" remap="internal">Determining Which Disks Are Available for Top-Down
Volume Creation</olink> for more information about disk availability.</para>
</listitem>
</itemizedlist><para>In addition to these minimum requirements, do not disable the Solaris Volume Manager RPC
daemons (<filename>rpc.metad</filename>, <filename>rpc.metamhd</filename>,
and <filename>rpc.metamedd)</filename> in the <filename>/etc/inetd.conf</filename> file.
These daemons are configured to start by default. They must remain enabled
to allow Solaris Volume Manager to use shared disk sets.</para>
</sect1><sect1 id="ewaus"><title>Creating Volumes Automatically</title><para>The <command>metassist</command> command enables you to create Solaris Volume Manager volumes,
as well as sets of volumes, based on quality-of-service criteria. The <command>metassist</command> command creates volumes for you with one command, rather than the
series of commands that Solaris Volume Manager traditionally requires to create volumes.</para><para>You can use the <command>metassist</command> command to create RAID-1
(mirror) volumes directly. Thus, you do not have to first create the submirrors
(concatenations or stripes) that are used as components of the RAID-1 (mirror)
volume.</para><sect2 id="ewaut"><title>Analyzing Volume Creation by Specifying Output Verbosity</title><para>When you run the <command>metassist</command> command, you can specify
the level of verbose output. More verbose output can help diagnose problems,
such as determining why disks were or were not selected for use in a volume,
or to determine why a specific attempted command failed. Less verbose output
can reduce the amount of extraneous information that you must review. </para><para>When you specify output verbosity, you can learn what the <command>metassist</command> command does and how it makes its decisions. This information is
useful for troubleshooting some of the following:</para><itemizedlist><listitem><para>Why a volume was created in a certain way</para>
</listitem><listitem><para>Why a volume was not created</para>
</listitem><listitem><para>What volumes the <command>metassist</command> command would
create, without actually creating the volumes</para>
</listitem>
</itemizedlist>
</sect2><task id="exlvu"><title>How to Create RAID-1 (mirror) Volumes Using the <command>metassist</command> Command</title><taskprerequisites><para>Check <olink targetptr="tasks-topdown-15" remap="internal">Prerequisites for Top-Down
Volume Creation</olink>.</para>
</taskprerequisites><procedure><step><para>Identify the available storage on which to create the volume.</para><para>If you do not explicitly specify storage, Solaris Volume Manager identifies unused
storage on the system and uses it, as appropriate. If you choose to specify
storage, either broadly (for example, all storage on controller 1) or specifically
(for example, use <literal>c1t4d2</literal>, but do not use <literal>c1t4d1</literal>), Solaris Volume Manager uses
the storage you specify.</para>
</step><step><para>Use the <command>metassist</command> command and the appropriate
options for your task.</para><itemizedlist><listitem><para>To create volumes from the command line, use the following
form of the <command>metassist</command> command.</para><screen># <userinput>metassist create -s <replaceable>diskset-name</replaceable> -f -r <replaceable>redundancy</replaceable> -a <replaceable>device1, device2...</replaceable> -S <replaceable>size</replaceable> -v <replaceable>verbosity</replaceable></userinput></screen><variablelist><varlistentry><term><command>create</command></term><listitem><para>Is the subcommand used to create volumes.</para>
</listitem>
</varlistentry><varlistentry><term><option>s</option> <replaceable>diskset-name</replaceable></term><listitem><para>Specifies the name of the disk set to use for the volume.</para>
</listitem>
</varlistentry><varlistentry><term><option>f</option></term><listitem><para>Specifies that the volume be associated with a hot spare.</para>
</listitem>
</varlistentry><varlistentry><term><option>r</option> <replaceable>redundancy</replaceable></term><listitem><para>Specifies the level of redundancy (number of data copies)
to create.</para>
</listitem>
</varlistentry><varlistentry><term><option>a</option> <replaceable>device1, device2...</replaceable></term><listitem><para>Specifies the devices that are available for creating the
volume.</para>
</listitem>
</varlistentry><varlistentry><term><option>S</option> <replaceable>size</replaceable></term><listitem><para>Specifies the size of the volume to create in <literal>KB</literal>, <literal>MB</literal>, <literal>GB</literal>, or <literal>TB</literal>, for kilobytes,
megabytes, gigabytes, and terabytes, respectively.</para>
</listitem>
</varlistentry><varlistentry><term><option>v</option> <replaceable>verbosity</replaceable></term><listitem><para>Specifies how verbose the output should be. Allowable values
range from <literal>0</literal> (nearly silent output) to <literal>2</literal> (significant
output). The default level is <literal>1</literal> (moderate output).</para>
</listitem>
</varlistentry>
</variablelist>
</listitem><listitem><para>To create volumes using an input file to specify volume characteristics,
use one of the following forms of the <command>metassist</command> command.</para><screen># <userinput>metassist create [-v n] [-c] -F <replaceable>config_file</replaceable></userinput>
# <userinput>metassist create [-v n] [-c | -d] -F <replaceable>request_file</replaceable></userinput></screen><variablelist><varlistentry><term><option>c</option></term><listitem><para>Specifies to output the command script that would implement
the specified or generated volume configuration. The command script is not
run, and processing stops at this stage.</para>
</listitem>
</varlistentry><varlistentry><term><option>d</option></term><listitem><para>Specifies to output the volume configuration that satisfies
the specified or generated volume request. No command script is generated
or executed, and processing stops at this stage.</para>
</listitem>
</varlistentry><varlistentry><term><option>F</option> <replaceable>config_file | request_file</replaceable></term><listitem><para>Specifies the volume request or volume configuration file
to process. If <replaceable>config_file</replaceable> or <replaceable>request_file</replaceable> is specified as a dash (-), it is read from standard input.
The <option>d</option> option cannot be specified when input file is a volume
configuration file.</para><para>A volume configuration file describes detailed configurations of the
volumes to be created, while a volume request file provides characteristics
for the volumes to be produced. For more information, see <olink targetdoc="refman4" targetptr="volume-config-4" remap="external"><citerefentry><refentrytitle>volume-config</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink><olink targetdoc="refman4" targetptr="volume-config-4" remap="external"><citerefentry><refentrytitle>volume-config</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> and <olink targetdoc="refman4" targetptr="volume-request-4" remap="external"><citerefentry><refentrytitle>volume-request</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man pages.</para>
</listitem>
</varlistentry><varlistentry><term><option>v</option> <replaceable>verbosity</replaceable></term><listitem><para>Specifies how verbose the output should be. Allowable values
range from <literal>0</literal> (nearly silent output) to <literal>2</literal> (significant
output). The default level is <literal>1</literal> (moderate output).</para>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</itemizedlist><para>See the following examples and the <olink targetdoc="refman1m" targetptr="metassist-1m" remap="external"><citerefentry><refentrytitle>metassist</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page for more information.</para>
</step><step><para>Once you have created the volumes, view the new volumes.</para><screen># <userinput>metastat -s <replaceable>diskset-name</replaceable></userinput></screen>
</step>
</procedure><example id="ewaur"><title>Creating a Two-Way Mirror Using the <command>metassist</command> Command</title><para>The following example shows how to create a two-way mirror, 10 Mbytes
in size. The <command>metassist</command> command identifies unused disks
and creates the best mirror possible using those disks. The <option>s myset</option> argument
specifies that the volumes will be created in the <literal>myset</literal> disk
set. The disk set is created, if necessary.</para><screen># <userinput>metassist create -s myset -r 2 -S 10mb</userinput></screen>
</example><example id="esxkz"><title>Creating a Two-Way Mirror and Hot Spare Using the <command>metassist</command> Command</title><para>The following example shows how to use the <command>metassist</command> command
to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide
additional fault tolerance. The <option>f</option> option specifies the fault
tolerance.</para><screen># <userinput>metassist create -s myset -f -r 2 -S 10mb</userinput>
 </screen>
</example><example id="eteru"><title>Creating a Stripe With a Specific Controller Using the <command>metassist</command> Command</title><para>The following example shows how to use the <command>metassist</command> command
to create a stripe using disks available on controller 1. The <option>a</option> option
specifies the available controller.</para><screen># <userinput>metassist create -s myset -a c1 -S 10mb</userinput></screen>
</example><example id="ewauq"><title>Specifying Output Verbosity From the <command>metassist</command> Command</title><para>The following example shows how to use the <command>metassist</command> command
to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide
additional fault tolerance. The <option>f</option> option specifies fault
tolerance. The final argument (<option>v 2</option>) specifies a verbosity
level of two, which is the maximum level and will provide the most information
possible about how the <command>metassist</command> command worked. </para><screen width="100"># <userinput>metassist create -s myset -f -r 2 -S 10mb -v 2</userinput>
Scanning system physical device configuration...

  These HBA/Controllers are known:.
    c0                        /pci@1f,0/pci@1,1/ide@3
    c1                        /pci@1f,0/pci@1/pci@2/SUNW,isptwo@4

  These disks are known:

    c0t0d0                    id1,dad@AST34342A=____________VGD97101
    c1t1d0                    id1,sd@SSEAGATE_ST39204LCSUN9.0G3BV0L88P000021097XNL
    c1t2d0                    id1,sd@SSEAGATE_ST39102LCSUN9.0GLJW22867000019171JDF
    c1t3d0                    id1,sd@SSEAGATE_ST39204LCSUN9.0G3BV0L7RV00007108TG0H
    c1t4d0                    id1,sd@SSEAGATE_ST39204LCSUN9.0G3BV0LDFR000021087R1T
    c1t5d0                    id1,sd@SSEAGATE_ST39204LCSUN9.0G3BV0L0M200002109812L
    c1t6d0                    id1,sd@SSEAGATE_ST39204LCSUN9.0G3BV0L8K8000021087R0Z
.
.
.
(output truncated)</screen><para>The following example shows how to use the <command>metassist</command> command
to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide
additional fault tolerance. The <option>f</option> option specifies fault
tolerance. The final argument (<option>v 0</option>) specifies a verbosity
level of zero, which is the minimum level and will provide nearly silent output
when the command runs. </para><screen># <userinput>metassist create -s myset -f -r 2 -S 10mb -v 0</userinput>
myset/hsp000: Hotspare pool is setup
myset/hsp000: Hotspare is added
myset/d2: Concat/Stripe is setup
myset/d1: Concat/Stripe is setup
myset/d0: Mirror is setup
myset/d0: submirror myset/d1 is attached</screen>
</example><example id="ftytz"><title>Creating a Volume Using an Input File</title><para>The following example shows how to use the <command>metassist</command> command
to create a volume using an input file. </para><screen># <userinput>metassist create -F request.xml</userinput></screen><para>For more information on using input files with the <command>metassist</command> command,
see <olink targetptr="tasks-topdown-16" remap="internal">Working With File-Based Data Using
the metassist Command</olink>.</para>
</example>
</task>
</sect1><sect1 id="tasks-topdown-16"><title>Working With File-Based Data Using the <command>metassist</command> Command</title><para>The <command>metassist</command> command enables you to create files
that you can use to evaluate volume characteristics or for actual volume creation.</para><sect2 id="tasks-topdown-8"><title>Creating a Command File (Shell Script)
Using the <command>metassist</command> Command</title><para>By running the <command>metassist</command> command with the <option>c</option> argument,
you can generate a Bourne shell script containing the commands that would
be used to create the volume configuration. This technique enables you to
review the commands before actually creating the volume, or even to modify
the script somewhat to meet specific needs.</para>
</sect2><task id="ewavh"><title>How to Create a Command File (Shell Script) Using
the <command>metassist</command> Command</title><taskprerequisites><para>Check <olink targetptr="tasks-topdown-15" remap="internal">Prerequisites for Top-Down
Volume Creation</olink>.</para>
</taskprerequisites><procedure><step><para>Identify the available storage on which to create the volume.</para><para>If you do not explicitly specify storage, Solaris Volume Manager identifies unused
storage on the system and uses it, as appropriate. If you choose to specify
storage, either broadly (for example, all storage on controller 1) or specifically
(for example, use <literal>c1t4d2</literal>, but do not use <literal>c1t4d1</literal>), Solaris Volume Manager uses
the storage you specify.</para>
</step><step><para>Use the <command>metassist</command> command and the appropriate
options for your task.</para><para>Use the <option>c</option> option to specify
that the volume should not actually be created.</para><screen># <userinput>metassist create -s <replaceable>diskset-name</replaceable> -f -r <replaceable>redundancy</replaceable> -a <replaceable>device1, device2...</replaceable> \
 -S <replaceable>size</replaceable> -v <replaceable>verbosity</replaceable> [-c]</userinput></screen><variablelist><varlistentry><term><command>create</command></term><listitem><para>Is the subcommand used to create volumes.</para>
</listitem>
</varlistentry><varlistentry><term><option>s</option> <replaceable>diskset-name</replaceable></term><listitem><para>Specifies the name of the disk set to use for the volume.</para>
</listitem>
</varlistentry><varlistentry><term><option>f</option></term><listitem><para>Specifies that the volume be associated with a hot spare.</para>
</listitem>
</varlistentry><varlistentry><term><option>r</option> <replaceable>redundancy</replaceable></term><listitem><para>Specifies the level of redundancy (number of data copies)
to create.</para>
</listitem>
</varlistentry><varlistentry><term><option>a</option> <replaceable>device1, device2...</replaceable></term><listitem><para>Specifies the devices that are available for creating the
volume.</para>
</listitem>
</varlistentry><varlistentry><term><option>S</option> <replaceable>size</replaceable></term><listitem><para>Specifies the size of the volume to create in <literal>KB</literal>, <literal>MB</literal>, <literal>GB</literal>, or <literal>TB</literal>, for kilobytes,
megabytes, gigabytes, and terabytes, respectively.</para>
</listitem>
</varlistentry><varlistentry><term><option>v</option> <replaceable>verbosity</replaceable></term><listitem><para>Specifies how verbose the output should be. Allowable values
range from <literal>0</literal> (nearly silent output) to <literal>2</literal> (significant
output). The default level is <literal>1</literal> (moderate output).</para>
</listitem>
</varlistentry><varlistentry><term><option>c</option></term><listitem><para>Specifies that the volume should not actually be created.
Instead, a shell script that can be used to create the specified configuration
is sent to standard output.</para><note><para>The shell script required by the <option>c</option> argument is
sent to standard output, while the rest of the output from the <command>metassist</command> command goes to standard error. You can redirect the output streams
as you choose.</para>
</note><para>See the following examples and the <olink targetdoc="refman1m" targetptr="metassist-1m" remap="external"><citerefentry><refentrytitle>metassist</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page for more information.</para>
</listitem>
</varlistentry>
</variablelist>
</step>
</procedure><example id="ewavc"><title>Creating a Command File (Shell Script) Using the <command>metassist</command> Command</title><para>The following example shows how to use the <command>metassist</command> command
to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide
additional fault tolerance. The <option>f</option> option specifies fault
tolerance. The final argument (<option>c</option>) specifies that the volume
should not actually be created. Rather, a shell script that could be used
to create the specified configuration should be sent to standard output. </para><screen># <userinput>metassist create -s myset -f -r 2 -S 10mb -c</userinput>
(output truncated)
.
.
.
Volume request completed successfully.
#!/bin/sh

#
# Environment
#

# Amend PATH
PATH="/usr/sbin:/usr/bin:$PATH"
export PATH

# Disk set name
diskset='myset'

#
# Functions
#

# Echo (verbose) and exec given command, exit on error
execho () {
    test -n "$verbose" &amp;&amp; echo "$@"
    "$@" || exit
}

# Get full /dev/rdsk path of given slice
fullpath () {
    case "$1" in
        /dev/dsk/*|/dev/did/dsk/*) echo "$1" | sed 's/dsk/rdsk/' ;;
        /*) echo "$1" ;;
        *) echo /dev/rdsk/"$1" ;;
    esac
}

# Run fmthard, ignore partboot error, error if output
fmthard_special () {
    ignore='Error writing partboot'
    out=`fmthard "$@" 2>&amp;1`
    result=$?
    echo "$out" |
    case "$out" in
        *"$ignore"*) grep -v "$ignore"; return 0 ;;
        '') return "$result" ;;
        *) cat; return 1 ;;
    esac >&amp;2
}

#
# Main
#

# Verify root
if [ "`id | sed 's/^[^(]*(\([^)]*\).*/\1/'`" != root ]
then
    echo "This script must be run as root." >&amp;2
    exit 1;
fi

# Check for verbose option
case "$1" in
    -v) verbose=1 ;;
    *) verbose= ;;
esac
    
# Does the disk set exist?
if metaset -s "$diskset" >/dev/null 2>&amp;1
then
    # Take control of disk set
    execho metaset -s "$diskset" -t
else
    # Create the disk set
    autotakeargs=
    /usr/sbin/clinfo || autotakeargs='-A enable'
    execho metaset -s "$diskset" $autotakeargs -a -h `uname -n | cut -f1 -d.`
fi
    
# Format slices
execho fmthard_special -d 7:0:0:0:0 `fullpath c1t3d0s7`
execho fmthard_special -d 7:0:0:0:0 `fullpath c1t6d0s7`
execho fmthard_special -d 7:0:0:0:0 `fullpath c1t4d0s7`

# Add disks to set
execho metaset -s "$diskset" -a c1t3d0
execho metaset -s "$diskset" -a c1t6d0
execho metaset -s "$diskset" -a c1t4d0

# Format slices
execho fmthard_special -d 0:4:0:10773:17649765 `fullpath c1t3d0s0`
execho fmthard_special -d 0:4:0:10773:17649765 `fullpath c1t6d0s0`
execho fmthard_special -d 0:4:0:10773:17649765 `fullpath c1t4d0s0`
execho fmthard_special -d 1:4:0:17660538:21546 `fullpath c1t3d0s1`
execho fmthard_special -d 1:4:0:17660538:21546 `fullpath c1t4d0s1`
execho fmthard_special -d 1:4:0:17660538:21546 `fullpath c1t6d0s1`

# Does hsp000 exist?
metahs -s "$diskset" -i hsp000 >/dev/null 2>&amp;1 || {
    # Create hsp hsp000
    execho metainit -s "$diskset" hsp000
}

# Add slices to hsp000
execho metahs -s "$diskset" -a hsp000 c1t3d0s1

# Create concat d2
execho metainit -s "$diskset" d2 1 1 c1t4d0s1

# Associate concat d2 with hot spare pool hsp000
execho metaparam -s "$diskset" -h hsp000 d2

# Create concat d1
execho metainit -s "$diskset" d1 1 1 c1t6d0s1

# Associate concat d1 with hot spare pool hsp000
execho metaparam -s "$diskset" -h hsp000 d1

# Create mirror d0
execho metainit -s "$diskset" d0 -m d2 1
execho metattach -s "$diskset" d0 d1
# </screen>
</example><example id="eteth"><title>Saving a Command File (Shell Script) Using the <command>metassist</command> Command</title><para>The following example shows how to use the <command>metassist</command> command
to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide
additional fault tolerance. The <option>f</option> option specifies fault
tolerance. The final argument (<option>c</option>) specifies that the volume
should not actually be created. Rather, a shell script that could be used
to create the specified configuration should be sent to standard output. The
end of the command redirects standard output to create the <filename>/tmp/metassist-shell-script.sh</filename> shell script that can later be used to create the specified volume.</para><screen># <userinput>metassist create -s myset -f -r 2 -S 10mb -c > \
 /tmp/metassist-shell-script.sh</userinput></screen>
</example>
</task><sect2 id="tasks-topdown-25"><title>Creating a Volume With a Saved Shell Script
Created by the <command>metassist</command> Command</title><para>After you have created a shell script with the <command>metassist</command> command,
you can use that script to create the volumes that you specified when the
shell script was created. </para><caution><para>The command script created by the <command>metassist</command> command
has significant dependencies on the specific system configuration of the system
on which the script was created, at the time the script was created. Using
the script on different systems or after any changes to the system configuration
can lead to data corruption or loss. </para>
</caution><task id="tasks-topdown-proc-26"><title>How to Execute a Saved <command>metassist</command> Command Shell Script</title><taskprerequisites><para>Check <olink targetptr="tasks-topdown-15" remap="internal">Prerequisites for Top-Down
Volume Creation</olink>.</para>
</taskprerequisites><procedure><step><para>Ensure that the system configuration has not changed since the
shell script was created, and that you are executing the script on the same
system it was created on. </para>
</step><step><para>Execute the saved shell script.</para><screen># <command>sh ./<replaceable>metassist-shell-script-name</replaceable></command></screen>
</step><step><para>View the new volume. </para><screen># <command>metastat</command> <option>s</option> <replaceable>diskset-name</replaceable></screen>
</step>
</procedure><example id="ewavg"><title>Executing a Saved <command>metassist</command> Command Shell Script</title><para>The following example shows how to use the <command>metassist</command> command
to create a volume using a shell script.</para><screen># <userinput>sh ./tmp/metassist-shell-script.sh</userinput>
myset/hsp000: Hotspare pool is setup
myset/hsp000: Hotspare is added
myset/d2: Concat/Stripe is setup
myset/d1: Concat/Stripe is setup
myset/d0: Mirror is setup
myset/d0: submirror myset/d1 is attached</screen>
</example>
</task>
</sect2><sect2 id="tasks-topdown-9"><title>Creating a Volume Configuration File With
the <command>metassist</command> Command</title><para>By running the <command>metassist</command> command with the <command><option>d</option></command> argument, you can generate an XML-based volume configuration
file that specifies the volumes and their components in detail, including
all options and relevant information about the volumes. Reviewing this file
helps you to understand the configuration that the <command>metassist</command> command
recommends. Making careful changes to this file can also enable you to fine-tune
the configuration, then to use the volume configuration file as input to the <command>metassist</command> command to actually create volumes. </para>
</sect2><task id="ewavd"><title>How to Create a Volume Configuration File Using the <command>metassist</command> Command</title><taskprerequisites><para>Check <olink targetptr="tasks-topdown-15" remap="internal">Prerequisites for Top-Down
Volume Creation</olink>.</para>
</taskprerequisites><procedure><step><para>Identify the available storage on which to create the volume.</para><para>If you do not explicitly specify storage, Solaris Volume Manager identifies unused
storage on the system and uses it, as appropriate. If you choose to specify
storage, either broadly (for example, all storage on controller 1) or specifically
(for example, use <literal>c1t4d2</literal>, but do not use <literal>c1t4d1</literal>), Solaris Volume Manager uses
the storage you specify.</para>
</step><step><para>Use the <command>metassist</command> command and the appropriate
options for your task.</para><para>Use the <option>d</option> option to specify
that the volume should not actually be created. Instead, an XML-based volume
configuration file is sent to standard output:</para><screen># <userinput>metassist create -s <replaceable>diskset-name</replaceable> -f -r <replaceable>redundancy</replaceable> -a <replaceable>device1, device2...</replaceable> \
 -S <replaceable>size</replaceable> -v <replaceable>verbosity</replaceable> [-d]</userinput></screen><variablelist><varlistentry><term><command>create</command></term><listitem><para>Is the subcommand used to create volumes.</para>
</listitem>
</varlistentry><varlistentry><term><option>s</option> <replaceable>diskset-name</replaceable></term><listitem><para>Specifies the name of the disk set to use for the volume.</para>
</listitem>
</varlistentry><varlistentry><term><option>f</option></term><listitem><para>Specifies that the volume be associated with a hot spare.</para>
</listitem>
</varlistentry><varlistentry><term><option>r</option> <replaceable>redundancy</replaceable></term><listitem><para>Specifies the level of redundancy (number of data copies)
to create.</para>
</listitem>
</varlistentry><varlistentry><term><option>a</option> <replaceable>device1, device2...</replaceable></term><listitem><para>Specifies the devices that are available for creating the
volume.</para>
</listitem>
</varlistentry><varlistentry><term><option>S</option> <replaceable>size</replaceable></term><listitem><para>Specifies the size of the volume to create in <literal>KB</literal>, <literal>MB</literal>, <literal>GB</literal>, or <literal>TB</literal>, for kilobytes,
megabytes, gigabytes, and terabytes, respectively.</para>
</listitem>
</varlistentry><varlistentry><term><option>v</option> <replaceable>verbosity</replaceable></term><listitem><para>Specifies how verbose the output should be. Allowable values
range from <literal>0</literal> (nearly silent output) to <literal>2</literal> (significant
output). The default level is <literal>1</literal> (moderate output).</para>
</listitem>
</varlistentry><varlistentry><term><option>d</option></term><listitem><para>Specifies that the volume should not actually be created.</para><note><para>The XML-based volume configuration file required by the <option>d</option> argument
is sent to standard output. However, the rest of the output from the <command>metassist</command> command goes to standard error. You can redirect the output streams
as you choose.</para>
</note><para>See the following examples and the <olink targetdoc="refman1m" targetptr="metassist-1m" remap="external"><citerefentry><refentrytitle>metassist</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man page for more information.</para>
</listitem>
</varlistentry>
</variablelist>
</step>
</procedure><example id="etesj"><title>Creating a Volume Configuration File Using the <command>metassist</command> Command</title><para>This example shows how to use the <command>metassist</command> command
to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide
additional fault tolerance. The <option>f</option> option specifies fault
tolerance. The final argument (<option>d</option>) specifies that the volume
should not actually be created. Rather, a volume configuration file that could
eventually be used to create the specified configuration should be sent to
standard output. </para><screen># <userinput>metassist create -s myset -f -r 2 -S 10mb -d</userinput>


.(output truncated)
.
.
Volume request completed successfully.
&lt;?xml version="1.0"?>
&lt;!DOCTYPE volume-config SYSTEM "/usr/share/lib/xml/dtd/volume-config.dtd">
 &lt;volume-config>
&lt;diskset name="myset"/>
&lt;disk name="c1t3d0"/>
&lt;disk name="c1t6d0"/>
&lt;disk name="c1t4d0"/>
&lt;slice name="c1t3d0s7" sizeinblocks="0"/>
&lt;slice name="c1t3d0s0" sizeinblocks="17649765" startsector="10773"/>
&lt;slice name="c1t6d0s7" sizeinblocks="0"/>
&lt;slice name="c1t6d0s0" sizeinblocks="17649765" startsector="10773"/>
&lt;slice name="c1t4d0s7" sizeinblocks="0"/>
&lt;slice name="c1t4d0s0" sizeinblocks="17649765" startsector="10773"/>
&lt;hsp name="hsp000">
&lt;slice name="c1t3d0s1" sizeinblocks="21546" startsector="17660538"/>
&lt;/hsp>
&lt;mirror name="d0" read="ROUNDROBIN" write="PARALLEL" passnum="1">
&lt;concat name="d2">
&lt;slice name="c1t4d0s1" sizeinblocks="21546" startsector="17660538"/>
&lt;hsp name="hsp000"/>
&lt;/concat>
&lt;concat name="d1>
&lt;slice name="c1t6d0s1"sizeinblocks="21546" startsector="17660538"/>
&lt;hsp name="hsp000"/>
&lt;/concat>
&lt;/mirror>
&lt;/volume-config>
# </screen>
</example><example id="etesc"><title>Saving a Volume Configuration File Using the <command>metassist</command> Command</title><para>This example shows how to use the <command>metassist</command> command
to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide
additional fault tolerance. The <option>f</option> option specifies fault
tolerance. The final argument (<option>d</option>) specifies that the volume
should not actually be created. Rather, a volume configuration file that could
eventually be used to create the specified configuration should be sent to
standard output. The end of the command redirects standard output to create
the <filename>/tmp/metassist-volume-config.xml</filename> volume configuration
file that can later be used to create the specified volume.</para><screen># <userinput>metassist create -s myset -f -r 2 -S 10mb -d >  \
/tmp/metassist-volume-config.xml</userinput></screen>
</example>
</task>
</sect1><sect1 id="tasks-topdown-12"><title>Changing the Default Behavior of the <command>metassist</command> Command</title><para>You can use the volume defaults file (<filename>/etc/defaults/metassist.xml</filename>) to change the default behavior for the <command>metassist</command> command.
By changing the defaults file, you can explicitly exclude from consideration,
or include for consideration, specific disks or controllers. You can also
specify requirements for most volume settings used by the <command>metassist</command> command. </para><para>The format of the <filename>/etc/defaults/metassist.xml</filename> is
specified by the <filename>/usr/share/lib/xml/dtd/volume-defaults.dtd</filename> Document
Type Definition (DTD). The format is documented in the <olink targetdoc="refman4" targetptr="volume-defaults-4" remap="external"><citerefentry><refentrytitle>volume-defaults</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> man page.</para><sect2 id="tasks-topdown-130"><title>Changing the Volume Defaults File</title><para>Edit the volume defaults file (<filename>/etc/defaults/metassist.xml</filename>)
to specify how the <command>metassist</command> command should behave. </para><note><para>When you edit the file, you must ensure that the file continues
to be compliant with the <filename>/usr/share/lib/xml/dtd/volume-defaults.dtd</filename> Document
Type Definition (DTD). If the XML file is not compliant with the DTD, the <command>metassist</command> command will fail with an error message. </para>
</note><example id="ewavi"><title>Creating a Volume With Changed Defaults Using the <command>metassist</command> Command</title><para>Before creating a volume, edit the <filename>/etc/default/metassist.xml</filename> file
to specify the default settings that you want to apply to all volumes you
will create with the <command>metassist</command> command. In this example,
the <command>metassist</command> command only creates volumes on controller <literal>c1</literal> and, when creating stripes, only creates stripes with exactly
four components and an interlace of value <literal>512KB</literal>. These
constraints apply to all uses of the <command>metassist</command> command
until the <filename>/etc/default/metassist.xml</filename> file is changed
again. </para><screen>#  <userinput>cat /etc/default/metassist.xml</userinput> 
&lt;!DOCTYPE volume-defaults SYSTEM \
"/usr/share/lib/xml/dtd/volume-defaults.dtd">

&lt;volume-defaults>
&lt;available name="<userinput>c1</userinput>" />
&lt;stripe mincomp="<userinput>4</userinput>" maxcomp="<userinput>4</userinput>" interlace="<userinput>512KB</userinput>" >&lt;/stripe>
&lt;/volume-defaults>

# <userinput>metassist create -s myset -S 10Gb</userinput>
 </screen><para>The <command>metassist</command> command creates a 10-Gbyte stripe,
using exactly four slices and an interlace value of 512 Kbytes, as specified
in the <filename>/etc/default/metassist.xml</filename> file.</para>
</example>
</sect2>
</sect1>
</chapter>