From c65b9daf1fd087cd41ec0c093bebba21535f8da1 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 15 Dec 2015 17:54:43 +0100 Subject: [PATCH] add autosizer source, modified README --- build_arm_image/README.md | 19 +++++++++++++++---- build_arm_image/autosizer.sh | 22 +++++++++++++--------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/build_arm_image/README.md b/build_arm_image/README.md index 87beb64..96f2c74 100644 --- a/build_arm_image/README.md +++ b/build_arm_image/README.md @@ -1,7 +1,18 @@ -This folder contains helper script to build arm image for raspberry and derivative arm plateform. +This folder contains helper scripts to build an arm image for raspberry. +The files here are for builder. They are not needed to install yunohost. -the folder structure maps debian OS folders. +The folder structure maps debian OS folders, shell script here are helpers. -files are copied to the /root when finished. +The files are copied on the sdcard when installation is finished. -See also: https://yunohost.org/#/build_arm_image +See also: https://yunohost.org/#/build_arm_image for previous step. + +run the following script before shuting down your rasbian. + +~~~ +./intsall_arm.sh +~~~ + + +autosizer.sh is used on your PC to compact the dd image you will copy back. +this script requier root privilege to run and modify the sdcard image. diff --git a/build_arm_image/autosizer.sh b/build_arm_image/autosizer.sh index 6f36138..af21b23 100755 --- a/build_arm_image/autosizer.sh +++ b/build_arm_image/autosizer.sh @@ -1,6 +1,9 @@ #!/bin/bash # Automatic Image file resizer # Written by SirLagz +# +# got from: http://sirlagz.net/2013/03/10/script-automatic-rpi-image-downsizer/ + strImgFile=$1 if [[ ! $(whoami) =~ "root" ]]; then @@ -12,20 +15,20 @@ if [[ ! $(whoami) =~ "root" ]]; then exit fi -if [[ -z $1 ]]; then +if [[ -z $strImgFile ]]; then echo "Usage: ./autosizer.sh " exit fi -if [[ ! -e $1 || ! $(file $1) =~ "x86" ]]; then +if [[ ! -e $strImgFile || ! $(file $strImgFile) =~ "x86" ]]; then echo "Error : Not an image file, or file doesn't exist" exit fi -partinfo=`parted -m $1 unit B print` -partnumber=`echo "$partinfo" | grep ext4 | awk -F: ' { print $1 } '` +partinfo=`parted -m $strImgFile unit B print` +partnumber=`echo "$partinfo" | grep ext4 | awk -F: ' { print $strImgFile } '` partstart=`echo "$partinfo" | grep ext4 | awk -F: ' { print substr($2,0,length($2)-1) } '` -loopback=`losetup -f --show -o $partstart $1` +loopback=`losetup -f --show -o $partstart $strImgFile` e2fsck -f $loopback minsize=`resize2fs -P $loopback | awk -F': ' ' { print $2 } '` minsize=`echo $minsize+1000 | bc` @@ -34,7 +37,8 @@ sleep 1 losetup -d $loopback partnewsize=`echo "$minsize * 4096" | bc` newpartend=`echo "$partstart + $partnewsize" | bc` -part1=`parted $1 rm 2` -part2=`parted $1 unit B mkpart primary $partstart $newpartend` -endresult=`parted -m $1 unit B print free | tail -1 | awk -F: ' { print substr($2,0,length($2)-1) } '` -truncate -s $endresult $1 +# TODO: 2 is probably $partnumber +part1=`parted $strImgFile rm 2` +part2=`parted $strImgFile unit B mkpart primary $partstart $newpartend` +endresult=`parted -m $strImgFile unit B print free | tail -1 | awk -F: ' { print substr($2,0,length($2)-1) } '` +truncate -s $endresult $strImgFile