2014-09-06

r00tabaga: I F'ed it up! what now!

Lifted from the most excellent Ace Hackware forum:   https://acehackware.zendesk.com/entries/25149852-I-broke-my-r00tabaga-

I broke my r00tabaga :(


Taylor Banks
posted this on August 09, 2013 17:11
If your r00tabaga gets b0rked, here are a few common diagnostic steps you can take to identify and/or reset the device's behavior that may save you needing to rebuild.

Get in.

First and foremost: Try to get in, any way you can. Once you're in, you can re-set passwords, change IPs, enable and disable ethernet and wireless adapters, install and uninstall packages and even re-flash the device with a fresh OpenWRT build if you just want to start over from scratch.

If you can't communicate with your r00tabaga:

  • look for an AP you don't recognize with a BSSID that matches your router's MAC address
  • try to connect to it via ethernet and get an IP address from it via DHCP
  • otherwise, the default ethernet IP is possibly 172.16.42.1 (pineapple) or it's acting as a DHCP client (minipwner)
  • if you are unable to ssh to the device on 172.16.42.1, try telnet and ssh on 192.168.1.1 or assign the device an IP with a local DHCP server
  • if you still can't get in via SSH, you can try failsafe mode, which will allow you to re-flash the device:
    power on the device, wait almost 5s, push and hold reset button for almost 3s, release.
    the re00tabaga  should reboot and bring up ethernet port with 192.168.1.1, listening via telnet.
    > do you see "failsafe" in the motd when you first login?
  • If booted into failsafe mode, try to re-mount your root & extroot:
    mount your root flash filesystem to manually correct a file with
    mount_root then try 
    /etc/init.d/fstab whole_root_enable and reboot; 
    you may need to modify /etc/config/fstab
    once mounted, you'll likely want to modify /etc/config/network and/or /etc/config/wireless
  • otherwise, reboot out of failsafe mode with reboot -f
  • if SSHed in, you can try using activate minipwner or activate pineapple to reset to default configs on a stable build
  • if default configs have been modified or removed, you may need to rebuild (see below).
OpenWRT Resources:

Option 1 - Rebuild it from scratch.

To rebuild a r00tabaga:

Read all of the directions through at least once before proceeding so that you understand the process from start to finish. While it isn't complex, building r00tabagas manually does take a little patience and requires at least basic knowledge of a linux or OS X command line. We've automated the setup and configuration in our lab, but knowing how to rebuild your r00tabaga from scratch, by hand, may still come in handy when you least expect it. :)
  1. Try to login via telnet or ssh and do a firstboot && reboot. If you can do so, it's faster and easier than re-flashing, but should accomplish the same goal, which is a reset of configuration files to their default state.
  2. Once in firstboot, you can: 
  3. Re-flash the r00tabaga with attitude-adjustment. If you're using an MR11Uv2, you need the eko build.
    Download the firmware and host it for download on your local machine with netcat:
    nc -l < filename.bin 6666
  4. From your router, download the firmware from your local machine with netcat:
    cd /tmp
    nc 192.168.1.111 6666 > filename.bin
    mtd -r write filename.bin firmware
  5. Build as Pineapple using a pivot root
    (If you have a dd image from your original r00tabaga USB drive, you can skip copying the filesystem and go straight to the section entitled Re-image It below.)
  6. Copy firewall, network and wireless configs into /etc/config directory as *.p
  7. Copy MiniPwner files into /etc/config as *.m
  8. Install MiniPwner packages (from the list in step 20, but do NOT install to dest -usb since it's a pivot root)
  9. Download and install activate script to //usr/bin, adjust paths as necessary
  10. install any additional optional packages
  11. run activate minipwner && reboot

Option 2 - Re-image it.

If you want to start with a known-good image of the 8GB root filesystem used at build time, you can download it here and rebuild your r00tabaga by configuring the device to mount the USB filesystem as an extroot. This method is known to work with Sandisk Cruzer Fit 8GB sticks, and has not been tested or verified to work with any other devices.
  • Re-flash the r00tabaga with attitude-adjustment (make sure to use the correct version for your hardware! MR11Uv2 needs the eko build to flash from the web gui) or login to the device and run firstboot to get the router into a known fresh state
  • Download this dd image and write it to an 8GB Sandisk Cruzer Fit stick.
  • Power on the router
  • Enabled wireless so that we can get the wireless adapter's MAC address:
    cp /etc/config/wireless /etc/config/wireless.orig 2>/dev/null
    sed -e 's/option disabled 1/# option disabled 1/' </etc/config/wireless.orig >/etc/config/wireless 2>/dev/null
    reboot
  • Make backups of all of the files in /etc/config/ as well as /etc/opkg.conf
  • Determine the MAC address of your r00tabaga:
    ifconfig -a | awk '/wlan0/{print $5}'
  • Edit /etc/config/wireless as below, replacing the MAC address with your own and the ssid (ex: my-home-wifi), encryption mode (ex: psk2) and key (ex: 1234567890)  with values corresponding to a wireless network your r00tabaga can use to connect to the internet to complete its configuration:
    config wifi-device wlan0
       option type mac80211
       option channel 6
       option macaddr xx:xx:xx:xx:xx:xx
       option hwmode 11ng
       option htmode HT20
       list ht_capab SHORT-GI-20
       list ht_capab SHORT-GI-40
       list ht_capab RX-STBC1
       list ht_capab DSSS_CCK-40
       # REMOVE THIS LINE TO ENABLE WIFI:
       # option disabled 1
    config wifi-iface
       option device wlan0
       option network wan
       option mode sta
       option ssid {xxxx}
       option encryption {xxxx}
       option key {xxxx}
  • Add a WAN stanza to /etc/config/network that looks like this:
    config interface 'wan'
       option ifname 'wlan0'
       option proto 'dhcp'
  • Bounce the network to restart the wifi adapter:
    /etc/init.d/network restart
  • Confirm you've got internet access via wlan0:
    ifconfig
    ping 4.2.2.2
  • Insert the USB stick and confirm that the filesystems are visible. You should be able to see the contents of the USB stick mounted under /mnt/sda2
  • Edit /etc/opkg.conf and make sure the URL for the attitude adjustment repository is:
  • http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/
  • Install base packages and dependencies:
    opkg update
    opkg install block-mount kernel kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-usb-storage kmod-fs-ext4 kmod-scsi-generic
  • Create an /etc/config/fstab file that looks like this (assuming your USB filesystem is on sda2 wih swap on sda1):
    config global automount
       option from_fstab 1
       option anon_mount 1

    config global autoswap
       option from_fstab 1
       option anon_swap 0

    config mount
       option target /
       option device /dev/sda2
       option fstype ext4
       option options rw,sync
       option enabled_fsck 0
       option enabled 1

    config swap
       option device /dev/sda1
       option enabled 1
  • Reboot.
  • Now enable the pivot root:
    /etc/init.d/fstab whole_root_enable
  • Reboot again. 
  • Now update all of your wireless configs (/etc/config/wireless.*) to have the correct MAC address identified above.
  • Finally, update your wireless SSIDs to match your device MAC:
    export MAC=`ifconfig -a | awk -F: '/wlan0/{print $6$7}'`
    sed -i -e "s/option ssid.*/option ssid r00tabaga-${MAC}/" /etc/config/wireless.m
    sed -i -e "s/option ssid.*/option ssid r00tabaga-${MAC}/" /etc/config/wireless
    /usr/sbin/activate minipwner
  • ... and reboot one last time.
  • Et voila! One updated r00tabaga!
 Broke it beyond your ability to repair it?  Contact support@acehackware.com