Section One: Flashing a ROM from scratch (Clean Flash)

So you’ve decided to be a crack-flashin’ ROMmer! Good for you! You, of course, accept the risks and understand that YOU are responsible for your phone. Well, this humble little tutorial will help you to minimize data loss across a full wipe. Understanding this process - and DOING it - you will be back up and running on your new ROM within the hour.

This step-by-step tutorial was written for the unlocked and rooted Verizon Samsung Galaxy Nexus, but the basic concepts will not change for most Android devices. However: if you have a different device, check your device’s forum at www.androidforums.com for more specific ROMming instructions for YOU.

Read this entire tutorial - a couple of times, in fact - BEFORE plunging in! You will want to know what you’re about to do next, instead of trying to read as you go. That eats up precious time and battery. Okay, first things first:

We are in an exciting time for Android: Android 4.4 is out and the ROMs are starting to roll! HOWEVER, your poor phone will suffer if you fail to have the right 4.4-compatible recovery flashed. Currently, ONLY ClockworkMod Recovery is compatible with many 4.4 ROMs. Make sure you have the latest version of ClockworkMod recovery, 6.0.4.3.

NOTE: This is a major change in the procedure! Previous versions of this Guide promoted TWRP as the Recovery of choice. Make SURE you replace the TWRP Recovery with ClockworkMod Recovery BEFORE flashing 4.4 ROMs!

You also want to make sure that you have the latest Android BOOTLOADER on your phone. For the Galaxy Nexus (toro version), the latest is PRIMED04. Get it and flash it in Recovery before installing any 4.3 ROMs.

Once THAT’S done:

There is a PAID APP that you absolutely, positively WANT and NEED to have. The free version of Titanium Backup is nice: but the paid version (license key) is worth far more than the cost. Get it. If you’re going to flash ROMs, it is THE indispensable app to have.

What does it do? It allows you to back up all apps, all app data, all settings, all SMS/MMS messages, call log...EVERYTHING. With one button. It’s a batch operation and will save you HOURS over the free version, that only allows you to back up one thing at a time. Get it. I’ll wait.

*Chief hums to himself happily*

You back? Got Titanium Backup Paid? Good! Let’s rock a ROM!

Before I do a full wipe here's what I do (other than a nandroid backup - which is critically important!):


In Titanium Backup, back up all user apps AND system data. All of it. How to do that? There are three icons in the upper right corner: Search (magnifying glass), Batch (document with a checkmark), and the menu button. Hit BATCH. In the “Backup” section you will see an option early on that reads “Backup all user apps + system data”. That’s the one you want. Hit RUN by that one. The app automatically selects everything. Good. Press the green checkmark in the upper right corner and let it back up.

NOTE: You are backing up ALL setttings, because it’s faster than selecting specific elements to back up. You will NOT, under any circumstances, RESTORE all system data to a new ROM. NEVER. If you do that, do not be shocked, stunned or amazed when you have a lot of trouble with your new ROM - because you WILL!

Once the batch backup is complete (you can use the phone during this process), go to the menu button. Scroll down the options until you find “Create ‘update.zip’” and press it. Change it at the bottom to the “TitaniumBackupxxx.zip” and let it create the file. If the app gets an update, remember to create a new zip. What this zip will do in Recovery is place the app in your app drawer without your logging into Play. HANDY!

(Once you have that zip created, it is not necessary to keep doing it with every ROM. Just make sure you have that zip for the latest version of Titanium Backup and you’re fine.)

Make a homescreen backup of your Launcher (IF your launcher supports it).

Okay: there should be three zips in internal memory for you to flash, right? The ROM, Google Apps (or Gapps) and TitaniumBackup. If the ROM is not rooted, then you will want a fourth one: SuperSU by Chainfire. For Android 4.4 ROMs, use versions 1.69 or higher.

NOTE: Do NOT attempt to ROM your phone with less than 80% battery charge! Charge it up and THEN we’ll do this. There are few things more catastrophic than something going wrong in the process, you have to start over, and then have the battery DIE halfway into a flash. You will own an expensive paperweight that is a pain to recover from... IF you can recover from it at all.  Just charge the thing!

