Reply
New Member
Posts: 13
Registered: ‎07-18-2015
Kudos: 6

Everyone should read this: How to backup your EdgePro for the case of MMC / Filesystem Fails

Dear all, 

 

als U is not providing any recovery information, I will try to help a bit. There are serious issues with the partitioning that U is using. If the filesystem gets corrupt everything goes wilde and there is no official receovery method.

 

I revived multiple devices not using proper backups. So I encourage everyone to do a full backup of their MMC and store in in a safe and secure place.

 

Backup procedure:

1) Start necat listener and write data to file:

On your Linux us netcat to receive the backup over the network:

 

OSX:

nc -l 19200 |bzip2 -d|dd bs=16m of=full_backup_mmc.img

 

Linux:

nc -l -p 19200 |bzip2 -d|dd bs=16M of=full_backup_mmc.img

 

2) Login to your edgepro cli interface and become root usind "sudo bash"

 

3) Execute the following command to read the mmc and send it to the PC.

 

dd bs=16M if=/dev/mmcblk0 |bzip2 -c|nc YOUR-COMPUTERS-IPADDRESS-HERE 19200

 

This will take a long time, but will work. Now you will have a full copy of the MMC. Use SSH instead of netcat if you like.

 

DO THIS, now. You will not know when you need this image to recover your router.

New Member
Posts: 13
Registered: ‎07-18-2015
Kudos: 6

Re: Everyone should read this: How to backup your EdgePro for the case of MMC / Filesystem Fails

How to actually recover the system.

 

First of all there are multiple ways. If the bootloader still working and you can boot at least part of the linux system there is the followin easy way (Just outlining the process):

 

1) Connect a console cable to a linux computer an use a terminal application and set the baudrate to 115200

2) Power on your edgerouterpro and hit space immediately in your terminal application and you will  arrive at the bootloader prompt. 

3) Get the environment variables using printenv. Example output below:

 

printenv
autoload=n
baudrate=115200
boardname=ubnt_e200
bootcmd=fatload mmc 0 $(loadaddr) vmlinux.64;bootoctlinux $(loadaddr) numcores=2 endbootargs mem=0 root=/dev/mmcblk0p2 rootdelay=10 rw rootsqimg=squashfs.img rootsqwdir=w mtdparts=phys_mapped_flash:640k(boot0),640k(boot1),64k(eeprom)

 

4) Copy the command from the bootcmd paramter and att init=/bin/sh at the end and hit enter. Linux should hopefully load and you will be landing at a root prompt.

 

fatload mmc 0 0x20000000 vmlinux.64; bootoctlinux 0x20000000 numcores=2 endbootargs mem=0 root=/dev/mmcblk0p2 rootdelay=10 rw rootsqimg=squashfs.img rootsqwdir=w init=/bin/sh

 

5) Mount important filesystem parts for linux to work properly:

sh-4.2# mount -t proc proc /proc

sh-4.2# mount sysfs

 

6) Load the ethernet drivers:

sh-4.2# modprobe octeon-ethernet

 

7) Take a linux computer and connect the ethernet cable to it and configure it to have the ip 192.168.40.1 and connect the other end of the cable to the edge router pro (i did it on eth5)

 

8) Bring up your ethernet interfaces. The labeling on the router does not match up with the linux names, this bring up all of them until you see an output telling you that the port is up, then you know this is the one with the linux pc connected to it. example output (eth1 was the right one):

 

sh-4.2# ifconfig eth5 up
sh-4.2# ifconfig eth0 up
sh-4.2# ifconfig eth1 up
eth1: 1000 Mbps Full duplex, port 1

 

9) Configure the ip on eth1: ifconfig eth1 192.168.40.2 

 

10) Verify the connection from your pc using ping:

ping 192.168.40.2
PING 192.168.40.2 (192.168.40.2) 56(84) bytes of data.
64 bytes from 192.168.40.2: icmp_seq=1 ttl=64 time=0.093 ms
64 bytes from 192.168.40.2: icmp_seq=2 ttl=64 time=0.123 ms

 

11) Make a copy of the mmc now if you want and label it as "bad"

12) Restore the good backup using the following procedure, attention, this will overwrite your mmc. maybe first wan to test to send something to a file etc. You have been warned.

 

On edgerouter pro run the following command: 

nc -l -p 19200 |bzip2 -d|dd bs=16M of=/dev/mmcblk0

 

On the linux system run the following command (assuming the router has the ip 192.168.40.2):

dd bs=16M if=full_backup_mmc.img |bzip2 -c|nc 192.168.40.2 19200

 

This will take a loooong time, its about 3.7GB to transfer. The resulting output will be something like:

0+226112 records in

0+226112 records out

3959422976 bytes transferred in 3214.706405 secs (1231659 bytes/sec)

 

Reboot your device and it should be working again.

 

 

 

 

New Member
Posts: 13
Registered: ‎07-18-2015
Kudos: 6

Re: Everyone should read this: How to backup your EdgePro for the case of MMC / Filesystem Fails

In case linux is not loading but you can access your bootloader using the console there is another way to restore the image, but this is more complicated. I dont got the script done yet put the basic concept is.

 

First empty a usb stick completely by writing 0 on all sectors.

Copy the backup.img to your usb stick using DD .. dd if=backup.img out=/dev/yourstick

 

Insert the stick to the edgerouter and start the console and if your at the console prompt you can use the built-in command to "read from usb stick and copy to memory" and then "write from memory to MCC" . I dont got a edgerouter right now at hand, this i cannot post the details. I will document it, the next time i got access to one.

 

This is horrible and you can only copy something like a few megs per cycle as the memory is not so big on the edgerouter. But hey, in case of an emergency your are now in the position to at least know how to restore it from bootloader prompt only.

New Member
Posts: 13
Registered: ‎07-18-2015
Kudos: 6

Re: Everyone should read this: How to backup your EdgePro for the case of MMC / Filesystem Fails

And while we are on the topic. Got a corrupt flash lately as well. So if you want to recover your flash maybe later on then backup the following files as well on a working edgerouter pro.

 

dd if=/dev/mtdblock0 |bzip2 -c|nc YOURLISTENING_NC_LINUX 19200

dd if=/dev/mtdblock1 |bzip2 -c|nc YOURLISTENING_NC_LINUX 19200

dd if=/dev/mtdblock2 |bzip2 -c|nc YOURLISTENING_NC_LINUX 19200

 

Then you should have thre parts of the flash content of the edgerouter on your linux system. From the output of the working edgepro router we get the following flash structure:

 

cat /proc/mtd

dev:    size   erasesize  name

mtd0: 000a0000 00010000 "boot0"

mtd1: 000a0000 00010000 "boot1"

mtd2: 00010000 00010000 "eeprom"

 

so on the linux box you need to concatinate the individual files to one. 

 

dd if=backup_mtdblock0.img of=full_flash.img bs=1

dd if=backup_mtdblock1.img of=full_flash.img bs=1 seek=655360

dd if=backup_mtdblock2.img of=full_flash.img bs=1 seek=1310720

 

The file full_flash.img is now 1376256 (1.3Megs) in size.

 

This image can be most probably flashed onto the chip to revive it. I will try that by desoldering a chip from a broken device and reflash an image from a working device. 

 

 

Reply