- Image resize fix + added logging,

- adding name to PV
- minimize modules unloading timeout
This commit is contained in:
Igor Pečovnik 2015-12-18 21:52:33 +01:00
parent 155a2a666c
commit 3c555c933c
3 changed files with 11 additions and 3 deletions

View file

@ -323,6 +323,7 @@ losetup $LOOP $RAWIMAGE
PARTSTART=$(parted $LOOP unit s print -sm | tail -1 | cut -d: -f2 | sed 's/s//')
PARTEND=$(parted $LOOP unit s print -sm | head -3 | tail -1 | cut -d: -f3 | sed 's/s//') # end of first partition
PARTSTARTBLOCKS=$(($PARTSTART*512))
echo "PARTSTART $PARTSTART PARTEND $PARTEND PARTSTARTBLOCKS $PARTSTARTBLOCKS" >> $DEST/debug/install.log
sleep 1; losetup -d $LOOP
# convert from EXT4 to EXT2
sleep 1; losetup -o $PARTSTARTBLOCKS $LOOP $RAWIMAGE
@ -333,6 +334,7 @@ resize2fs $LOOP -M >/dev/null 2>&1
BLOCKSIZE=$(LANGUAGE=english tune2fs -l $LOOP | grep "Block count" | awk '{ print $(NF)}')
RESERVEDBLOCKSIZE=$(LANGUAGE=english tune2fs -l $LOOP | grep "Reserved block count" | awk '{ print $(NF)}')
BLOCKSIZE=$(($PARTSTART+$BLOCKSIZE+$RESERVEDBLOCKSIZE))
echo "BLOCKSIZE $BLOCKSIZE RESERVEDBLOCKSIZE $RESERVEDBLOCKSIZE" >> $DEST/debug/install.log
resize2fs $LOOP $BLOCKSIZE >/dev/null 2>&1
tune2fs -O has_journal $LOOP >/dev/null 2>&1
tune2fs -o journal_data_writeback $LOOP >/dev/null 2>&1
@ -345,7 +347,7 @@ PARTITIONS=$(parted -m $LOOP 'print' | tail -1 | awk -F':' '{ print $1 }')
#((echo d; echo $PARTITIONS; echo n; echo p; echo ; echo ; echo "+"$NEWSIZE"K"; echo w;) | fdisk $LOOP)>/dev/null
parted $LOOP rm $PARTITIONS >/dev/null 2>&1
NEWSIZE=$(($BLOCKSIZE*4700/1024)) # overhead hardcoded to number
NEWSIZE=$((($BLOCKSIZE+$RESERVEDBLOCKSIZE)*5000/1024)) # overhead hardcoded to number
STARTFROM=$(($PARTEND+1)) # if we have two partitions, start of second one is where first one ends +1
[[ $PARTITIONS == 1 ]] && STARTFROM=$PARTSTART
@ -357,6 +359,7 @@ TRUNCATE=$(parted -m $LOOP 'unit s print' | tail -1 | awk -F':' '{ print $3 }' |
TRUNCATE=$((($TRUNCATE+1)*512))
truncate -s $TRUNCATE $RAWIMAGE >/dev/null 2>&1
losetup -d $LOOP
echo "NEWSIZE $NEWSIZE STARTFROM $STARTFROM TRUNCATE $TRUNCATE" >> $DEST/debug/install.log
}

View file

@ -80,7 +80,7 @@ if [ -f "$DEST/cache/rootfs/$RELEASE.tgz" ]; then
currtime=`date +%s`
diff=$(( (currtime - filemtime) / 86400 ))
display_alert "Extracting $RELEASE from cache" "$diff days old" "info"
pv -p -b -r "$DEST/cache/rootfs/$RELEASE.tgz" | pigz -dc | tar xp -C $DEST/cache/sdcard/
pv -p -b -r -c -N "$RELEASE.tgz" "$DEST/cache/rootfs/$RELEASE.tgz" | pigz -dc | tar xp -C $DEST/cache/sdcard/
if [ "$diff" -gt "3" ]; then
chroot $DEST/cache/sdcard /bin/bash -c "apt-get update" | dialog --backtitle "$backtitle" --title "Force package update ..." --progressbox 20 70
fi
@ -183,7 +183,7 @@ KILLPROC=$(ps -uax | pgrep dbus-daemon | tail -1); if [ -n "$KILLPROC" ]; then k
display_alert "Closing debootstrap process and preparing cache." "" "info"
tar cp --directory=$DEST/cache/sdcard/ --exclude='dev/*' --exclude='proc/*' --exclude='run/*' --exclude='tmp/*' \
--exclude='mnt/*' --exclude='sys/*' . | pv -p -b -r -s $(du -sb $DEST/cache/sdcard/ | cut -f1) | pigz > $DEST/cache/rootfs/$RELEASE.tgz
--exclude='mnt/*' --exclude='sys/*' . | pv -p -b -r -s $(du -sb $DEST/cache/sdcard/ | cut -f1) -N "$RELEASE.tgz" | pigz > $DEST/cache/rootfs/$RELEASE.tgz
fi
#
# mount proc, sys and dev

View file

@ -94,6 +94,11 @@ jessie)
# disable some getties
sed -e 's/5:23:respawn/#5:23:respawn/g' -i $DEST/cache/sdcard/etc/inittab
sed -e 's/6:23:respawn/#6:23:respawn/g' -i $DEST/cache/sdcard/etc/inittab
# seting timeout
mkdir -p $DEST/cache/sdcard/etc/systemd/system/systemd-modules-load.service.d/
echo "[Service]" > $DEST/cache/sdcard/etc/systemd/system/systemd-modules-load.service.d/10-timeout.conf
echo "TimeoutStopSec=10" >> $DEST/cache/sdcard/etc/systemd/system/systemd-modules-load.service.d/10-timeout.conf
;;
# Ubuntu Trusty