From d4f8441b9a3a629aae1cc864bd3a8cf9e93025d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Pe=C4=8Dovnik?= Date: Sat, 26 Dec 2015 12:54:05 +0100 Subject: [PATCH] Previous method does not work on Ubuntu --- scripts/firstrun | 9 ++++++++- scripts/resize2fs | 13 ++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/firstrun b/scripts/firstrun index 114ac7d899..e933705c60 100644 --- a/scripts/firstrun +++ b/scripts/firstrun @@ -19,7 +19,14 @@ N=/etc/init.d/firstrun CURKERNE=$(uname -r | sed 's/\([0-9]\+\.[0-9]\+\)\..*/\1/') MACHINE=$(cat /run/machine.id) MEMTOTAL=$(awk 'BEGIN { printf "%.0f\n", '$(grep MemTotal /proc/meminfo | awk '{print $2}')'/1024/1024 }') -root_partition=$(findmnt --target / -o SOURCE -n) +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) set -e diff --git a/scripts/resize2fs b/scripts/resize2fs index a22a029e18..68f96141bc 100644 --- a/scripts/resize2fs +++ b/scripts/resize2fs @@ -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