ANOTHER NOTE: It’s also a foregone conclusion that you have verified that your ROM & Gapps downloads are good. Few things cause more problems than a bad download. Check the MD5 checksums of both once they’re on your phone. Astro is a free file manager that can calculate MD5s. Root Explorer is a paid app and worth the price to many of us... it calculates MD5s too. Long-press the filename, select “properties” from the menu and it will calculate the MD5 for you. If the numbers match what the developer says the MD5 should be, it’s good. If your ROM doesn’t list an MD5, ASK! If the developer can’t or won’t give you one, ask other users. If your MD5 matches theirs, it’s a safe bet your ROM & Gapps are good.

Take a deep breath, and reboot into Recovery.


FIRST THING: BACKUP! Make a nandroid backup right now. If something goes wrong, you want to be able to restore the phone to THIS moment in time. Make sure you have adequate space in storage and backup the phone. When backup is complete:

There are four partitions you want to completely wipe: data (this is also called a factory reset: do NOT wipe internal memory under any circumstances! NO NO NO!), cache, Dalvik and system. Take a deep breath and wipe those four partitions. You can also use a zip program called Superwipe: it formats the four partitions for you. It will not wipe your SD card or internal memory.

Once wiped, your phone is absolutely a paperweight with no clue what to do with itself. Time to tell it what to do.

Flash the ROM, and then the appropriate Gapps. One after the other. If the ROM is not rooted, make sure you also flash a SuperSU zip to retain root. Once that is done, reboot system, PUT THE PHONE DOWN and check your pulse. This first boot will take a l-o-n-g time as the phone sets the ROM into the system partition and re-populates the Dalvik cache. If you think you’re in a bootloop, you’re likely not - I have seen initial boots take as long as TEN MINUTES! Be patient, but:

After 15 minutes: if you’re still at the Google icon or bootanimation, you’re likely looped. Pull the battery, wait 10 seconds, put it back in, go into Recovery manually (On the Nexus: BOTH volume buttons + Power all at the same time, then scroll down to Recovery using the volume down button and Power to select), wipe everything AGAIN and re-flash the ROM & Gapps. Good thing you have lots of BATTERY available, huh? *wink*

On the other side of the wipe, the first glimpse that everything went well is the Welcome screen asking you to select your language. YAYYY - You ROMmed it, baby!

NOTE: If something went wrong AGAIN? Wipe those four partitions again and restore your nandroid backup. You need another ROM. Check to make sure your ROM was designed for YOUR device, that the Gapps are the right ones, etc. Ask in the forums. Get sound advice. And charge your phone.

Okay, once you’re up and running:

DO NOT sign in to your Google account yet. Skip stuff. Hit “not now” or whatever and get to the homescreen as fast as possible. Then reboot back into recovery. Install the Titanium Backup zip you created. Reboot system again.

At the homescreen, open your app drawer, start Titanium Backup and go to Batch. Select "Restore missing apps and all system data". Tap "Let me choose myself" and de-select EVERYTHING. Do NOT restore all of one ROM’s system elements to another ROM! BAD BAD BAD!

You can select all your user apps - or at least the ones you still want. They will all be at the bottom of the list. And you can select, starting at the top of the list, the following system elements ONLY:

Accounts - this will restore your Google accounts

Call Log - this restores your entire call log

Clock (ALARMS) - again, IF you have any... if you don’t have any, don’t restore this

Messages (SMS & MMS) - this restores all your messages

And NO OTHERS.

Hit the checkmark to start the restore and go celebrate a successful ROMming with a cold glass of tea or something. When it’s done, reboot the phone so the information "takes" and you can then verify that your accounts are in place and syncing the right stuff. Sign into Play and un-check that STUPID “auto-add widgets” setting.

Big Important Note coming: READ IT!

BIG IMPORTANT NOTE: Now that Android 4.4 is out, you may have the opportunity to go from a 4.1 ROM to a 4.2 ROM. Because Android 4.2 changes the file structure in a few but critical ways, it is ABSOLUTELY VITAL that you do NOT restore ANY system elements from 4.1 to 4.2+. None! So yes, you will have to set your accounts, alarms and settings up all over again, and you WILL lose your call log and messages. You should be able to restore these elements from a 4.2 ROM to a 4.3 ROM, but never from an older 4.1 ROM to a 4.2+ ROM. Got it? :)

