aboutsummaryrefslogtreecommitdiffstats
path: root/upslak.sh
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2024-04-03 21:28:47 +0200
committer Eric Hameleers <alien@slackware.com>2024-04-03 21:28:47 +0200
commit97c5a5f9b3e6bbb7748dbf256dc7b6f71c167aa1 (patch)
tree73847beee35c57a1a42e521fa00c1bc46aa91640 /upslak.sh
parent275c5cec36e186d4246f51e351296f164e38dbdf (diff)
downloadliveslak-97c5a5f9b3e6bbb7748dbf256dc7b6f71c167aa1.tar.gz
liveslak-97c5a5f9b3e6bbb7748dbf256dc7b6f71c167aa1.tar.xz
upslak.sh : prevent loss of persistent data in case of insufficient space
Thanks to Peter Sevens for reporting and showing an example.
Diffstat (limited to 'upslak.sh')
-rw-r--r--upslak.sh14
1 files changed, 13 insertions, 1 deletions
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"