Last active
December 17, 2015 06:48
-
-
Save huksley/5567559 to your computer and use it in GitHub Desktop.
Extend LVM with new logical sdaX disk. Online, hot, without restart.
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 | |
LV=`lvs | grep -v swap | sed -re "s/^[ ]+//;s/[ ]+/ /g" | cut -d" " -f1 | tail -n+2` | |
VG=`lvs | grep -v swap | sed -re "s/^[ ]+//;s/[ ]+/ /g" | cut -d" " -f2 | tail -n+2` | |
if [ "$1" = "" ]; then | |
echo specify /dev/sda? | |
exit | |
fi | |
echo Extending /dev/mapper/$VG-$LV using $1 as source space | |
pvcreate $1 | |
vgextend $VG $1 | |
lvextend -l +100%FREE /dev/mapper/$VG-$LV | |
resize2fs /dev/mapper/$VG-$LV | |
df -h /dev/mapper/$VG-$LV |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you are using VMWare and adding space to existing disk, issue as root
to rescan disk for changes (dmesg must say sda: detected capacity change from X to Y)
after that,
make partition using cfdisk to make this disk as logical, 8e type (for LVM)