From 0b04de8118d82e66bd6c681aeb64f1d3d3d6c5a6 Mon Sep 17 00:00:00 2001 From: Sean Mayo Date: Fri, 7 Jul 2017 15:53:20 -0700 Subject: [PATCH] reverted to using raspi-config to be used for automatic image resizing while not having to rely on the raspi-config tool does make the pishrink utility more portable, the raspi-config tool is already properly maintained. rather than being forced to maintain the autosizing utility in this script (which has already been broken for several months due to a linux kernal change), it just makes more sense to not have to rewrite properly maintained code. --- pishrink.sh | 45 +++++---------------------------------------- 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/pishrink.sh b/pishrink.sh index f2df6b9..5a481ef 100755 --- a/pishrink.sh +++ b/pishrink.sh @@ -60,51 +60,16 @@ if [ "$should_skip_autoexpand" = false ]; then mountdir=`mktemp -d` mount $loopback $mountdir - if [ `md5sum $mountdir/etc/rc.local | cut -d ' ' -f 1` != "c4eb22d9aa99915af319287d194d4529" ]; then + if [ `md5sum $mountdir/etc/rc.local | cut -d ' ' -f 1` != "a27a4d8192ea6ba713d2ddd15a55b1df" ]; then echo Creating new /etc/rc.local mv $mountdir/etc/rc.local $mountdir/etc/rc.local.bak ###Do not touch the following 6 lines including EOF### -cat <<\EOFE > $mountdir/etc/rc.local +cat <<\EOF > $mountdir/etc/rc.local #!/bin/bash -do_expand_rootfs() { - ROOT_PART=$(cat /proc/cmdline | tr -s ' ' '\n' | grep root= | cut -d '=' -f 2) - if [[ "$ROOT_PART" != /dev/mmcblk0* ]] ; then - echo $ROOT_PART is not an SD card... - return 0 - fi - PART_NUM=$(echo $ROOT_PART | cut -d 'p' -f 2) - - # Get the starting offset of the root partition - PART_START=$(fdisk -l /dev/mmcblk0 | grep $ROOT_PART | tr -s ' ' | cut -d ' ' -f 2) - [ "$PART_START" ] || return 1 - # Return value will likely be error for fdisk as it fails to reload the - # partition table because the root fs is mounted - fdisk /dev/mmcblk0 < /etc/rc.local && -#!/bin/sh -resize2fs $ROOT_PART -rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local - -EOF -reboot -exit -} -do_expand_rootfs -rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; /etc/rc.local +/usr/bin/raspi-config --expand-rootfs +rm -f /etc/rc.local; cp -f /etc/rc.local.bak /etc/rc.local; reboot exit 0 -EOFE +EOF ###End no touch zone### chmod +x $mountdir/etc/rc.local fi