Working With File-Based Data Using the metassist Command

The metassist command enables you to create files that you can use to evaluate volume characteristics or for actual volume creation.

Creating a Command File (Shell Script) Using the metassist Command

By running the metassist command with the c 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.

How to Create a Command File (Shell Script) Using the metassist Command

Check Prerequisites for Top-Down Volume Creation.

  1. Identify the available storage on which to create the volume.

    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 c1t4d2, but do not use c1t4d1), Solaris Volume Manager uses the storage you specify.

  2. Use the metassist command and the appropriate options for your task.

    Use the c option to specify that the volume should not actually be created.

    # metassist create -s diskset-name -f -r redundancy -a device1, device2... \
     -S size -v verbosity [-c]
    
    create

    Is the subcommand used to create volumes.

    s diskset-name

    Specifies the name of the disk set to use for the volume.

    f

    Specifies that the volume be associated with a hot spare.

    r redundancy

    Specifies the level of redundancy (number of data copies) to create.

    a device1, device2...

    Specifies the devices that are available for creating the volume.

    S size

    Specifies the size of the volume to create in KB, MB, GB, or TB, for kilobytes, megabytes, gigabytes, and terabytes, respectively.

    v verbosity

    Specifies how verbose the output should be. Allowable values range from 0 (nearly silent output) to 2 (significant output). The default level is 1 (moderate output).

    c

    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.

    Note

    The shell script required by the c argument is sent to standard output, while the rest of the output from the metassist command goes to standard error. You can redirect the output streams as you choose.

    See the following examples and the metassist ( 1M ) man page for more information.

Example 23.6. Creating a Command File (Shell Script) Using the metassist Command

The following example shows how to use the metassist command to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide additional fault tolerance. The f option specifies fault tolerance. The final argument ( c) 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.

# metassist create -s myset -f -r 2 -S 10mb -c
(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" && 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>&1`
    result=$?
    echo "$out" |
    case "$out" in
        *"$ignore"*) grep -v "$ignore"; return 0 ;;
        '') return "$result" ;;
        *) cat; return 1 ;;
    esac >&2
}

#
# Main
#

# Verify root
if [ "`id | sed 's/^[^(]*(\([^)]*\).*/\1/'`" != root ]
then
    echo "This script must be run as root." >&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>&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>&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
# 

Example 23.7. Saving a Command File (Shell Script) Using the metassist Command

The following example shows how to use the metassist command to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide additional fault tolerance. The f option specifies fault tolerance. The final argument ( c) 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 /tmp/metassist-shell-script.sh shell script that can later be used to create the specified volume.

# metassist create -s myset -f -r 2 -S 10mb -c > \
 /tmp/metassist-shell-script.sh

Creating a Volume With a Saved Shell Script Created by the metassist Command

After you have created a shell script with the metassist command, you can use that script to create the volumes that you specified when the shell script was created.

Caution

The command script created by the metassist 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.

How to Execute a Saved metassist Command Shell Script

Check Prerequisites for Top-Down Volume Creation.

  1. 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.

  2. Execute the saved shell script.

    # sh ./metassist-shell-script-name
    
    
  3. View the new volume.

    # metastat 
    s diskset-name
    

Example 23.8. Executing a Saved metassist Command Shell Script

The following example shows how to use the metassist command to create a volume using a shell script.

# sh ./tmp/metassist-shell-script.sh
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

Creating a Volume Configuration File With the metassist Command

By running the metassist command with the d 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 metassist 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 metassist command to actually create volumes.

How to Create a Volume Configuration File Using the metassist Command

Check Prerequisites for Top-Down Volume Creation.

  1. Identify the available storage on which to create the volume.

    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 c1t4d2, but do not use c1t4d1), Solaris Volume Manager uses the storage you specify.

  2. Use the metassist command and the appropriate options for your task.

    Use the d option to specify that the volume should not actually be created. Instead, an XML-based volume configuration file is sent to standard output:

    # metassist create -s diskset-name -f -r redundancy -a device1, device2... \
     -S size -v verbosity [-d]
    
    create

    Is the subcommand used to create volumes.

    s diskset-name

    Specifies the name of the disk set to use for the volume.

    f

    Specifies that the volume be associated with a hot spare.

    r redundancy

    Specifies the level of redundancy (number of data copies) to create.

    a device1, device2...

    Specifies the devices that are available for creating the volume.

    S size

    Specifies the size of the volume to create in KB, MB, GB, or TB, for kilobytes, megabytes, gigabytes, and terabytes, respectively.

    v verbosity

    Specifies how verbose the output should be. Allowable values range from 0 (nearly silent output) to 2 (significant output). The default level is 1 (moderate output).

    d

    Specifies that the volume should not actually be created.

    Note

    The XML-based volume configuration file required by the d argument is sent to standard output. However, the rest of the output from the metassist command goes to standard error. You can redirect the output streams as you choose.

    See the following examples and the metassist ( 1M ) man page for more information.

Example 23.9. Creating a Volume Configuration File Using the metassist Command

This example shows how to use the metassist command to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide additional fault tolerance. The f option specifies fault tolerance. The final argument ( d) 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.

# metassist create -s myset -f -r 2 -S 10mb -d


.(output truncated)
.
.
Volume request completed successfully.
<?xml version="1.0"?>
<!DOCTYPE volume-config SYSTEM "/usr/share/lib/xml/dtd/volume-config.dtd">
 <volume-config>
<diskset name="myset"/>
<disk name="c1t3d0"/>
<disk name="c1t6d0"/>
<disk name="c1t4d0"/>
<slice name="c1t3d0s7" sizeinblocks="0"/>
<slice name="c1t3d0s0" sizeinblocks="17649765" startsector="10773"/>
<slice name="c1t6d0s7" sizeinblocks="0"/>
<slice name="c1t6d0s0" sizeinblocks="17649765" startsector="10773"/>
<slice name="c1t4d0s7" sizeinblocks="0"/>
<slice name="c1t4d0s0" sizeinblocks="17649765" startsector="10773"/>
<hsp name="hsp000">
<slice name="c1t3d0s1" sizeinblocks="21546" startsector="17660538"/>
</hsp>
<mirror name="d0" read="ROUNDROBIN" write="PARALLEL" passnum="1">
<concat name="d2">
<slice name="c1t4d0s1" sizeinblocks="21546" startsector="17660538"/>
<hsp name="hsp000"/>
</concat>
<concat name="d1>
<slice name="c1t6d0s1"sizeinblocks="21546" startsector="17660538"/>
<hsp name="hsp000"/>
</concat>
</mirror>
</volume-config>
# 

Example 23.10. Saving a Volume Configuration File Using the metassist Command

This example shows how to use the metassist command to create a two-way mirror, 10 Mbytes in size, with a hot spare to provide additional fault tolerance. The f option specifies fault tolerance. The final argument ( d) 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 /tmp/metassist-volume-config.xml volume configuration file that can later be used to create the specified volume.

# metassist create -s myset -f -r 2 -S 10mb -d >  \
/tmp/metassist-volume-config.xml