Blame SOURCES/rootfs-expand

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