#! /bin/sh
#
# mirrorRoot - mirrors the root disk cleanly and safely
#
################################################################
# Author: Todd Stansell # $Id: mirrorRoot,v 1.21 2004-02-01 03:40:20-08 todd Exp $
#
# Notes:
#
# 1) I use vxprint -F ... throughout this script because of the
# fact that vxprint -ht output is not consistent between versions.
# Version 3.1 adds information about replication (since it's
# now integrated). Anyway, by pulling only the information
# I need, I can be sure it will work without regard to version.
#
# 2) status codes of all veritas commands are documented in the
# vxintro manpage.
#
# 3) versions previous to 1.18 don't deal with the Block0
# subdisk correctly for VxVM 3.5. So, make sure you're
# using version 1.18 or newer. You wouldn't see this
# message if you weren't, though.
#
################################################################ #! /bin/sh
#
# mirrorRoot - mirrors the root disk cleanly and safely
#
################################################################
# Author: Todd Stansell # $Id: mirrorRoot,v 1.21 2004-02-01 03:40:20-08 todd Exp $
#
# Notes:
#
# 1) I use vxprint -F ... throughout this script because of the
# fact that vxprint -ht output is not consistent between versions.
# Version 3.1 adds information about replication (since it's
# now integrated). Anyway, by pulling only the information
# I need, I can be sure it will work without regard to version.
#
# 2) status codes of all veritas commands are documented in the
# vxintro manpage.
#
# 3) versions previous to 1.18 don't deal with the Block0
# subdisk correctly for VxVM 3.5. So, make sure you're
# using version 1.18 or newer. You wouldn't see this
# message if you weren't, though.
#
################################################################
mirror_dev="c0t1d0"
mirror_name="rootdisk2"
verbose=0
c_opt=false
setswaponly=false
PATH=$PATH:/usr/sbin:/etc/vx/bin
PROG=`basename `
USAGE="usage: $PROG [-hvc] [ [-s] | [-n name] [-d device] ]
-h help
-s create swap slices and configure dump device only
-v increase verbosity level (two -v's for max)
-c show vx commands as they are run
-n name disk access name of mirror disk (default is $mirror_name)
-d device device used to mirror onto (default is $mirror_dev)"
#
# kills off any processes that are running in the background
#
cleanup() {
vxtask abort $PROG
}
#
# echo a message if we want vx command verbosity
#
show() { [ $c_opt ] && /bin/echo "# $@" ; }
#
# echo a message if we want verbosity
#
msg() { [ $verbose -ge 1 ] && /bin/echo "$@" ; }
#
# usage: showstatus $value $prog $msg
#
showstatus() {
status=""
prog=""
if [ $status -ne 0 ] ; then
echo "" >&2
echo " $prog exited with status $status" >&2
exit $status
fi
}
#
# Check to see that $device has at least $size sectors
# usage: check_size $device $size
#
check_size() {
len=`vxprint -e 'sd && sd_disk="'$dm_of_rootvol'" && p0 = "PRIVATE"' -F "%len" | awk 'END{print ''-a}'`
pub_len=`vxdisk list | awk -F= '/^public:/ {print $NF}'`
if [ $pub_len -lt $len ] ; then
echo "$mirror_dev is only $pub_len sectors, while" >&2
echo "$dm_of_rootvol uses $len sectors. Please choose a larger disk." >&2
exit 7
fi
}
#
# usage: initdisk $device
#
initdisk() {
dev=
# see if we need the old_layout option to vxdisksetup. This
# is required if we have a fully-utilized disk that has been
# encapsulated, so that only 1 cylinder is used for the private
# region, and the new disk will have enough public space to
# mirror everything to. If you don't want it to use this option,
# then initialize the disk before running this script.
opt=""
if grep old_layout /etc/vx/bin/vxdisksetup >/dev/null ; then
opt="old_layout"
fi
msg "Initializing $dev for use with volume manager"
show "vxdisksetup -i $dev $opt"
vxdisksetup -i $dev $opt; status=$?
showstatus $status vxdisksetup "Could not initialize $dev"
}
#
# adds a device ($dev) to a disk group ($dg) with specified media name ($dm)
#
# usage: add_to_dg $dev $dm [$dg]
#
add_to_dg() {
dg=rootdg
dev=
dm=
[ "" ] && dg=
msg "Adding $dev to $dg as $dm"
show "vxdg -g $dg adddisk $dm=$dev"
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




