title: “Resize RootFS”
date: 2020-10-23T13:16:20
slug: resize-rootfs
#!/bin/bash
fdisk\_first() {
p2\_start=`fdisk -l /dev/mmcblk0 | grep mmcblk0p2 | awk '{print $2}'`
echo "Found the start point of mmcblk0p2: $p2\_start"
fdisk /dev/mmcblk0 << \_\_EOF\_\_ >> /dev/null
d
2
n
p
2
$p2\_start
p
w
\_\_EOF\_\_
sync
touch /root/.resize
echo "Ok, Partition resized, please reboot now"
echo "Once the reboot is completed please run this script again"
}
resize\_fs() {
echo "Activating the new size"
resize2fs /dev/mmcblk0p2 >> /dev/null
echo "Done!"
echo "Enjoy your new space!"
rm -rf /root/.resize
}
if [ -f /root/.resize ]; then
resize\_fs
else
fdisk\_first
fi
