When performing sysupgrade, the new image takes a full image, and overrides both kernel and rootfs partitions.
What if, I only want to update the kernel partition? I can't find the kernel-only image (zImage, uImage, whatever).
Where can I find that?
That is what I think as well, but if I wan'na take the risk and do it, is it possible? I want to change some sources in the kernel, without replacing the rootfs...
Not possible as kernel modules are in the root file system. There’s the further complication that the MTD partitions are dynamic, based on the size of the kernel.
sysupgrade -h will provide help text, which includes
-l | --list-backup
list the files that would be backed up when calling
sysupgrade -b. Does not create a backup file.
The list comes from metadata about the installed packages' config files to start. It can be modified to include additional files/directories by editing /etc/sysupgrade.conf
For example, on one of my boxes, to handle things that I configured (not part of packages):
## This file contains files and directories that should
## be preserved during an upgrade.
# /etc/example.conf
# /etc/openvpn/
/etc/.git
/etc/.gitignore
/etc/ethers
/etc/logrotate.d/
/etc/mac80211-post-add.sh
/root
/home
Thanks again for your reply.
What if I want to upgrade my system using mtd write instead of sysupgrade?
is there any possibility to save information and then restore?
I hope it's okay I am reviving this old thread.
I am still trying to cope with this issue. I want to manually save some config files, update firmware using mtd write and restore the config files.
I noticed that sysupgrade saves the configurations in a file named sysupgrade.tfx, but while it looks it is saved /tmp partition, the mount_boot searches for sysupgrade.tgz in "/" partition when booting, to restore.
So where is it being saved? It must be a free partition which is not deleted while updating firmare partition (which includes kernel, rootfs and rootfs_data) and not erased when rebooting.
How is it copied to the new overlay after flashing?
Just to make sure it works, i'm trying to create a new file by using:
echo "some text" > /filename.txt
running that line right after I flash the image, and before the reboot.
but after reboot, the new file is not available....
What am I missing? Should I access the new overlay in a different way?
You can’t “cut off the branch you’re standing on”. All processes other than procd need to be killed and it needs to exec something that uses the new root. See pivot_root if you want to pursue further.
Writing a custom upgrade function within the existing sysupgrade process is likely an easier approach.
Edit:
default_do_upgrade() {
local err
sync
if [ "$SAVE_CONFIG" -eq 1 ]; then
get_image "$1" "$2" | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j "$CONF_TAR" write - "${PART_NAME:-image}"
else
get_image "$1" "$2" | mtd $MTD_ARGS write - "${PART_NAME:-image}"
fi
err=$?
if [ $err -ne 0 ] ; then
>&2 echo "ERROR: default_do_upgrade mtd write error: $err"
exit 1
fi
}
This must be done at a low level for NOR flash as you can't mount the file system before rebooting in any reasonable way.
I am sure it is easier, but it won't answer my needs.
I need a simple updater, to store my own couple of files (previously known and hard coded - no need to make all the tests and checkups), use mtd write to flash the image and the restore my previously saved files.
Where can I find information about the pivot_root? I managed to find some info in openwrt site, but it says it's obsolete.
You would be surprised. You can do just about anything you need, letting the existing sysupgrade framework take care of the process of changing the root filesystem. See the contents of package/base-files/files/lib/upgrade/ as well as how the stage2 upgrader is selected. See, for an example of "something completely different" target/linux/ipq40xx/base-files/lib/upgrade/linksys.sh
That will not work because / is not a directory configured to be saved.
sysupgrade ability to save setting is based on a tar-gz of the whole tree of files to be save. This tar is kept in the ram disk while writing the flash. Then it is extracted and written to the new filesystem before rebooting. So you can make the backup, add any extra files you want using regular archive tools, then run sysupgrade with that new backup and all the files will be in the new install.
You should consider that if you don't understand how those work, your likelihood of being successful in writing a replacement, which is effectively what you will have to do, will continue to be vanishingly small.