I want to improve the sysupgrade script, making it support extroot better.
I have the following improvements in mind:
- After upgrading but before restarting, new usb storage related packages are installed to the jffs2 partition, along with the fs package to support the current usb overlay's filesystem.
- Before upgrading,
/etc/config/fstabin jffs2 partition is saved to/tmp, and after upgrading, restored to the jffs2 partition - The upper directory in the usb overlay is removed after upgrading, making sure no mismatched kernel and kernel modules.
- All other saved configs (if any) are restored to the usb overlay after upper is removed.
This as the following benefits comparing to the current version:
- After upgrading and restarting, extroot is still loaded.
- Saved config are restored to usb overlay, not jffs2.
- Each new release should contain a script that installs usb storage and fs packages required to make a functioning extroot. We don't want an old release to install these packages for a new release.
- The upper directory in usb overlay should be automatically removed after upgrading, since the usb overlay will be loaded after restarting.
KanjiMonster raise that concern that automatically wiping out the usb overlay might cause some damage, since it's currently persist across upgrading. I think it can be fixed by put the extroot support behind a flag in the sysupgrade script, only when enabled, the usb overlay is wiped out, otherwise the script does exactally what it does now.
I intend to implement the extroot support, and have given the sysupgrade souce a read. There are a few things I don't quite understand, and would like to get some help:
-
The script calls
ubus call system upgrade, what does it do? Is it simply a event notification that by default no other processes listen to? -
Who calls the script with
nandcommand, in which case it executesnand_upgrade_stage2? -
What does
mount -o bind /tmp/root /tmp/rootdo? Binding a directory to itself doesn't make sense to me.Google doesn't help much on this topic. Although the man page of mount does mention the case of bind a directory to itself, but I failed to understand the explanation: "it's also possible to use the bind mount to create a mountpoint from a regular directory". Isn't mountpoint just a mounted directory? What does creating a mounted directory from the same directory mean?
-
I search the whole OpenWrt repo, no script is using the
jffs2_copy_configfunction in thecommon.shscript. No packages seem to be using this function either. Is it safe to remove it? -
How is the jffs2 partition wiped out? The mtd command that writes the image to flash has this
firmwarearguments passed, which mean it should only overwrite that mtd block. I don't see other commands that overwrites the jffs2 partition.