Create New Lv Fs

#!/bin/ksh
#
#
#  Script pour basculer des fs DATABASES de jfs en jfs2
#


vg=$1
svg=$vg
nvg=$2

test $# -lt 1 && exit 9

typefs=jfs

test ! -z "${nvg}" && typefs="${typefs}|jfs2"

lsvg -l $vg | egrep -w "${typefs}|open\/syncd" | egrep -v "jfslog|jfs2log" | awk '{ print $7" "$1" "$4 }' | sort | while read fs lv pps
do

slv=$lv

if test ! -z "$nvg"
then
vg=$nvg
nlv=$( echo $vg | cut -c2- )$( echo $lv | cut -c10- )
lv="l${nlv}"
tppsvg=$( lsvg $svg | grep "PP SIZE" | awk '{ print $6 }' )
tppvg=$( lsvg $vg | grep "PP SIZE" | awk '{ print $6 }' )
if test $tppvg -gt $tppsvg
then
 (( tppvg/=tppsvg ))
 (( pps/=tppvg ))
fi
fi

nfs=$( echo $fs | sed 's/REEL/REEL_new/' )
if test $( echo $nfs | grep -c REEL ) -eq 0
then
nfs=$( echo $fs | sed 's/$/_new/' )
fi

cat << @EOFF >> /tmp/copiefs_$$
cp -Ppr $fs/* $nfs
chown $( ls -l `dirname $fs` | grep -w $( basename $fs ) | awk '{print $3":"$4 }' ) $nfs
@EOFF

cat << @EOFF >> /tmp/creatlv_$$
mklv -y'${lv}_new' -t'jfs2' $vg $pps
@EOFF

##crfs -v jfs2 -d'${lv}_new' -m'$nfs' -A''\`locale yesstr | awk -F: '{print \$1}'\`'' -p'rw' -a agblksize='4096'
cat << @EOFF >> /tmp/creatfs_$$
crfs -v jfs2 -d'${lv}_new' -m'$nfs' -A'yes' -p'rw' -a agblksize='4096'
@EOFF

if test $( echo $fs | grep -c "REEL$" ) -eq 1
then
cat << @EOFF >> /tmp/creatfs_$$
mount $nfs
@EOFF
pasmount=$nfs
fi

cat << @EOFF >> /tmp/ancienfs_$$
$fs
@EOFF

cat << @EOFF >> /tmp/newfs_$$
$nfs
@EOFF

cat << @EOFF >> /tmp/chlvfs_$$
chlv -n ${slv}_old ${slv}
chlv -n ${lv} ${lv}_new
chfs -m ${fs}_old ${fs}
chfs -m ${fs} ${nfs}
@EOFF

done

#---------------- AFFICHAGE

echo "set -ev"

echo "\n#=======Pour creer new LV "
sort /tmp/creatlv_$$

echo "\n#=======Pour creer new FS "
cat /tmp/creatfs_$$

echo "\n#=======Pour mount new FS "
sed "s/^/mount /" /tmp/newfs_$$ | grep -vw "${pasmount}$"

echo "lsvg -l $svg"
test ! -z "$nvg" && echo "lsvg -l $nvg"

if test $( grep -vcw "\/REEL" /tmp/copiefs_$$ ) -gt 0
then
echo "\n#****************************************************************"
echo "# copie des FS a faire par la PROD"
echo "#******************************************************************"
grep -vw REEL /tmp/copiefs_$$
fi

echo "exit"

echo "\n#****************************************************************"
echo "#Prevenir equipe BDD pour qu ils fassent la copie sur les new FS "
echo "# Puis vous pouvez passer apres feu vert de BDD au etapes suivantes"
echo "#******************************************************************"

echo "\n#=======Pour umount ancien FS "
sed "s/^/umount /" /tmp/ancienfs_$$ | sort -r

echo "\n#=======Pour umount new FS "
sed "s/^/umount /" /tmp/newfs_$$ | sort -r

echo "\n#=======Pour renommer les anciens et nouveaux FS "
cat /tmp/chlvfs_$$

echo "\n#=======Pour mount new FS "
sed "s/^/mount /" /tmp/ancienfs_$$

echo "lsvg -l $svg"
echo " "
test ! -z "$nvg" && echo "lsvg -l $nvg"

rm /tmp/*_$$

Previous page: Create FS
Page suivante : Shell Presentation taille FS