OpenWrt Forum Archive

Topic: Reflash script that preserves /etc/config?

The content of this topic has been archived on 29 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi!

Is it possible to replace the squashfs root filesystem but preserve the jffs overlay (or part of it)?

I'm thinking something along these lines:

1. Copy all of root filesystem to a ram filesystem.

2. Pivotroot to the ram copy.

3. Unmount jffs and squashfs.

4. Flash new image (kernel + squashfs), e.g. 'mtd write /tmp/firmware.img firmware'.

5. Mount new empty jffs.

6. Copy part of ram filesystem back to jffs, e.g. 'cp -r /etc/config/ /jffs/etc/config'.

7. Reboot into new openwrt system with /etc/config preserved.

My feeling is the most difficult will be step 5 because mtd/jffs usually clears the filesystem on the first boot, no? So when the flash is replaced the mtd partition table is not updated and it is not possible to mount jffs partition.

Any thoughts? Anybody tried it? How do you get around the problem with mtd/jffs partition table update?

Yes, there is an option for this when flashing firmware in Luci. It does not preserve all the jffs but only the relevant config files (you can manually add files or directories). Make a backup before flashing just in case.

The discussion might have continued from here.