From 8b98b2e1604e4262b9579bf3f75c9c9d88b11350 Mon Sep 17 00:00:00 2001 From: BodgeMaster <> Date: Sun, 22 Mar 2026 04:34:08 +0100 Subject: [PATCH] system-image: check that the mksquashfs command actually succeeded before overwriting the old image --- opt/system-image | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/opt/system-image b/opt/system-image index 99d21c6..266c3c5 100644 --- a/opt/system-image +++ b/opt/system-image @@ -97,10 +97,14 @@ if $DONT_ASK || yesno; then echo_tty "Building image..." mksquashfs / /run/void-usb/container/new_squashfs.img -b 1M -comp xz -progress -noappend -pf /run/void-usb/system-image-pseudo -ef /run/void-usb/system-image-excludes > $TTY_OR_CONSOLE - - echo_tty -n "Moving new image in place... " - mv /run/void-usb/container/new_squashfs.img /run/void-usb/container/squashfs.img - echo_tty "done" + if [ "$?" -ne 0 ]; then + echo_tty "An error ocurred while generating the image. It will be discarded." + sleep 5 + else + echo_tty -n "Moving new image in place... " + mv /run/void-usb/container/new_squashfs.img /run/void-usb/container/squashfs.img + echo_tty "done" + fi else echo_tty "Discarding system changes." fi