{"id":422,"date":"2022-09-15T13:04:02","date_gmt":"2022-09-15T13:04:02","guid":{"rendered":"https:\/\/www.aixperts.co.uk\/?p=422"},"modified":"2022-10-21T14:43:28","modified_gmt":"2022-10-21T14:43:28","slug":"growing-san-lun-on-linux","status":"publish","type":"post","link":"https:\/\/www.aixperts.co.uk\/?p=422","title":{"rendered":"Growing SAN LUN on Linux"},"content":{"rendered":"\n<p>This procedure works on SLES 15, should work on RHEL, but not yet tested.<\/p>\n\n\n\n<p>This script is for growing SAN LUNs running via multipath on Linux. Makes it look like AIX and just as easy!<\/p>\n\n\n\n<p>Growing SAN LUNs in Linux is a rather frustrating affair, as Googling the subject will tell you. As many different methods as Google hits. This script, &#8216;chvg&#8217;, combines the tools needed, and targets only the volume group you have extended LUNs for.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n####################################\n# chvg script to increase disk in VG\n####################################\n\n# Version history\n#\n# 2022-09-14    HM      1.0     Initial\n#\n\nver=1.0\n\n# Set variables\ntoday=\"$(date +%Y-%m-%d)\"\n\n# Setup a little usage function\nhelpFunction()\n{\n   echo \"\"\n   echo \"Usage: $0 -g &lt;Volume Group&gt;\"\n   echo -e \"\\t-g Update size of disks in volume group\"\n   exit 1 # Exit script after printing help\n}\n\n# Set a bogus VG to pick up running script with no arguments\nVG=\"Gobbledegook\"\n\n# Pick out options\nwhile getopts \"g:\" opt\ndo\n   case \"$opt\" in\n      g ) VG=\"$OPTARG\" ;;\n      ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent\n   esac\ndone\n\n# If VG isn't right, exit with help text\nvgs ${VG} &gt;\/dev\/null 2&gt;&amp;1 || helpFunction\n\n# Save a copy of the current multipathed disks\nmultipath -ll &gt; \/tmp\/multipath.before.out.${today}\n\n# Find disks in VG\ndisks=\"$(pvs | grep -w ${VG} | awk '{ print $1 }' | awk -F\/ '{ print $NF }' | tr '\\n' '\n')\"\n\n# Find paths\nfor disk in ${disks}\ndo\n   # Find first set of paths\n   paths1=\"$(multipath -ll ${disk} | grep -v -- \"-+-\" | grep \"| |-\" | awk '{ print $4 }')\"\n\n   # Find second set of paths\n   paths2=\"$(multipath -ll ${disk} | grep -v -- \"-+-\" | grep -v \"| |-\" | grep \"|-\" | awk '{ print $3 }')\"\n\n   # Find last disk in first set\n   paths3=\"$(multipath -ll ${disk} | grep -- \"| \\`-\" | awk '{ print $4 }')\"\n\n   # Find last disk in second set\n   paths4=\"$(multipath -ll ${disk} | grep -- \"  \\`-\" | awk '{ print $3 }')\"\n\n   # Add to full list of paths\n   allpaths=${allpaths}\" \"${paths1}\" \"${paths2}\" \"${paths3}\" \"${paths4}\ndone\n\n# Now set the paths to rescan\nfor path in ${allpaths}\ndo\n   # Write a true to the rescan parameter for the device\n   echo 1 &gt; \/sys\/block\/${path}\/device\/rescan\ndone\n\n# Now restart multipathd to rescan (\"Linux\" magic)\nsystemctl restart multipathd\n\n# And save the new multipath output\nmultipath -ll &gt; \/tmp\/multipath.after.out.${today}\n\n# Resize the PVs in the VG\nfor pv in ${disks}\ndo\n   pvresize \/dev\/mapper\/${pv}\ndone\n\nexit 0\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This procedure works on SLES 15, should work on RHEL, but not yet tested. This script is for growing SAN LUNs running via multipath on Linux. Makes it look like AIX and just as easy! Growing SAN LUNs in Linux &hellip; <a href=\"https:\/\/www.aixperts.co.uk\/?p=422\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,148],"tags":[136,122,135,134,133],"class_list":["post-422","post","type-post","status-publish","format-standard","hentry","category-linux","category-scripting","tag-grow","tag-linux","tag-multipath","tag-san","tag-scripts"],"_links":{"self":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=422"}],"version-history":[{"count":2,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/422\/revisions"}],"predecessor-version":[{"id":431,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/422\/revisions\/431"}],"wp:attachment":[{"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=422"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=422"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aixperts.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}