Reply
Veteran Member
Posts: 5,460
Registered: ‎03-12-2011
Kudos: 2749
Solutions: 129

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

Check out https://github.com/SO3Group/emrk/blob/master/bin/emrk-reinstall

It's literally running that script, just be sure to adjust DEV/ROOT/BOOT with the device of your USB stick (check dmesg) or you might accidentally destroy the contents of your HDD.

In practice I run the commands in the script manually one-by-one rather than running the script.

New Member
Posts: 2
Registered: ‎07-07-2014

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

[ Edited ]

I'm able to connect to the ERL via console, statically assign an IP to the router and boot from a file on a TFTP server, but I'm running into an issue where after the

 

Welcome to EdgeMax Rescue Kit!

This tool is distributed under the terms of
GNU General Public License and other licenses

Brought to you by SO3 Group

WARNING: This tool is not developed, officially
supported or endorsed by Ubiquiti Networks!

Using it may lead to destroying your router
configuration or operating system

Ubiquiti Networks support will not help you
with using it or fixing consequences of
using it.

This tool itself is distributed without any
warranty and authors are not liable for
any damage it may cause

By using this tool you agree you are doing
it at your own risk and understand what
you are doing

*********************************************

Enter 'Yes' to proceed, 'No' to reboot
yes or no: yes

Do you want to configure the network via DHCP?
yes or no: no

Do you want to configure the network statically?
yes or no: yes

Enter IPv4 address in CIDR format (e.g. 192.0.2.10/24): 192.168.1.0/24
Enter IPv4 gateway address: 192.168.1.1
Enter DNS server address: 192.168.1.1

EMRK provides some scripts for automated
recovery procedures:

emrk-factory-reset -- reset config to factory default
emrk-remove-user-data -- remove all the user data including
    config and everything
emrk-reinstall -- reinstall EdgeOS from scratch
    (wipes any user data too)

Enter 'reboot' to reboot your router


BusyBox v1.17.1 (Debian 1:1.17.1-8) built-in shell (ash)
Enter 'help' for a list of built-in commands.

/bin/ash: can't access tty; job control turned off
EMRK>
EMRK>emrk-reinstall 
WARNING: This script will reinstall EdgeOS from scratch
If you have any usable data on your router storage,
it will be irrecoverably destroyed!
Do you want to continue?
yes or no: yes
Unmounting boot partition
Unmounting root partition
Re-creating partition table
Creating boot partition
Formatting boot partition
mkfs.vfat 3.0.9 (31 Jan 2010)
Creating root partition
Formatting root partition
Mounting boot parition
Mounting root partition
kjournald starting.  Commit interval 5 seconds
EXT3 FS on sda2, internal journal
EXT3-fs: mounted filesystem with writeback data mode.
Enter EdgeOS image url:

For the image url, I enter

ftp://192.168.1.200/ER-e100.v1.5.0.4677648.tar

 since it's the same FTP location as where I placed emrk-0.9c.bin

 

I get the error

curl: (7) couldn't connect to host
Could not download EdgeOS image, try again!

 Fair enough, I suppose ftp:// instead of tftp may make a difference, so I try 

tftp://192.168.1.200/ER-e100.v1.5.0.4677648.tar

 The error I get is now

curl: (7) getpeername() failed with errno 134: Transport endpoint is not connected
Could not download EdgeOS image, try again!

 

 

I'm sure that I'm messing something up with the 

Do you want to configure the network statically?
yes or no: yes

 part, but I'm not exactly sure what. Any help is appreciated.

 

 

[EDIT] Figured it out, had to enter 192.168.1.200 as the gateway and DNS server.

SuperUser
Posts: 9,552
Registered: ‎01-10-2012
Kudos: 6144
Solutions: 387

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)


@NVX wrote:
Sounds like the memory bug. You mention 3 months, that sounds like it's still in warranty?

 

Nope - not still in warranty. It sat on a shelf for 9 months :/    Dissapointing to say the least.  I can't get it to boot tonight and I don't feel like fishing out a fan to see if I can get it going again.  

 


@NVX wrote:

