From 97c5a5f9b3e6bbb7748dbf256dc7b6f71c167aa1 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Wed, 3 Apr 2024 21:28:47 +0200 Subject: upslak.sh : prevent loss of persistent data in case of insufficient space Thanks to Peter Sevens for reporting and showing an example. --- upslak.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'upslak.sh') diff --git a/upslak.sh b/upslak.sh index 438d90f..0a82690 100644 --- a/upslak.sh +++ b/upslak.sh @@ -1280,7 +1280,19 @@ if [ $CHANGES2SXZ -eq 1 ]; then echo "*** Unable to create file '/mnt/live/changes/.wipe'!" echo "*** Are you sure you are running ${DISTRO^} Live Edition?" else - # Squash the persistence data into a Live .sxz module: + # Squash the persistence data into a Live .sxz module, + # but only if we find the space to do so: + CHANGESSIZE=$(du -sm /mnt/live/changes/ |tr '\t' ' ' |cut -d' ' -f1) + if [ $(( $USBPFREE - $CHANGESSIZE )) -lt $MINFREE ]; then + CHANGES2SXZ=-1 + fi + if [ $CHANGES2SXZ -eq -1 ]; then + echo "*** Not enough space to squash persistence data into a module." + # Don't wipe persistence data on next boot! + rm -f /mnt/live/changes/.wipe + cleanup + exit 1 + fi LIVE_MOD_SYS=$(dirname $(find ${USBMNT} -name "0099-${DISTRO}_zzzconf*.sxz" |head -1)) LIVE_MOD_ADD=$(dirname ${LIVE_MOD_SYS})/addons MODNAME="0100-${DISTRO}_customchanges-$(date +%Y%m%d%H%M%S).sxz" -- cgit v1.2.3