arrfab / rpms / centos-release

Forked from rpms/centos-release 5 years ago
Clone
f85a5f
#!/bin/bash
f85a5f
clear
f85a5f
part=$(mount |grep '^/dev.* / ' |awk '{print $1}')
f85a5f
if [ -z "$part" ];then
f85a5f
    echo "Error detecting rootfs"
f85a5f
    exit -1
f85a5f
fi
f85a5f
dev=$(echo $part|sed 's/[0-9]*$//g')
f85a5f
devlen=${#dev}
f85a5f
num=${part:$devlen}
f85a5f
if [[ "$dev" =~ ^/dev/mmcblk[0-9]*p$ ]];then
f85a5f
    dev=${dev:0:-1}
f85a5f
fi
f85a5f
if [ ! -x /usr/bin/growpart ];then
f85a5f
    echo "Please install cloud-utils-growpart (sudo yum install cloud-utils-growpart)"
f85a5f
    exit -2
f85a5f
fi
f85a5f
if [ ! -x /usr/sbin/resize2fs ];then
f85a5f
    echo "Please install e2fsprogs (sudo yum install e2fsprogs)"
f85a5f
    exit -3
f85a5f
fi
f85a5f
echo $part $dev $num
f85a5f
f85a5f
echo "Extending partition $num to max size ...."
f85a5f
growpart $dev $num
f85a5f
echo "Resizing ext4 filesystem ..."
f85a5f
resize2fs $part
f85a5f
echo "Done."
f85a5f
df -h |grep $part
f85a5f