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

This commit is contained in:
Simone Karin Lehmann 2018-03-13 22:29:56 +01:00 committed by Simone Karin Lehmann
parent 9ec17c9c1d
commit a9b0244e29
2 changed files with 8 additions and 4 deletions

View File

@ -43,5 +43,11 @@ cp -a e2fsck/e2fsck "$BASE"
cp -a resize/resize2fs "$BASE" cp -a resize/resize2fs "$BASE"
cp -a misc/tune2fs "$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" cd "$BASE"
diskutil eject "/Volumes/Ramdisk" diskutil eject "/Volumes/Ramdisk"

View File

@ -86,9 +86,7 @@ sleep 1
#Truncate the file #Truncate the file
endresult=$(($newpartend * 512)) endresult=$(($newpartend * 512))
endresult=$(($endresult + 1)) endresult=$(($endresult + 1))
dd if="$img" of="$img-shrinked.img" bs=512 count=$endresult truncate -s $endresult "$img"
aftersize=$(ls -lh "$img-shrinked.img" | tr -s " " | cut -d " " -f 5) aftersize=$(ls -lh "$img" | tr -s " " | cut -d " " -f 5)
rm -f "$img"
mv "$img-shrinked.img" "$img"
echo "Shrunk $img from $beforesize to $aftersize" echo "Shrunk $img from $beforesize to $aftersize"