diff --git a/scripts/install-usb.sh b/scripts/install-usb.sh index d70cd07..f3ee020 100755 --- a/scripts/install-usb.sh +++ b/scripts/install-usb.sh @@ -60,7 +60,15 @@ trap cleanup EXIT mkdir -p "$TMP/boot" "$TMP/data" mount "$p2" "$TMP/boot"; mount "$p3" "$TMP/data" mkdir -p "$TMP/boot/boot/grub" "$TMP/data/reports" "$TMP/data/database" "$TMP/data/checklists" "$TMP/data/reference" -cp "$ISO" "$TMP/boot/pc-intake.iso" +if ! cp "$ISO" "$TMP/boot/pc-intake.iso" || ! sync -f "$TMP/boot"; then + current_size=$(blockdev --getsize64 "$DEVICE" 2>/dev/null || echo 0) + if ((current_size == 0)); then + echo 'USB medium disappeared while writing. Replace the stick or use another USB port.' >&2 + else + echo 'USB write failed. Check the stick and the kernel log before retrying.' >&2 + fi + exit 1 +fi # Copy video reference files separately under INTAKE_DATA/reference (optional). cat > "$TMP/boot/boot/grub/grub.cfg" <<'GRUBCFG' set timeout=5