In the bootloader run "mtest", if it hangs or errors out then it's probably the memory bug. It should just count up indefinitely.


 

If I get it to boot again I may do  that.  Supposedly support checked the date and it's not in the range, but I know it's one of the earliest models that was out there.  Oh well...  I'll just keep an eye on the boards here or maybe look at the next model up - do any of them have fans?  


On one hand the one year warranty is a little dissapointing, on the other it was $99...

When you receive a solution to your question/issue, don't forget to mark your thread as solved and to give kudo's to the people who have helped you out!

Having wifi problems? Take a look here first: https://help.ubnt.com/hc/en-us/articles/221029967-UniFi-Debugging-Intermittent-Connectivity-Issues-on-your-UAP
Veteran Member
Posts: 5,460
Registered: ‎03-12-2011
Kudos: 2749
Solutions: 129

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

The ERL and ER-PoE are fanless. the two rackmount models ER8 and ER8-Pro both have fans.

Regular Member
Posts: 591
Registered: ‎09-10-2012
Kudos: 381
Solutions: 35

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

[ Edited ]

@safusu : The IP you entered 192.168.1.0/24 is not valid. This is a reserved address for the network. Try anything between 192.168.1.1 - 192.168.1.254 (including) that is not used by another host. Neither gateway nor DNS server were used while you attemted that download, so you could have entered anything there.

 

- DNS would have only been used if you had used a host name rather than an ip address, i.e. tftp://mybox.mydomain.tld/... Since you've used an IP address, no DNS server was queried for the download

- Gateway would have only been used if the host you were trying to download the image from was not in the same subnet like the router (i.e. if the host had an IP address outside of 192.168.1.1 - 192.168.1.254).

Regular Member
Posts: 747
Registered: ‎11-06-2013
Kudos: 231
Solutions: 26

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)


@EricE wrote:

@NVX wrote:
Sounds like the memory bug. You mention 3 months, that sounds like it's still in warranty?

 

Nope - not still in warranty. It sat on a shelf for 9 months :/    Dissapointing to say the least.  I can't get it to boot tonight and I don't feel like fishing out a fan to see if I can get it going again.  

 


@NVX wrote:

In the bootloader run "mtest", if it hangs or errors out then it's probably the memory bug. It should just count up indefinitely.


 

If I get it to boot again I may do  that.  Supposedly support checked the date and it's not in the range, but I know it's one of the earliest models that was out there.  Oh well...  I'll just keep an eye on the boards here or maybe look at the next model up - do any of them have fans?  


On one hand the one year warranty is a little dissapointing, on the other it was $99...


The warranty is 1 year from purchase. Not one year from the date code.

New Member
Posts: 31
Registered: ‎08-17-2014
Kudos: 6

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

Untitled.png

 So recently needed to reset my ERL due to it not accepting the default password after a reset. Followed the steps for a reinstall and after rebooting it fails to about here and hangs. Not sure where to go from here....If you need another screenshot I can provide it.

 

Highlighted
Established Member
Posts: 896
Registered: ‎03-20-2008
Kudos: 133
Solutions: 2

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

Here is a shell script I use to generate USB keys that you just have to insert into your edgerouter

#!/bin/bash

PARTED=$( which parted )

W_DIR=w
SERVER=[web server where you store firmwares]
KERNEL_ORIG=vmlinux.tmp
KERNEL_ORIG_MD5=vmlinux.tmp.md5
KERNEL=vmlinux.64
SQUASHFS_ORIG=squashfs.tmp
SQUASHFS_MD5_ORIG=squashfs.tmp.md5
SQUASHFS=squashfs.img
VERSION_ORIG=version.tmp

find_usb_key () {
        # step 1 : count usb devices
        nb=0
        disk=''
        for dev in $( ls -d /sys/block/sd* ) ; do
                if [ -h ${dev} ] ; then
                        usb=$( readlink ${dev} | grep 'usb' | wc -l )
                        if [ "${usb}" == "1" ] ; then
                                disk=${dev}
                                ((++nb))
                                if [ ${nb} -gt 1 ] ; then
                                        disk=''
                                fi
                        fi
                fi
        done
        echo "${disk}"
        if [ ${nb} -eq 1 ] ; then
                nb=0
        else
                if [ ${nb} -eq 0 ] ; then
                        nb=1
                fi
        fi
        return ${nb}
}

