Posts: 211
Registered: ‎05-21-2013
Kudos: 264
Solutions: 8
Contributions: 3
EdgeMax rescue kit (now you can reinstall EdgeOS from scratch)
[ Edited ]

EDIT by UBNT-stig:  NOTE this rescue kit will only works on ER-Lite and ER-PoE.


This forum topic is the home of the EdgeMax Rescue Kit—a network bootable rescue image for EdgeOS-based routers.


Basically, it's a minimal Linux kernel with recovery tools embedded in initramfs. You connect to your router via serial, boot it via TFTP and get into a minimal rescue system.


The following scripts for automated recovery procedures are included:

  1. emrk-factory-reset — removes the config.boot, optionally making a backup copy inside the config dir so you can access it easily after reboot.
  2. emrk-remove-user-data — removes any data from writable dirs, getting the system back to clean EdgeOS (all config data, user installed packages on so on are removed). It also removes copies of user data left after resets, as pressing reset button doesn't really remove the data but renames the old writable dir to some random name and creates a new one. Useful if you are going to give away your ERL to an untrusted third party.
  3. emrk-reinstall — downloads release tarball from URL and reinstalls EdgeOS from scratch .

NOTE: emrk-remove-user-data and emrk-reinstall are highly disruprive! The former will remove everything but the stock EdgeOS image. The latter will remove and re-create all the partitions, so all your data, if you still have any, will be lost irrecoverably. Use it only if there is no hope to recover your installation in a less disruptive way.


I did my best to get it to work, but I can't guarantee there are no bugs, so use at your own risk.


How to use

Download the latest version of the EMRK image from (or use mirror director link:

Install a TFTP server. On UNIX systems some TFTP implementation is always available from ports/repos, Windows users may use this one:

Copy the image to your TFTP server directory.


It's better to set up a DHCP server. If you are using ISC DHCPD, use these options in your subnet declaration:

option tftp-server-name "x.x.x.x"; # Your TFTP server address
next-server x.x.x.x; # Your TFTP server address
option bootfile-name "emrk-0.9c.bin";
filename "emrk-0.9c.bin

Connect to your router via serial. Power on or reboot the router and, before EdgeOS kernel loads, press any key (I usually keep pressing some key repeatedly from the start). This will get you to the bootloader console where you can boot your router manually.


Connect router eth0 interface to your network.


If you use a DHCP server, issue the following command in U-Boot CLI:

dhcp;tftpboot;bootoctlinux $loadaddr

 If you don't have a DHCP server, you may configure network manually:

set ipaddr x.x.x.x (where x.x.x.x is desired router IP address)

set netmask (or whatever mask you want)

set serverip y.y.y.y (where y.y.y.y is your TFTP server address)

set bootfile <EMRK image file name>

set gatewayip z.z.z.z (where z.z.z.z is your default gateway)

bootoctlinux $loadaddr


If everything goes right, after bootoctlinux command you will see the kernel booting and will be asked if you want to continue after a scary disclaimer. Answer "yes" (case insensitive) or "no".

Next you will be asked if you want to use DHCP or configure the network interface statically.


To reinstall EdgeOS from scratch, you will need to download the tarball and put it on your HTTP/FTP/SSH server.


Here is an example reinstall log (kernel boot messages omitted).

Loading EMRK 0.9a
Mounting filesystems
Bringing up eth0

Checking boot partition
Boot partition looks intact
Attempting to mount boot partition
Boot partition successfully mounted
Looking for kernel file
Found a kernel
Checking kernel MD5 sum file
Found kernel MD5 sum file
Checking kernel MD5 sum
Kernel MD5 sum is correct

Checking root partition
Root partition looks intact
Attempting to mount root partition
kjournald starting.  Commit interval 5 seconds
EXT3 FS on sda2, internal journal
EXT3-fs: mounted filesystem with writeback data mode.
Root partition successfully mounted
Looking for system image file
Found a system image file
Checking system image MD5 sum file
Found system image MD5 sum file
Checking system image MD5 sum
System image MD5 sum is correct

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 network via DHCP?
yes or no: yes
udhcpc (v1.17.1) started
Sending discover...
Sending select for
Lease of obtained, lease time 86400
/usr/share/udhcpc/default.script: Resetting default routes
route: SIOCDELRT: No such process
/usr/share/udhcpc/default.script: Adding DNS

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
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:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 68.3M  100 68.3M    0     0  8319k      0  0:00:08  0:00:08 --:--:-- 6318k
Unpacking EdgeOS release image
Verifying EdgeOS kernel
Copying EdgeOS kernel to boot partition
Verifying EdgeOS system image
Copying EdgeOS system image to root partition
Creating EdgeOS writable data directory
Cleaning up
Installation finished
Please reboot your router

If you want to do things manually, there are busybox with symlinks to its applets (cat/grep/rm/cp/mv/tar/etc., ping, traceroute, nc etc.), curl, parted, and mkfs.ext3/mkfs.vfat.


I used it on my on ERL when I replaced the USB stick with a 8GB one yesterday. Hope you find it useful, any bug reports or suggestions are welcome.


Here are the scripts it uses:

Who Me Too'd this topic