.lib-scanDevices.sh: Difference between revisions
Jump to navigation
Jump to search
(Created page with "<syntaxhighlight lang="bash"> #!/bin/bash # Scan devices # "scanDevices" # APA 20191227 # initialisation des variables if [ -z "$(find /tmp/pvresize-before.sh -mmin -1 2>/de...") |
No edit summary |
||
Line 50: | Line 50: | ||
EOT | EOT | ||
if [ $# -eq 0 ] ;then | if [ $# -eq 0 ] ;then | ||
script.sh "$(hostList.sh | script.sh "$(hostList.sh infocepo |grep -E '^t.[^v][[:alnum:]]{8}[^p](|-...)$' )" /tmp/pvresize-before.sh 2>&1 >/dev/null | ||
else | else | ||
script.sh "$@" /tmp/pvresize-before.sh 2>&1 >/dev/null | script.sh "$@" /tmp/pvresize-before.sh 2>&1 >/dev/null | ||
Line 61: | Line 61: | ||
EOT | EOT | ||
if [ $# -eq 0 ] ;then | if [ $# -eq 0 ] ;then | ||
script.sh "$(hostList.sh | script.sh "$(hostList.sh infocepo |grep -E '^t.[^v][[:alnum:]]{8}[^p](|-...)$' )" /tmp/pvresize.sh 2>&1 >/dev/null | ||
else | else | ||
script.sh "$@" /tmp/pvresize.sh 2>&1 >/dev/null | script.sh "$@" /tmp/pvresize.sh 2>&1 >/dev/null |
Latest revision as of 00:25, 9 March 2022
#!/bin/bash
# Scan devices
# "scanDevices"
# APA 20191227
# initialisation des variables
if [ -z "$(find /tmp/pvresize-before.sh -mmin -1 2>/dev/null )" ] ;then
echo "=== DEVICE ==="
cat <<EOT >/tmp/pvresize-before.sh
# scan FC
ls -1 /sys/class/fc_host/*/issue_lip |while read FCPath ;do
echo "1" >"\${FCPath}"
done &&sleep 2
# scan SCSII
ls -1 /sys/class/scsi_host/*/scan |while read SCSIIPath ;do
echo "- - -" >"\${SCSIIPath}"
done &&sleep 2
# scan device
ls -1 /sys/block/*/device/rescan |while read devicePath ;do
echo 1 >"\${devicePath}"
done &&sleep 2
multipath -ll |sed -rn 's# .* (sd[a-z]+) .* failed faulty.*\$#\1#p' |while read lineMy ;do
echo 1 > /sys/block/"\${lineMy}"/device/delete
done &&sleep 2
# update multipath
# multipath present
multipath -r |sed -rn 's#^.*\((.*)\).*\$#\1#p' >/tmp/multipath_r
mpathNameList="\$(multipath -ll |grep -w dm |grep -vwf /tmp/multipath_r |sed -rn 's#^([[:graph:]]+)[[:space:]].*\$#\1#p' )"
if [ ! -z "\${mpathNameList}" ] ;then
echo "\${mpathNameList}" |while read mpathName ;do
dmsetup remove -f \$mpathName
multipath -f \$mpathName
done
fi
#multipath -F
multipath -r &&sleep 2
multipath -ll |sed -rn 's#^([[:graph:]]+).*dm-.*\$#\1#p' |while read multipathName ;do
multipathd resize map "\${multipathName}"
done &&sleep 2
EOT
if [ $# -eq 0 ] ;then
script.sh "$(hostList.sh infocepo |grep -E '^t.[^v][[:alnum:]]{8}[^p](|-...)$' )" /tmp/pvresize-before.sh 2>&1 >/dev/null
else
script.sh "$@" /tmp/pvresize-before.sh 2>&1 >/dev/null
fi
echo "=== LVM ==="
cat <<EOT >/tmp/pvresize.sh
# pv resize
pvs |tail -n +2 |awk '{print \$1}' |xargs pvresize
EOT
if [ $# -eq 0 ] ;then
script.sh "$(hostList.sh infocepo |grep -E '^t.[^v][[:alnum:]]{8}[^p](|-...)$' )" /tmp/pvresize.sh 2>&1 >/dev/null
else
script.sh "$@" /tmp/pvresize.sh 2>&1 >/dev/null
fi
fi