[Howto] Installation of 23.05.5 to Archer C60 v2

Hello,
This device prevented me from easy installation of openwrt, so recently I have put some effort into figuring out how to assemble the image for direct writing. I've polished the info from the wiki and adapted it to the newer 23.05.5 version. Here is the code.

#!/bin/bash

dumpname=./dump.bin
orig_bytes=`du -b ${dumpname} | cut -f1`

# owrt_sys=./openwrt-19.07.3-ath79-generic-tplink_archer-c60-v2-squashfs-sysupgrade.bin # overlay free space will be about 2900 KiB
owrt_sys=./openwrt-23.05.5-ath79-generic-tplink_archer-c60-v2-squashfs-sysupgrade.bin # this image is about 2 MiB bigger, so overlay will be about 900 KiB
owrt_sys_bytes=`du -b ${owrt_sys} | cut -f1`

# dead code must be found manually
owrt_use_bytes=0x470000 # for 19.07.3 sysupgrade image
owrt_use_bytes=0x650000 # for 23.05.5 sysupgrade image

part_os_image_base=0x030000
part_os_image_size=0x100000
part_file_system_size=0x6a9500
part_soft_vers_base=0x7d9500

padding_bytes=$((${part_os_image_size} + ${part_file_system_size} - ${owrt_use_bytes}))

echo Original size: ${orig_bytes}
echo OpenWRT sysupgrade size: ${owrt_sys_bytes}
echo OpenWRT sysupgrade size before the dead code: $((${owrt_use_bytes}))
echo OpenWRT padding bytes: ${padding_bytes}

if [ ${padding_bytes} -lt 0 ]; then
	echo Cannot build fw due to 8MiB size restriction.
	exit 0
fi
make_fw () { 
	dd if=${dumpname} bs=512 iflag=count_bytes count=$((${part_os_image_base}))          of=owrt_frankenstein.bin
	dd if=${owrt_sys} bs=512 iflag=count_bytes count=$((${owrt_use_bytes}))              >> owrt_frankenstein.bin
	dd if=/dev/zero   bs=512 iflag=count_bytes count=${padding_bytes} | tr "\000" "\377" >> owrt_frankenstein.bin
	dd if=${dumpname} bs=512 iflag=skip_bytes  skip=$((${part_soft_vers_base}))          >> owrt_frankenstein.bin

	new_bytes=`du -b owrt_frankenstein.bin | cut -f1`
	echo New size: ${new_bytes}
}

read -p "Continue (y/n)?" choice
case "$choice" in 
  y|Y|yes|Yes) make_fw ;;
  *) echo "Exiting without performing any actions"  ;;
esac


I still wonder how openwrt detects that location of rootfs_data has been changed.