Created
June 12, 2014 19:08
-
-
Save chrislovecnm/369aa4adc381e129ea92 to your computer and use it in GitHub Desktop.
Copy a LVS logical volume between volume groups
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 | |
export mount_point=$1 | |
if [[ -z "$mount_point" ]]; then | |
echo "pass in drive name as first argument"; | |
exit 1; | |
fi | |
# Sanity check that lv is not used | |
lvuses="$( lvdisplay -c /dev/vg0/${mount_point} | cut -d ':' -f 6 )" | |
if [ $lvuses -gt 0 ]; then | |
echo "lv $mount_point is in use" | |
exit 1 ; | |
fi | |
#obtain lv size (in sectors) | |
export lvsize="$( lvdisplay -c /dev/vg0/${mount_point} | cut -d ':' -f 7 )" | |
echo "lvsize ${lvsize}" | |
#create destination | |
lvcreate -L "${lvsize}s" vg1 -n ${mount_point} || exit 1 | |
echo "lvcreated /dev/vg1/${mount_point}" | |
# copy | |
echo "starting copy | |
time dd if=/dev/vg0/${mount_point} of=/dev/vg1/${mount_point} | |
echo "DONE!!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment