System crashes after OTA upgrade fails

OTA upgrade turns on ROOTFS_AB_ENABLED,
After upgrading the bootloader, power off before upgrading rootfs.
After restarting, run nvbootctrl get-current-slot and find that the slot has been switched, but the rootfs slot is inconsistent with the current slot. As a result, when the rootfs is upgraded via OTA again, the upgrade script directly deletes the currently used rootfs and the system crashes.

echo “Deleting directories/files in the ${rootfs_partition}”
echo “Entering ${tmp_mnt}”
pushd “${tmp_mnt}” > /dev/null 2>&1 || return 1
echo “find "${tmp_mnt}" -maxdepth 1 ! -name "ota*" -exec rm -rf {} ;”
if ! find . -maxdepth 1 ! -name “ota*” -exec rm -rf “{}” ;; then
echo “Failed to delete dirs/files in the ${rootfs_partition}”
return 1
fi
popd > /dev/null 2>&1 || return 1
echo “Exiting ${tmp_mnt}”

hello shuang.cao,

may I know which L4T release version you’re based-on, and which is your target L4T version for OTA update?
besides, is your device flashed with RootfsA/B?

please see-also developer guide for more details, Updating Jetson Linux with Image-Based Over-the-Air Update.

32.7.4 → 32.7.4
yes, enable RootfsA/B
ROOTFS_AB=1

I found that sudo nvbootctrl is-unified-enabled returns 0, which is the enabled state.

In this case, after OTA bootloader, rootfs will not be upgraded. Restart.

The bootloader switches the slot: sudo nvbootctrl get-current-slot

Rootfs cannot view the slot, prompting Warning: unified bootloader and rootfs a/b is enabled, can NOT inquire rootfs info!
But df -h found that rootfs is still the old slot before the change.

OTA again, the software thinks that the old slot is the rootfs that needs to be updated, then rm -rf deletes the rootfs that is being mounted, and the system crashes

please see-also Topic 270687 for reference.

Sorry, we use ota tools:
ota_tools_R32.7.4_aarch64.tbz2

I can’t find useful information with
Topic 270687

hello shuang.cao,

this should be expected. as it always to tie bootloader A/B to rootfs A/B.
please use below commands to switch the rootfs slots.
$ sudo nvbootctrl set-active-boot-slot 0 (boot on RootFS A)
$ sudo nvbootctrl set-active-boot-slot 1 (boot on RootFS B)

BTW…

sorry, I did not notice your steps at the first place.
are you intended to corrupted OTA process? I don’t it’s fully tested with rel-32 release version.