Cloning OpenWRT

I use OpenWRT on Linksys WRT54GL as a firewall. I would like to have the ability to fully clone the system. Reading the docs, it looks like the following should work:

  1. Backup the existing OpenWRT firmware (note whether it is White Russian or
    dd if=/dev/mtdblock/1 of=/tmp/backup20080704.trx
    scp backup20080704.trx pp:/mirror/firewall/
  2. Flash the WRT54GL with a “blank” firmware image, using instructions at OpenWrtDocs/Installing,
  3. The upload the firmware image, and reflash from within OpenWRT
    mtd -r write firmware.trx linux
  4. Or:  try using TFTP (this might not work, because it needs the .bin file, not the .trx generated in Step 1)

I’ll see if this works.

Comments

  1. Lars - 4 July 2008 @ 15:42

    Two things of note: (i) I like to use the pre-configured X-Wrt images from http://x-wrt.org/ and (ii) it is always useful to ensure that boot_wait is set (I set it to 10 seconds), which allows you to overcome a bad flash using TFTP (almost… always)

  2. Lars - 4 July 2008 @ 15:49

    I used the X-Wrt webinterface (System -> Upgrade) to upload the backup done in the previous step, and it seems to have worked (even without a reboot, although that should be a safe thing to do). It came up with the later X-Wrt version that my image had, the earlier kernel, the SSH keys, and the package list from my production system. Since I did not restore the NVRAM yet, some of the parameters are still wrong, but that also has the advantage that it comes up with the temporary IP address, and not with the IP address of the production system.

  3. Lars - 4 July 2008 @ 15:53

    For NVRAM, this should be used (for a complete clone – but I’m not going to try it now):


    dd if=/tmp/wrt-nvram.bin of=/dev/mtdblock/3

    From http://wiki.openwrt.org/BackupAndRestore#head-defee89a7e78ef2e853df32c8b8009edbfd8821b

  4. Lars - 7 July 2008 @ 09:04

    P.S. The above works for White Russian, but not Kamikaze

  5. Lars - 7 July 2008 @ 09:19

    For Kamikaze, the following should create a flashable image:


    dd if=/dev/mtdblock1 of=/tmp/backup20080704.trx

  6. Lars - 7 July 2008 @ 09:19

    And restoring under Kamikaze would be

    mtd -r write backup20080704.trx linux

Leave a Reply