Here’s more information on it:

With Android 4.2, Google introduced multiple users as a new feature. In order to accommodate multiple users, Google is now giving each user a their own folder for storage. If you upgraded to 4.2 from 4.1, then the 4.2 ROM will look for a certain file in /data to determine whether it needs to migrate all of your files to the new multi-user data structure. By default, 4.2 migrates all of /data/media to /data/media/0.

A problem arose though with custom recoveries. A custom recovery retains the /data/media folder during a factory reset. When you factory reset and then boot a 4.2 ROM again, the 4.2 ROM will migrate everything in /data/media again. It will migrate your files every time you factory reset. This multiple migration is what resulted in some people having their files moved to /sdcard/0 or even /sdcard/0/0 etc.

In TWRP 2.3.2.0 we have corrected this problem by ensuring that we do not delete the special file during a factory reset. However, if ended up having your files upgraded you will need to move or merge them back into /sdcard. Also, if you have moved your TWRP folder from /data/media/0 to /data/media so that you could restore backups while using prior TWRP versions, you may now need to move the TWRP folder back into /data/media/0.

As a special note, if you restore a backup to a prior version of Android, you may have to move your files out of /data/media/0 and into /data/media to be able to see them again. Also, downgrading to 4.1 or below then installing 4.2 again may trigger another "upgrade" of your file system. It is not recommended to flip flop between 4.1 and 4.2 ROMs

Thanks TEAM WIN for the detailed explanation.

If you use a Launcher that backs them up, you may or may not have to restore your homescreens. You WILL have to restore your widgets.

Done!

Things you WILL have to re-do in the new ROM:

Sounds & ringtones

Display options

Security settings

Language & input (especially if you use a third party keyboard)

Any other ROM modifications you made will have to be redone.

You will also want to verify that your accounts sync the right things (if you have more than one account), and check that your alarms and alarm SOUNDS are restored correctly.

Hope this helps you. I think you’ll find that with experience, you will be able to flash a ROM and have everything up & restored in 30 to 45 minutes. THAT’S a good flash.

Good luck, ask any questions BEFORE you start, and happy flashing!

Section Two - Flashing a ROM update (Dirty Flash)

Once you are up on a ROM and running nicely, it’s usually not the end of your flashing. Developers very often actively work to improve their ROMs and keep them up to date. This is where the dirty flash comes in.

Unless you are updating a ROM from Android 4.1 to Android 4.2, you can often update the SAME ROM without wiping data at all. This is a great time saver for you!

Keep in mind that a dirty flash may not work ALL THE TIME. Changes in system structure and operating criteria may cause a dirty-flashed ROM to behave badly... in which case, you’ll have to wipe everything and clean flash it. SO it’s vitally important to be prepared for the worst.

Remember to make your backups: both in Titanium Backup and the nandroid backup in Recovery. ALWAYS nandroid backup! If things go wonky, you can wipe everything and restore it.

Download the ROM and check the MD5. Make sure you have your Gapps ready. Boot into Recovery and make your nandroid backup, then:

Wipe Cache, Dalvik and System partitions. Do NOT wipe DATA. Do NOT run Superwipe, because it will also wipe data.

Flash the ROM and Gapps, and then reboot system.

The first boot will still take a long time, because you wiped System & the Dalvik cache. Once the phone boots up, though, it should be like nothing ever happened. Your data, settings, homescreens, etc. should all be intact!

That’s the dirty flash. Remember, you cannot go from one ROM to another using this method; only incremental updates to the same ROM. But it’s a great time-saver...

...IF it works. If AOSP (Android Open Source Project, or the raw Android code) changed significantly in the update, then you might have to wipe everything and flash the ROM clean. Be ready for it, but try the dirty flash first.

Happy Flashing!

Legal stuff...

Since this Guide is updated from time to time here, it would be unwise to publish this or otherwise post it elsewhere on the Internet because that version may become obsolete very quickly. I’ve already found such re-distribution, and do NOT approve of it. Therefore:

This Guide is © 2013 G. L. Wilkie. All Rights Reserved. Do not publish or re-distribute without explicit permission of the author. Linking to this Guide is permissible... however, posting it is not.