key=$( find_usb_key )
nbkeys=$?

if [ ${nbkeys} != 0 ] ; then
        # fatal error, none found or more than one...
        echo "FATAL: ${nbkeys} usb keys found... I only work with one"
        exit 1
fi

key=$( echo ${key} | sed -e "s/^\/sys\/block\(\/.*\)$/\/dev\1/" )

mounts=$( grep ${key} /proc/mounts | wc -l )

if [ ${mounts} -gt 0 ] ; then
        echo "Forcibly unmounting stuff"
        for dev in $( grep ${key} /proc/mounts | sed -e 's/^\([^\ ]*\)\ .*$/\1/' ) ; do
                echo "unmounting ${dev}"
                umount ${dev}
        done
fi


BOOT=${key}1
ROOT=${key}2
BOOT_MNT_DIR=/tmp${BOOT}
ROOT_MNT_DIR=/tmp${ROOT}

if ! [ "$1" == "--skip-part" ] ; then

        echo "re-creating the partition table"
        ${PARTED} --script ${key} mktable msdos

        echo "creating boot partition"
        ${PARTED} --script ${key} -- mkpart primary fat32 1 150MB
        echo "formatting boot partition"
        mkfs.vfat ${BOOT}

        echo "creating root partition"
        ${PARTED} --script ${key} -- mkpart primary ext3 150MB -1s
        echo "formatting root partition"
        echo "y" | mkfs.ext3 -v ${ROOT}

        mkdir -p ${BOOT_MNT_DIR} ${ROOT_MNT_DIR}

        echo "mounting boot partition"
        mount -t vfat ${BOOT} ${BOOT_MNT_DIR}
        echo "mounting root partition"
        mount -t ext3 ${ROOT} ${ROOT_MNT_DIR}
fi

TMP_DIR=${ROOT_MNT_DIR}/tmp
mkdir -p ${TMP_DIR}

echo "Downloading the tar file"
curl -o ${TMP_DIR}/edgeos.tar ${SERVER}/erl/latest

echo "Unpacking EdgeOS release image"
tar xf ${TMP_DIR}/edgeos.tar -C ${TMP_DIR}

echo "Verifying EdgeOS kernel"
if [ `md5sum ${TMP_DIR}/${KERNEL_ORIG} | awk -F ' ' '{print $1}'` != `cat ${TMP_DIR}/${KERNEL_ORIG_MD5}` ]; then
        echo "Kernel from your image is corrupted! Check your image and start over."
        exit 1
fi

echo "Copying EdgeOS kernel to boot partition"
cp ${TMP_DIR}/${KERNEL_ORIG} ${BOOT_MNT_DIR}/${KERNEL}
cp ${TMP_DIR}/${KERNEL_ORIG_MD5} ${BOOT_MNT_DIR}/${KERNEL_MD5}

# The image
echo "Verifying EdgeOS system image"
if [ `md5sum ${TMP_DIR}/${SQUASHFS_ORIG} | awk -F ' ' '{print $1}'` != `cat ${TMP_DIR}/${SQUASHFS_MD5_ORIG}` ]; then
        echo "System image from your image is corrupted! Check your image and start over."
        exit 1
fi

echo "Copying EdgeOS system image to root partition"
mv ${TMP_DIR}/${SQUASHFS_ORIG} ${ROOT_MNT_DIR}/${SQUASHFS}
mv ${TMP_DIR}/${SQUASHFS_MD5_ORIG} ${ROOT_MNT_DIR}/${SQUASHFS_MD5}

echo "Copying version file to the root partition"
mv ${TMP_DIR}/${VERSION_ORIG} ${ROOT_MNT_DIR}/${VERSION}

# Writable data dir
echo "Creating EdgeOS writable data directory"
mkdir ${ROOT_MNT_DIR}/${W_DIR}

## Cleanup
echo "Cleaning up"
rm -rf ${TMP_DIR}

echo "Installation finished"

