Skip to content

Commit

Permalink
Merge pull request #98 from netzint/update-zeroing-pv
Browse files Browse the repository at this point in the history
Update zeroing pv
  • Loading branch information
HappyBasher committed Jul 24, 2023
2 parents 442ec03 + d46d9e6 commit 5dab3c7
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 9 deletions.
6 changes: 6 additions & 0 deletions build/conf.d/8_pv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# pv build environment

PVNAME="pv"
PVURL="https://github.com/icetee/$PVNAME"
PVSRCDIR="$SRC/$PVNAME"
PVBIN="$PVSRCDIR/$PVNAME"
3 changes: 3 additions & 0 deletions build/initramfs.d/18_pv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ctorrent

file /usr/bin/pv @@PVBIN@@ 755 0 0
2 changes: 2 additions & 0 deletions build/run.d/7_linbofs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ echo "# static entries" > "$INITRAMFS_BUILD"
for i in "$BUILDINITD"/*; do
sed -e "s|@@BBBIN@@|$BBBIN|g
s|@@CHNTPWBIN@@|$CHNTPWBIN|g
s|@@CTORRENTBIN@@|$CTORRENTBIN|g
s|@@PVBIN@@|$PVBIN|g
s|@@KXBIN@@|$KXBIN|g
s|@@LINBOFS@@|$LINBOFS|g
s|@@SERVERFS@@|$SERVERFS|g" "$i" >> "$INITRAMFS_BUILD" || exit 1
Expand Down
27 changes: 27 additions & 0 deletions build/run.d/7_pv
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
#
# download and build ctorrent

# read build environment
for i in build/conf.d/*; do source "$i" || exit 1; done

# check for binary
if [ -s "$PVBIN" -a -x "$PVBIN" ]; then
echo "pv binary exists, skipping build."

else
# download
echo "Cloning $PVNAME source ..."
[ -d "$PVSRCDIR" ] && rm -rf "$PVSRCDIR"
cd "$SRC"
git clone "$PVURL" || exit 1
# compile
echo "Configuring $PVNAME ..."
cd "$PVSRCDIR" || exit 1

./configure || exit 1
echo "Compiling $PVNAME ..."
cd "$PVSRCDIR" || exit 1
make || exit 1
strip "$PVBIN" || exit 1
fi
2 changes: 2 additions & 0 deletions linbofs/linbo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ else # handle missing gui problem
echo "Console boot menue of group $HOSTGROUP"
echo "----------------------------------------"
count=0
if [ -d "/conf/" ]; then
for item in /conf/os.*; do
[ -s "$item" ] || continue
name=""
Expand All @@ -71,6 +72,7 @@ else # handle missing gui problem
count=$(( count + 1 ))
echo "[$count] Sync & start $name"
done
fi
echo "----------------------------------------"
echo "[R] Reboot"
echo "[S] Shutdown"
Expand Down
22 changes: 13 additions & 9 deletions linbofs/usr/bin/linbo_create_image
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,22 @@ mk_baseimage(){
local rootdev="$1"
local imagefile="$2"
echo "Filling up partition with zeroes..." | tee -a /tmp/image.log
freespace=$(df -kP $rootdev | awk 'NR==2 {print $4}')k
interruptible pv -s $freespace -tprebf /dev/zero | dd of=/mnt/zero.tmp bs=1024k 2>/tmp/image.log


# Create nulled files of size 1GB, should work on any FS.
local count=0
while true; do
# tschmitt: log errors to image.log
interruptible dd if=/dev/zero of="/mnt/zero$count.tmp" bs=1024k count=1000 2>>/tmp/image.log || break
[ -s "/mnt/zero$count.tmp" ] || break
let count++
echo "$(du -ch /mnt/zero*.tmp | tail -1 | awk '{ print $1 }') zeroed ... " | tee -a /tmp/image.log
done
#local count=0
#while true; do
# # tschmitt: log errors to image.log
# interruptible dd if=/dev/zero of="/mnt/zero$count.tmp" bs=1024k count=1000 2>>/tmp/image.log || break
# [ -s "/mnt/zero$count.tmp" ] || break
# let count++
# echo "$(du -ch /mnt/zero*.tmp | tail -1 | awk '{ print $1 }') zeroed ... " | tee -a /tmp/image.log
#done
# Sync is asynchronous, unless started twice at least.
sync ; sync ; sync
rm -f /mnt/zero*.tmp
rm -f /mnt/zero.tmp
umount /mnt || umount -l /mnt
echo "Starting compression of $rootdev -> $imagefile (full partition, ${size}K)."
echo "qemu-img convert -p -c -f raw -O qcow2 $rootdev $imagefile"
Expand Down

0 comments on commit 5dab3c7

Please sign in to comment.