OpenWrt Forum Archive

Topic: How to backup spi flash image

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

Hi to all,

     I would like to backup my spi flash image of my openwrt router to a microSD card.

     "mmcblk0p1" is my uSD card but I am not sure about which one of the "mtd" is my rootfs.

     can anybody help me ?


root@mylinkit:/tmp/run/mountd/mmcblk0p1# ls /dev/
audio               mtd2                null                ttyS11
autofs              mtd2ro              port                ttyS12
bus                 mtd3                ppp                 ttyS13
console             mtd3ro              ptmx                ttyS14
cpu_dma_latency     mtd4                pts                 ttyS15
dsp                 mtd4ro              random              ttyS2
full                mtd5                shm                 ttyS3
i2c-0               mtd5ro              snd                 ttyS4
kmsg                mtd6                spidev32766.1       ttyS5
log                 mtd6ro              tty                 ttyS6
mem                 mtdblock0           ttyACM0             ttyS7
memory_bandwidth    mtdblock1           ttyACM1             ttyS8
mixer               mtdblock2           ttyACM2             ttyS9
mmcblk0             mtdblock3           ttyACM3             urandom
mmcblk0p1           mtdblock4           ttyACM4             watchdog
mtd0                mtdblock5           ttyACM5             watchdog0
mtd0ro              mtdblock6           ttyS0               zero
mtd1                network_latency     ttyS1
mtd1ro              network_throughput  ttyS10

cat /proc/mtd to identify the partitions.

The 'root' partition holds your kernel and squashfs.  It never changes during runtime.  The overlay partition has files written at runtime.  The one called firmware is a union of both combined.

Mount the SD card as a file system then create a file image of the firmware partition for example if it is mtd5, do

cat /dev/mtd5 > firmware.bin

You can then flash this file like a sysupgrade bin to restore your router to how it was when the backup was made, or flash it to another router of the same model to make a clone of the OS and configuration.

(Last edited by mk24 on 13 Jul 2017, 14:20)

can you please write step by step by commands ?

The discussion might have continued from here.