echo "Unmounting partitions"
umount ${ROOT_MNT_DIR}
umount ${BOOT_MNT_DIR}

 

New Member
Posts: 31
Registered: ‎08-17-2014
Kudos: 6

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

Forgive my ignorance, but where would I insert that? The only terminal I can get to is the bootlader screen. I cannot get to a regular prompt.

Established Member
Posts: 896
Registered: ‎03-20-2008
Kudos: 133
Solutions: 2

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)


@jagtx459 wrote:

Forgive my ignorance, but where would I insert that? The only terminal I can get to is the bootlader screen. I cannot get to a regular prompt.


you'd use that on your linux pc to generate the usb key

then it's just a matter of installing the usb key inside the router

New Member
Posts: 31
Registered: ‎08-17-2014
Kudos: 6

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

[ Edited ]

As I am stting at my desk at work still pondering, I think I may have thought of the problem and will test to see if that fixes it tonight. I may have pulled the incorrect firmware URL when doing the reinstall. What clued me in was I was reading through the forum again and one poster mentioned using the recovery kit for the ER8 model. So hopefully that will fix the issue. If not I will try the USB script you provided above; thank you for that!

Previous Employee
Posts: 10,504
Registered: ‎06-09-2011
Kudos: 3142
Solutions: 945
Contributions: 16

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)


@jagtx459 wrote:

As I am stting at my desk at work still pondering, I think I may have thought of the problem and will test to see if that fixes it tonight. I may have pulled the incorrect firmware URL when doing the reinstall. What clued me in was I was reading through the forum again and one poster mentioned using the recovery kit for the ER8 model. So hopefully that will fix the issue. If not I will try the USB script you provided above; thank you for that!


This rescue kit will not work on the 8 port units.

EdgeMAX Router Software Development
New Member
Posts: 31
Registered: ‎08-17-2014
Kudos: 6

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)


@UBNT-stig wrote:

@jagtx459 wrote:

As I am stting at my desk at work still pondering, I think I may have thought of the problem and will test to see if that fixes it tonight. I may have pulled the incorrect firmware URL when doing the reinstall. What clued me in was I was reading through the forum again and one poster mentioned using the recovery kit for the ER8 model. So hopefully that will fix the issue. If not I will try the USB script you provided above; thank you for that!


This rescue kit will not work on the 8 port units.


Yes, I apologize for not explaining better. I have an ERL and may have inadvertantly downloaded the 8 port firmware on the last step of the reinstall which caused it to hang.

Veteran Member
Posts: 5,460
Registered: ‎03-12-2011
Kudos: 2749
Solutions: 129

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)


@jagtx459 wrote:

@UBNT-stig wrote:

@jagtx459 wrote:

As I am stting at my desk at work still pondering, I think I may have thought of the problem and will test to see if that fixes it tonight. I may have pulled the incorrect firmware URL when doing the reinstall. What clued me in was I was reading through the forum again and one poster mentioned using the recovery kit for the ER8 model. So hopefully that will fix the issue. If not I will try the USB script you provided above; thank you for that!


This rescue kit will not work on the 8 port units.


Yes, I apologize for not explaining better. I have an ERL and may have inadvertantly downloaded the 8 port firmware on the last step of the reinstall which caused it to hang.


That'd do it! You should be able to re-run the rescue kit as per normal to reflash the correct firmware though (you don't need to use the USB method which of course involves pulling the router apart - but it would still work, so use whatever method is easiest).

New Member
Posts: 31
Registered: ‎08-17-2014
Kudos: 6

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)


@NVX wrote:

@jagtx459 wrote:

@UBNT-stig wrote:

@jagtx459 wrote:

As I am stting at my desk at work still pondering, I think I may have thought of the problem and will test to see if that fixes it tonight. I may have pulled the incorrect firmware URL when doing the reinstall. What clued me in was I was reading through the forum again and one poster mentioned using the recovery kit for the ER8 model. So hopefully that will fix the issue. If not I will try the USB script you provided above; thank you for that!


This rescue kit will not work on the 8 port units.


Yes, I apologize for not explaining better. I have an ERL and may have inadvertantly downloaded the 8 port firmware on the last step of the reinstall which caused it to hang.


