Owut upgrade question for rpi4 with custom scripts and root file system size

Hello,

I am currently running 24.10.0-rc4 on rpi4.
Custom things on it is,

  • custom opkg packages.
  • custom firewall rules
  • custom static ipv4/ipv6 address.
  • one custom service (/etc/init.d/) created out of a custom script
  • and root file system expanded to full size as below
opkg install parted losetup resize2fs
wget -U "" -O expand-root.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=0"
. ./expand-root.sh
sed -i 's|root=PARTUUID=ba416753-02|root=/dev/mmcblk0p2|' /boot/cmdline.txt
sh /etc/uci-defaults/70-rootpt-resize

Do I simply have to run owut upgrade and it should upgrade and retain all above?

I went ahead and tried owut upgrade and it did upgrade. However few issue I ran in to,

  • It did not boot, and to fix, I had to run.
sed -i 's|root=PARTUUID=ba416753-02|root=/dev/mmcblk0p2|' /boot/cmdline.txt
  • custom service (/etc/init.d/) was gone.

See this post for an update to the extend script. I've tested it once but if you have a minute give it a go too.

It should amend the cmdline.txt with the new partuuid.

Are you suggesting I download https://openwrt.org/_export/code/docs/guide-user/advanced/expand_root?codeblock=0" and before executing edit expand_root.sh to include,

NEW_UUID=`blkid ${ROOT_DISK}p${ROOT_PART} | sed -n 's/.*PARTUUID="\([^"]*\)".*/\1/p'`
sed -i "s/PARTUUID=[^ ]*/PARTUUID=${NEW_UUID}/" /boot/cmdline.txt

?

expand_root.sh will create a couple of files in your file system.

/etc/uci-defaults/70-rootpt-resize
/etc/uci-defaults/80-rootfs-resize

These will run on first boot or manually as you have run by doing "sh /etc/uci-defaults/70-rootpt-resize".

/etc/uci-defaults/70-rootpt-resize will resize the root partition. During the resize the PARTUUID changes. If you edit 70-rootpt-resize and add the following after touch /etc/rootpt-resize (line 12)

NEW_UUID=`blkid ${ROOT_DISK}p${ROOT_PART} | sed -n 's/.*PARTUUID="\([^"]*\)".*/\1/p'`
sed -i "s/PARTUUID=[^ ]*/PARTUUID=${NEW_UUID}/" /boot/cmdline.txt

It should update the partuuid in cmdline.txt after the partition resize but before the reboot, so the system should come up again successfully without intervention. This should help with subsequent upgrades too.

My logic is that replacing the PARTUUID is a more generic way of fixing this issue rather than replacing the partuuid with /dev/mmcblk0p2 as there may be people who have their root on a different partition/device.

Hope this makes sense.

make sense.
I ran the logic outside the script and it correctly resolved NEW_UUID
I updated /etc/uci-defaults/70-rootpt-resize as you suggested.

Will monitor on next reboot/upgrade

1 Like