Skip to content

Commit

Permalink
Try to remove a zram device up to 5 times
Browse files Browse the repository at this point in the history
This helps make sure that the device is removed when we stop zram as
sometimes it will fail on the first try.

Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Nov 8, 2021
1 parent 04db705 commit d3d5629
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion zram-config
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ mergeOverlay() {
}

removeZdir() {
local count=0

if [[ -n $OLDLOG_DIR ]]; then
rm -f /etc/logrotate.d/00_oldlog
fi
Expand Down Expand Up @@ -150,7 +152,10 @@ removeZdir() {
return 1
fi

zramctl -r "/dev${ZRAM_DEV}" >> "$ZLOG" 2>&1 || return 1
until zramctl -r "/dev${ZRAM_DEV}" >> "$ZLOG" 2>&1 || [[ count -ge 5 ]]; do
count=$(( $count + 1 ))
sleep 5
done

echo "/dev$ZRAM_DEV removed" >> "$ZLOG"
}
Expand Down

0 comments on commit d3d5629

Please sign in to comment.