NSLU2-Linux
view · edit · print · history

How do I completely backup my NSLU2?

There are several parts to this answer. First get root access as noted above for the stock Linksys or other places for Unslung or Openslug. Next you will need to backup all the partitions from the flash and the hard driver/flash stick. A recommendation is to backup the flash onto the hard drive/flash stick first, then when one backs up the hard drive/flash stick (HD/FS) you'll have both.

At the root prompt, type "dmesg" to get a printout of the console of the kernel messages during boot. Search in there for something like the following:

Searching for RedBoot partition table in IXP4XX-Flash0 at offset 0x7e0000
6 RedBoot partitions found on MTD device IXP4XX-Flash0
Creating 6 MTD partitions on "IXP4XX-Flash0":
0x00000000-0x00040000 : "RedBoot"
0x00040000-0x00060000 : "SysConf"
0x00600000-0x00160000 : "Kernel"
0x00160000-0x00180000 : "Ramdisk"
0x00180000-0x007e0000 : "Flashdisk"
0x007e0000-0x00800000 : "FIS directory"

This lets you know there are 6 partitions in the flash. N.B. BE VERY CAREFUL with the following commands. A mistyped or bad command can literally erase or hose up your entire system. USE AT YOUR OWN RISK.

Reader's comment: Note that the following does not work with a Slug formatted with OpenDebianSlug. Not sure what firmware this *does* work with, but it isn't OpenDebianSlug. Anybody got ideas where these partitions are created in ODS?

Other Reader's comment: The whole thing works perfectly well for me (OpenSlug 3.10).

First, MAKE SURE your current working directory is on the HD/FS. Then for each of the partitions do some similar to the following:

dd if=/dev/mtdblock0 of=redboot.bin
dd if=/dev/mtdblock1 of=sysconf.bin
dd if=/dev/mtdblock2 of=kernel.bin
dd if=/dev/mtdblock3 of=ramdisk.bin
dd if=/dev/mtdblock4 of=flashdisk.bin
dd if=/dev/mtdblock5 of=fisdir.bin

Issue "dd" commands all the way through to mtdblock5 or how many partitions one has. Note: Since we started at 0, the mtdblock number will be 1 less than the total number.

Note: the block number start with 0. This provides you with a binary copy of the contents of the individual paritions in flash. Next, you will need to properly shutdown and power off the NSLU2 to backup the contents of the HD/FS. This is most easily performed on another system. I'd recommend getting a copy of ubuntu or knoppix and running from the livecd if you don't have access to Linux/Unix system.

On that Linux/Unix system, one needs to plug in the NSLU2 hard drive/flash stick, I'd suggest mounting the partitions read only, and tar up the partitions and save off a copy of the MBR (master boot record -- this contains the partition table on the disk itself). With this data, a disk of equal or greater size can be restored to. Note: Restoring to a larger disk will mean the extra space is not utilised. When done shutdown properly and reattach the HD/FS to the NSLU2.

Finally, as long as RedBoot isn't toasted, you can reload and restore the flash partitions. If RedBoot is toasted, then you'd need to do hardware modifications to get JTAG access to restore RedBoot or another boot loader to the flash and then be able to restore everything.

Build a simple recover Image

To recover your System to a brand new NSLU2 it's simpler to build a full image. The full image is simply the aggregation of our generated Files. To put them together you can use the "cat" command on your slug. Pay attention to the order of your files, it must be the same order as shown by your dmesg call. For the above example the command would be:

cat redboot.bin sysconf.bin kernel.bin ramdisk.bin flashdisk.bin fisdir.bin > fullimage.bin

Recover

You can recover with upslug2 by providing the fullimage.bin by parameter -i. In this case the redboot and sysconf data is *NOT* restored. If you have modified redboot or sysconf on your old system, you need to call upslug2 with -C. You need a Complete-reprogram-enabled version of upslug2!

The fullimage.bin file is also usable with the Linksys-webgui!

unpack a new NSLU2
plug power and network
power on
open 192.168.1.77 in your browser
select Administration
login with "admin"-"admin"
select Advanced
select Upgrade
click browse at upgrade file
select your fullimage.bin
click start upgrade
wait for success message
plug your old disk or stick
you are done!

Edit: I can confirm that this woks well for a Debian/LE NSLU Edit2: I had to edit /etc/udev/rules.d/70-persistent-net.rules to match new device MAC address

Backup Flash on NSLU2 running openWrt Kamikazi 7.09 (as of Jan 3, 2009)

This works to produce a backup of the flash which can be reflashed onto another (or the same) NSLU2 (no external device on this slug):

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
(Note: I saw a suggestion that mtdblock4 should be made read-only before doing this, but the resulting image file was less than 8388608 megabytes--I didn't persue this.)

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--leaving it in produces an image which is too large.

Now how to get this file back on a Windows PC. There is probably a simpler way, but you can 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. This httpd.conf does not specify a password.

Then from the PC you can run 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(approve sites)";
$A = file_get_contents($Geturl);
$fh = fopen("nslu2c_image.bin", 'w') or die("Can't open file");
fwrite($fh,$A);
fclose($fh);
?>
(Windows users can also download gnu wget from http://users.ugent.be/~bpuype/wget/(approve sites) Slick and scriptable.)

This image can then successfully be flashed (using the Sercomm upgrade utility or upslug2) onto a new NSLU2. You can access this NSLU2, change the ip address, and voila, a cloned openWrt 7.09 slug.

view · edit · print · history · Last edited by daer.
Based on work by lbenson, Vasile, fcarolo, Klaus Ruebsam, Nikolaus Klepp, Mario Wolff, Jelle Alten, Hockeyrink, and Egor Zindy.
Originally by tman.
Page last modified on October 10, 2009, at 08:58 PM