Created
June 18, 2013 05:10
-
-
Save mhlavac/5802789 to your computer and use it in GitHub Desktop.
LVM add new physical volume to existing logical volume and extend that logical volume as much as possible.
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/sh | |
if [ `id -u` -ne '0' ]; then | |
echo "This script must be run as root" >&2 | |
exit 1 | |
fi | |
drive=$1 | |
volume_group=$2 | |
volume_group_location=$3 | |
pvcreate $drive | |
vgextend $volume_group $drive | |
pvdisplay_output=`pvdisplay $drive --units b | grep "PV Size"` | |
pv_size=`echo $pvdisplay_output | awk '{print $3}' | |
pv_not_usable=`echo $pvdisplay_output | awk '{print $8}' | |
extend=`expr $pv_size - $pv_not_usable` | |
lvextend -L +$extend $volume_group_location | |
resize2fs $volume_group |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment