Created
February 5, 2022 13:06
-
-
Save grmontesino/8ec29cd16cf3d893dde808f35f079304 to your computer and use it in GitHub Desktop.
Incremental pvmove
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
#### | |
# pvmove data in configurables sized extents amount | |
# More info about motivation and concept in | |
# https://grmontesino.blogspot.com/2022/02/incremental-pvmove.html | |
# | |
# Usage: incremental_pvmove.sh <LV> <Origin PV> <Dest. PV> [] | |
#### | |
LV="$1" | |
ORIG_PV="$2" | |
DEST_PV="$3" | |
EXTENTS="${4:-25000}" | |
START=$(lvs --noheadings -ao devices $LV | grep -oP "$ORIG_PV\(\K\d+(?=\))") | |
while true; do | |
SIZE=$(lvs --noheadings --separator "|" -ao devices,seg_size_pe $LV \ | |
| grep "$ORIG_PV" | head -1 | cut -d"|" -f2) | |
[ ${SIZE:=0} -gt $EXTENTS ] || EXTENTS=$SIZE | |
if [ $EXTENTS -le 0 ]; then | |
echo "* Finished!" | |
break | |
fi | |
echo "* pvmove ${ORIG_PV}:${START}+${EXTENTS} $DEST_PV" | |
pvmove ${ORIG_PV}:${START}+${EXTENTS} $DEST_PV | |
START=$((START+EXTENTS)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment