Previous method does not work on Ubuntu
This commit is contained in:
parent
e54a30dc77
commit
d4f8441b9a
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user