Topic: backup/restore kamikaze with custom setup?

Hi,
I'm having troubles to restore kamikaze image on my linksys wrt54gl.  I've followed procedure for backup/restore firmware, but it seems kamikaze has some new trick, which I should applied.  What I'm trying to do is to copy finished configuration from one router to the new one, which should be straight forward, and I've done it in the past (partially) with whiterussian version

I've done:
---------
cd /tmp
mount -o remount,ro /dev/mtdblock/4 /jffs
dd if=/dev/mtdblock/4 > /tmp/wrt-linux.trx
mount -o remount,rw /dev/mtdblock/4 /jffs

=> then copied image to laptop and try to flash router, but no luck,
=> tried to copy image to new router to /tmp and did
mount -o remount,ro /dev/mtdblock/4 /jffs
mtd -r write /tmp/wrt-linux.trx linux

but get following reply:
===========
Bad trx header
If this is a firmware in bin format, like some of the
original firmware files are, you need to convert it to trx.
Image check failed.
==================
=>image size is:
-rw-r--r--    1 root     root      2162688 Jan  1 07:34 wrt-linux.trx
=> df on old router shows
Filesystem           1k-blocks      Used Available Use% Mounted on
none                      7156      2504      4652  35% /tmp
/dev/mtdblock/4           2112      1936       176  92% /jffs
/jffs                     1152      1152         0 100% /

(it should have enough space if it fits on one router)
=>probably need to convert image to trx format??? but how
=>I didn't backup nvram, as Kamikazi uses uci, so I doubt it would make sense


any help, would be greatly appreciated

Noerr

Re: backup/restore kamikaze with custom setup?

Well found solution;)

i backed up partition 4 instead of 1, as it didn't make sense to me to have trx file of 3.6MB in size. so the solution is

cd /tmp
mount -o remount,ro /dev/mtdblock/4 /jffs
dd if=/dev/mtdblock/1 > /tmp/wrt-linux.trx
mount -o remount,rw /dev/mtdblock/4 /jffs

on new router
mount -o remount,ro /dev/mtdblock/4 /jffs
mtd -r write /tmp/wrt-linux.trx linux


Regards

Re: backup/restore kamikaze with custom setup?

In following this thread and the wiki article, http://wiki.openwrt.org/BackupAndRestore I have run this on Kamikazi 7.09 running on a NSLU2:

cd /tmp
mount -o remount,ro /dev/mtdblock/4 /jffs
dd if=/dev/mtdblock/1 > /tmp/wrt-linux.trx
mount -o remount,rw /dev/mtdblock/4 /jffs

But after the dd command I get this message: "dd: /dev/mtdblock/1: No such file or directory"

When I ls /dev, I see mdt1, etc. and mtdblock1, etc., but I am uncertain what the "mtdblock/1" is supposed to signify.  I am unfamiliar with any of these matters--what am I doing wrong?

If this process is completed successfully, would the wrt-linux.trx file be essentially a bin file, which I could flash in the normal way for the NSLU2?  If not, is there a way I could get such a file?

Re: backup/restore kamikaze with custom setup?

Why do you need to mount /dev/mtdblock/4 if you just want to dump /dev/mtdblock/1?

Mazi

Re: backup/restore kamikaze with custom setup?

The wiki says that the jffs should be mounted read-only in order to prevent corruption in the output file.  As I say, I don't know the relationship between the various mtdblock designations, and so can't do much except copy what I have read.  Any explanation of how they relate or of why my dd command might not have worked will be appreciated.  I have no external memory on this NSLU2, and am trying to produce an 8-megabyte image which I can flash into another NSLU2 in the standard manner.

Re: backup/restore kamikaze with custom setup?

I may be wrong; however, the explanation on Wiki only applies to any R/W Linux FS and not a R/O squashfs used on a Linux router.

Mazi

Re: backup/restore kamikaze with custom setup?

Ok, after advice from Rod Whitby on the NSLU2-linux forum, this works for me (I don't know if the mount r/o and remounts are needed--still awaiting feedback):

mount -o remount,ro /dev/mtdblock/4 /jffs
dd if=/dev/mtdblock0 > /tmp/NSLU2C_image.bin
dd if=/dev/mtdblock1 >> /tmp/NSLU2C_image.bin
dd if=/dev/mtdblock2 >> /tmp/NSLU2C_image.bin
dd if=/dev/mtdblock3 >> /tmp/NSLU2C_image.bin
dd if=/dev/mtdblock4 >> /tmp/NSLU2C_image.bin
dd if=/dev/mtdblock6 >> /tmp/NSLU2C_image.bin
mount -o remount,rw /dev/mtdblock/4 /jffs

This produces a file in tmp, NSLU2C_image.bin, which is 8388608 bytes long, the size of the image which is flashed into the NSLU2.  Note that the dds omit mtdblock5, which is a subset of mtdblock4.

Now how to get this file back on my Windows PC.  There is probably a simpler way, but I don't know it.  I made the file available over http by running this:

/usr/sbin/httpd -p 82 -h /tmp -c /etc/httpd.conf

which makes port 82 available with the home directory of /tmp.  My httpd.conf does not specify a password. 

Then from the PC I ran this PHP program (php must be available).

<?php // GetNSimg.php gets NSLU2 openWrt firmware image file
  $Geturl = "http://192.168.1.77:82/NSLU2C_image.bin";
  $A = file_get_contents($Geturl); 
  $fh = fopen("NSLU2C_image.bin", 'w') or die("Can't open file");
  fwrite($fh,$A);
  fclose($fh);
?>

I then successfully flashed this image (using the Sercomm upgrade utility) onto a new NSLU2 for which I had not been able to find the IP address.  I was able to access this NSLU2, change the ip address, and voila, a cloned openWrt 7.09 slug.