Previous method does not work on Ubuntu

This commit is contained in:
Igor Pečovnik
2015-12-26 12:54:05 +01:00
parent e54a30dc77
commit d4f8441b9a
2 changed files with 18 additions and 4 deletions

View File

@@ -16,11 +16,18 @@ device="/dev/"$(lsblk -idn -o NAME | grep mmcblk0)
PARTITIONS=$(($(fdisk -l $device | grep $device | wc -l)-1))
device="/dev/"$(lsblk -idn -o NAME | grep mmcblk0)"p"$PARTITIONS
N=/etc/init.d/resize2fs
root_device=$(mountpoint -d /)
for file in /dev/* ; do
CURRENT_DEVICE=$(printf "%d:%d" $(stat --printf="0x%t 0x%T" $file))
if [ $CURRENT_DEVICE = $root_device ]; then
root_partition=$file
break;
fi
done
rootfstype=$(blkid -s TYPE -o value $root_partition)
case "$1" in
start)
root_partition=$(findmnt --target / -o SOURCE -n)
rootfstype=$(blkid -s TYPE -o value $root_partition)
start)
if [[ $rootfstype == ext4 && ! -f "/root/.no_rootfs_resize" ]]; then
echo -e "[\e[0;32m ok \x1B[0m] Resizing SD card file-system"
/sbin/resize2fs $device >/dev/null 2>&1