How do I back up the stock/vendor bootchain for the Linksys E8450?

How do I back up the stock/vendor bootchain for the Linksys E8450? I was trying to follow the installation guide, but it's not immediately clear to me how I am supposed to go about it. The installation guide says the following:

WARNING #3 The installer is meant to be executed only once per device unless an update explicitly requires a bootloader update. In that case, make sure to copy the content of the boot_backup UBI volume off the device before re-running the installer, so you will still have a copy of the stock bootchain!

and then it says:

Backup stock/vendor bootchain

Connect to the device via SSH and enter the following commands:

mkdir /tmp/boot_backup
mount -t ubifs ubi0:boot_backup /tmp/boot_backup

Then, copy the files under /tmp/boot_backup using scp to your computer.

But how am I supposed to gain SSH access with the stock firmware? From what I can see, the stock firmware that comes with the E8450 doesn't have an SSH feature. Am I supposed to do this after installing OpenWRT? If so, that would be strange, as it sort of defeats the purpose of a backup.

One of the things the installer script does is back up the boot chain (but not the complete flash) into a new UBI volume called 'boot_backup'. Once you have run the UBI installer package on that router for the first time and you're in OpenWRT, that's when the backup should be taken. I recommend you do this after completing the installer steps as listed in the document (currently steps 1 - 13 under "Installing OpenWrt"). Additionally, this is the time to take any additional backups you might want to have on hand (especially the factory partition!)

I should also note that if you run the installer package more than once, the original boot_backup (and therefore the original boot chain) will be lost forever. Therefore, it's important to do this only after the first time you have run the installer on any given router.

One of the things the installer script does is back up the boot chain (but not the complete flash) into a new UBI volume called 'boot_backup'.

How do I backup the entire flash?


Once you have run the UBI installer package on that router for the first time and you're in OpenWRT, that's when the backup should be taken. I recommend you do this after completing the installer steps as listed in the document (currently steps 1 - 13 under "Installing OpenWrt").

Noted. Strange that it's after the install. What does one do if the install fails? They would have no backup of the original firmware.


Additionally, this is the time to take any additional backups you might want to have on hand (especially the factory partition!)

How do I do this? Is it just taking a backup of the entire flash? If so, I refer back to the first question.

If you're talking about backing up the factory flash contents, it's not an easy task. The stock firmware doesn't provide an easy way of offloading data. The easiest solution I've found is by connecting to the onboard serial console, using dd to copy the contents of each real mtd partition, and then subverting the onboard http server to serve up the backed up files.

Although Daniel took most of the avenues of failure into account, nothing can prevent the unexpected. The good news is that the installer was built with some safeguards against this, and so was the router. If the installer doesn't find what it needs to confirm it has found the necessary data, it aborts into an initramfs (recovery) install of OpenWRT. If the installer itself is corrupt and can't boot, then the stock configuration will fail over to its backup. The 'boot_backup' volume is an additional safeguard built into the installer. The installer backs up the boot data before it overwrites it.

The easiest solution, assuming you're running the stable OpenWRT, is to use luci to back up the mtdblock contents. The only one that is absolutely critical is 'factory'. As long as you want to run OpenWRT, all of the other partitions can be restored by using the versions downloaded from the official OpenWRT firmware builder web page.

If I understand you correctly, are you saying that that isn't necessary? I presume all that would do is backup the original vendor firmware, and I would also presume that there isn't much point in doing so?


So that would be what's found at System>Backup / Flash Firmware>Actions>Save mtdblock contents>Choose mtdblock>[bl2|fip|factory|ubi]? And you are saying that the only one that's crucial is factory?

Something interesting about that is that the files that are downloaded from luci, OpenWrt.mtd[0|1|2|3].bin (corresponding to bl2, fip, factory, ubi, respectively), seem to be the same as the ones in boot_backup, mtd[0|1|2|3]. Is the backup of boot_backup simply an alternative to what one can do in luci with "Choose mtdblock"?

It would back up the original vendor firmware and vendor layout, but it's still not the entire flash content. There are spaces in between partitions that would not be backed up. Although these spaces are assumed empty, they might contain data due to bad blocks or various other situations. However, those regions are not directly addressable from within the stock firmware, and I haven't found a mechanism within U-Boot (modern or stock) that would allow easy extraction of the data, either.

As for the point of doing so, the only value in retaining all of the data would be in someone looking for the option to return to stock firmware. Since the manufacturers have declared both models as past end-of-life, there will be no more security patches or updates for them. Therefore, the value of that kind of exercise at this point is purely academic.

Correct. For this router, the 'factory' partition is the only one that doesn't have a publicly available and intact replacement.

They have the same names because they're all backups of the mtd partitions. However, boot_backup is a backup from a different time. When you run the UBI installer, the first thing the script does is take copies of the data as it exists prior to the changes, excluding "large" partitions containing the OS images. The mtdblock content download from luci takes the data as it exists at the time the button on the web page was pressed. Therefore, the data is only equal if you run the same installer script more than once.

1 Like

I'm still a little confused about how they differ — in which cases would each of them be used as a point of restoration? Where and why would one work and not the other?

The stock boot chain design is quite different from the OpenWRT boot chain, even though the software is essentially the same. The stock boot chain had more steps, with the components separated. The version of U-Boot used in the stock boot chain is much older and much more limited feature-wise. The stock boot chain also failed to properly implement the error correction functionality, so the flash memory was more prone to experiencing faults. However, stock firmware is far less frequently updated, and all of this is what was expected by the stock upgrade process. Having a completely different and unexpected boot chain design while running stock firmware would have been very likely to cause issues when upgrading.

Essentially, the only reason I can see to hold onto the original boot chain would be to preserve the data (since from the script, it looks like it might also try to preserve the factory partition) or if you might want to try to restore the stock firmware at some point either for yourself, or if you were intending to eventually re-sell the router. However, given that the factory firmware is now obsolete and the device is officially end of life, I see absolutely no reason to do so other than for academic purposes. Since it's at present easier to get the factory partition via luci (if and only if you're using the stable firmware on the 1.0.x or older UBI installer), this really limits the value of the boot_backup.

1 Like