Last active
April 28, 2026 19:15
-
-
Save huyvometropolis/38c18928df563d68e829be36be034534 to your computer and use it in GitHub Desktop.
Update AIMobile yocto OS on the flight. It checks the active slot, picks the other partition, writes, flips the slot, and reboots — nothing else.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -euo pipefail | |
| ROOTFS="${1:?Usage: $0 <rootfs.ext4>}" | |
| [ -f "$ROOTFS" ] || { echo "Error: file not found: $ROOTFS"; exit 1; } | |
| ACTIVE=$(/usr/sbin/nvbootctrl get-current-slot) | |
| if [ "$ACTIVE" = "0" ]; then | |
| INACTIVE_PART=/dev/nvme0n1p2 | |
| NEXT_SLOT=1 | |
| else | |
| INACTIVE_PART=/dev/nvme0n1p1 | |
| NEXT_SLOT=0 | |
| fi | |
| echo "Active slot: $ACTIVE" | |
| echo "Writing to: $INACTIVE_PART" | |
| dd if="$ROOTFS" of="$INACTIVE_PART" bs=4M conv=fsync status=progress | |
| /usr/sbin/nvbootctrl set-active-boot-slot "$NEXT_SLOT" | |
| echo "Boot slot set to: $NEXT_SLOT — rebooting" | |
| sync && /sbin/reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment