Blame SOURCES/rootfs-expand

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