Created
September 12, 2013 00:53
-
-
Save vpetersson/6531944 to your computer and use it in GitHub Desktop.
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 | |
NEWDEV='/dev/vdb' | |
# Partition the new disk as LVM | |
echo -e "n\np\n1\n\n\nt\n8e\nw" | sudo fdisk $NEWDEV | |
# Initiate the disk | |
sudo pvcreate $NEWDEV\1 | |
# Get the VG Name | |
VGNAME=$(sudo vgdisplay | grep 'VG Name' | awk {'print $3'}) | |
# Extend the volume | |
sudo vgextend $VGNAME $NEWDEV\1 | |
# Get the free size in VG | |
FREESIZE=$(sudo vgdisplay | grep 'Free PE / Size' | awk {'print $7'}) | |
# Get root partition | |
LVROOT=$(sudo lvdisplay | grep 'LV Name' | grep 'root' | awk {'print $3'}) | |
# Expand the volume | |
sudo lvextend -L $FREESIZE\G $LVROOT | |
# Expand the file system | |
sudo sudo resize2fs $LVROOT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment