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