Backing up stock firmware in mtdflash via netcat from running system (Ubiquiti EdgeRouter ER-X)

Hi,

the wiki currently recommends to backup the stock firmware on the Ubiquiti EdgeRouter ER-X models by first ram-booting openwrt and then running the backup from there.

I thought I found an easier method that works with just the unmodified stock firmware: First, I ssh'd into the box (password is "ubnt" by default):

ssh ubnt@192.168.1.1
su

And then started a netcat process for each partition of the mtd device (mtd0ro, mtd1ro and so on):

cd /dev
cat mtd0ro | nc -lp 5555

On the computer connected to my router, I started a netcat process as well:

nc -w 10 192.168.1.1 5555 > mtd0ro

To make sure it worked, I compared both the sizes (which seemed fine) and the checksums:

md5sum /dev/mtd0ro

However, for some reason, the checksums for the following partitions did not match:

  • mtd1ro
  • mtd2ro
  • mtd7ro

The other partitions seem fine. Any ideas why this is the case? I didn't expect their contents to change while the OS is running. Or is to be this expected for mtd flash on this model?

This is a bad idea on NAND flash. mtd is not aware of bad blocks. For the large partitions that may contain bad blocks, reading/writing needs to be done at the ubi level. Reading a bad block with mtd may not return the same data every time. That's why it's a bad block.

Recently Ubiquiti added a TFTP recovery function to the bootloader and published a TFTP recoverable firmware file. This makes it rather un-brickable. Make sure you have the new bootloader before installing OpenWrt.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.