That'd do it! You should be able to re-run the rescue kit as per normal to reflash the correct firmware though (you don't need to use the USB method which of course involves pulling the router apart - but it would still work, so use whatever method is easiest).


Success! I guess just venting here helped find my dumb error.

Veteran Member
Posts: 5,460
Registered: ‎03-12-2011
Kudos: 2749
Solutions: 129

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)


@jagtx459 wrote:

@NVX wrote:

@jagtx459 wrote:

@UBNT-stig wrote:

@jagtx459 wrote:

As I am stting at my desk at work still pondering, I think I may have thought of the problem and will test to see if that fixes it tonight. I may have pulled the incorrect firmware URL when doing the reinstall. What clued me in was I was reading through the forum again and one poster mentioned using the recovery kit for the ER8 model. So hopefully that will fix the issue. If not I will try the USB script you provided above; thank you for that!


This rescue kit will not work on the 8 port units.


Yes, I apologize for not explaining better. I have an ERL and may have inadvertantly downloaded the 8 port firmware on the last step of the reinstall which caused it to hang.


That'd do it! You should be able to re-run the rescue kit as per normal to reflash the correct firmware though (you don't need to use the USB method which of course involves pulling the router apart - but it would still work, so use whatever method is easiest).


Success! I guess just venting here helped find my dumb error.


I'm familiar with the process. It always seems that explaining your problem to someone else makes you have a lightbulb moment. Man Very Happy

Member
Posts: 190
Registered: ‎03-21-2013
Kudos: 60
Solutions: 8

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

You sir, are a life saver. Thanks.

Worked brilliantly with the documentation you provided. Saved me from running to the store and buy a linksys. 

New Member
Posts: 18
Registered: ‎09-19-2013
Kudos: 5

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

pleasantly surprised, but greatly confused...

 

had a power outage at a client site; corrupted the file system. used emrk to get the thing booted, unmounted and e2fsck'd /dev/sda2 which seemed to work its magic, but there were coruptions to a couple key files that it could not overcome.  ok, no prob.   then did the emrk-reinstall over the system...

 

was sorta stressing that several of our customizations (we've got chillispot running on it, and a couple other tweaks) would be blasted out, so incidentally BEFORE I did the emrk-reinstall I was able to peruse /mnt/root and grab the various config and binary files that were surely already fully documented somewhere in our configuration management system, but just for grins I decided to keep an extra copy. (yeah, right)  tar'd them up, tftpd them off, and did the emrk-reinstall

 

cool beans.  worked as planned.  HOWEVER, after the reboot, the thing had kept all the files that we had added (thus no requirement to manually resinstall anything).  It just worked as desired after a "firmware refresh" -- I know it did the full untar and mv'd the new files over top of the old files... but the way I read that script, the mkfs.ext3 line should have blasted out what was there???  I'm not sure if the mkfs failed, but it wasn't trapped so it just kept going, writing over the already "good" (minus the few bad blocks that had been fsck'd??) file system.

 

Anyway, good stuff.  Saved me tons of time.  Not sure why I couldn't do future firmware upgrades like this (obviously there would be an increasing amount of crud from superseded and deprecated utilities, so it might not be the best way to ensure everything works right, but I was surprised that it appeared to work just fine).

 

Thanks!

 

 

New Member
Posts: 8
Registered: ‎09-23-2014
Kudos: 1

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

Thanks for this.

You just saved me from an unneccessary RMA.

 

New Member
Posts: 19
Registered: ‎07-03-2014
Kudos: 1

Re: EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)

Just an FYI for anyone doing this.....when it tells you to "reboot your router" at the end of the process DO NOT unplug the power cord as the solution to reboot.  If you do pull the power cable, you willl have to redo the entire process again. At that final step instead type "reboot" and press the Enter key.

 

It took me 5 tries to figure this out before I realized my mistake.

 

I just fixed two EdgeRouter Lite's as I selected the wrong firmware version from the website when upgrading from 1.0.2 -> 1.5.  Ensure you pick the correct model in the second drop down box after selecting "EdgeMax" in the first drop down box.

 

Reply