From a9b0244e299fc912b073661f4e98c8379e96ea11 Mon Sep 17 00:00:00 2001 From: Simone Karin Lehmann Date: Tue, 13 Mar 2018 22:29:56 +0100 Subject: [PATCH] fix the calculation again to be used by truncate. use truncate instead of dd. add build instructions for truncate to the helper script to build it on macOS --- make_e2fstools | 6 ++++++ pishrink | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/make_e2fstools b/make_e2fstools index 1f64521..d1cb213 100755 --- a/make_e2fstools +++ b/make_e2fstools @@ -43,5 +43,11 @@ cp -a e2fsck/e2fsck "$BASE" cp -a resize/resize2fs "$BASE" cp -a misc/tune2fs "$BASE" +download https://ftp.gnu.org/gnu/coreutils/coreutils-8.29.tar.xz +cd core* +./configure --prefix "$TARGET" --disable-nls +make +cp -a src/truncate "$BASE" + cd "$BASE" diskutil eject "/Volumes/Ramdisk" diff --git a/pishrink b/pishrink index e8e5168..13ce853 100755 --- a/pishrink +++ b/pishrink @@ -86,9 +86,7 @@ sleep 1 #Truncate the file endresult=$(($newpartend * 512)) endresult=$(($endresult + 1)) -dd if="$img" of="$img-shrinked.img" bs=512 count=$endresult -aftersize=$(ls -lh "$img-shrinked.img" | tr -s " " | cut -d " " -f 5) -rm -f "$img" -mv "$img-shrinked.img" "$img" +truncate -s $endresult "$img" +aftersize=$(ls -lh "$img" | tr -s " " | cut -d " " -f 5) echo "Shrunk $img from $beforesize to $aftersize"