Quantcast
Viewing all articles
Browse latest Browse all 60861

Re: What are the recovery options on a EdgeRouter X?


talz wrote:

I finally got some time to try recovering my ER-X again, and got it unbricked. This is what I did:

 

Downloaded and built openwrt on my Fedora (linux) PC:

 

$ git clone https://git.openwrt.org/openwrt.git
$ cd openwrt
$ ./scripts/feeds update -a
$ ./scripts/feeds install -a
$ sudo dnf install zlib-static
$ make menuconfig

Target System: Ralink RT288x/RT3xxx
Subtarget: MT7621 based boards
Target Profile: Ubiquiti EdgeRouter X
Target Images
Select RAMdisk
Save and Exit

$ make

 

This took a while to compile everything, and gave me:

 

bin/ramips/openwrt-ramips-mt7621-ubnt-erx-initramfs-kernel.bin

I then copied this file to a TFTP server (I used tftp-server on my Fedora - you could probably use something like tftpd64 on Windows).

 

On the ER-X, I had it taken apart, and hooked up to its serial port (see a few pages back for how to do this). I then booted the device and used option 1 on the uboot bootloader to boot from TFTP.

 

I gave it an IP on my LAN, told it the IP of my TFTP server, told it the filename of the openwrt .bin file above, and it booted openwrt it without a problem.

 

I then mounted the ubiquiti partition with:

 

$ sudo mount -t ubifs /dev/ubi0_0 /mnt

At that point, I backed up everything on the partition using SCP, and deleted everything on it.

 

I then used my Fedora machine to download the same ER-X firmware file that I had installed on the device before I bricked it, extracted the contents of the archive, and renamed the following files:

 

 

squashfs.tmp --> squashfs.img
squashfs.tmp.md5 --> squashfs.img.md5
version.tmp --> version

I then used SCP to copy the 3 files to the ubiquiti device, and put them in /mnt (the partition I had mounted).

I rebooted the device and it booted normally without a problem.

I then got the latest firmware image, upgraded it, and it worked great after that as well.

 

Note: The files I restored did NOT include the actual kernel (vmlinux). I'm not entirely sure how to mount the partition that stores the kernel using openwrt (if it can be mounted at all - maybe it just gets written to some specific address on the disk with dd?). If anyone knows how to get to the kernel partition, please let us know.


, Thanks for the writeup. I was out of state and didn't have a chance to reply yet.

 

Those were the essentially the same steps that I had taken. You were more fortunate than I as my UBI partition was corrupted and totally unmountable. UBI should autorecover with the journal from what I've read but perhaps there is an underlying issue with the flash driver with regards to ECC.

 

I had to first recreate the partition and volume using the commands below before then mounting and restoring the squashfs image. I also used the 'sync' mount option for extra piece of mind by bypassing the write cache and ensuring that the files made their way to the volume.

# /dev/mtd5 = 'ubi' when running OpenWrt / LEDE
ubiformat /dev/mtd5 ubiattach -p /dev/mtd5 ubimkvol /dev/ubi0 --vol_id=0 --lebs=1925 --name=troot mount -o sync -t ubifs ubi0:troot /mnt/
cp /tmp/version.tmp /mnt/version
cp /tmp/squashfs.tmp /mnt/squashfs.img
cp /tmp/squashfs.tmp.md5 /mnt/squashfs.img.md5

Since I decided to use the older 1.8.5 release for recovery I also had to replace the kernel image. I wasn't positive on the usage of the 'kernel2' partition so I ended up flashing both partitions with the kernel from 1.8.5 with the commands below.

# /dev/mtdblock3 = 'kernel1' when running OpenWrt / LEDE
# /dev/mtdblock4 = 'kernel2' when running OpenWrt / LEDE
dd if=/tmp/vmlinux.tmp of=/dev/mtdblock3 dd if=/tmp/vmlinux.tmp of=/dev/mtdblock4

After rebooting and seeing the Ubiquiti shell I then continued testing with the following procedures:

*) Reset to factory default.

*) Installed 1.8.0 system image and rebooted.

*) Switched default system image to 1.8.5 and rebooted.

*) Installed 1.9 system image and rebooted.

 

Thus far everything seems to be operating as it should. I'll continue to monitor it through releases to see if any of my recovery steps introduce any unintended side efffects.


Viewing all articles
Browse latest Browse all 60861

Trending Articles