9

I'm used to wiping everything when installing a new ROM, but I would like to know if a nandroid restore automatically wipes out the partitions it is recovering.

When I run a restore, I see some messages saying it is "formatting cache" and "erasing boot before restore", but the rest of my partitions (system, data, .android_secure, etc) don't have any accompanying messages about them being cleared first.

Does a nandroid restore overwrite partitions, or does it merge the files with the current structure?

And in the interest of making this applicable to a wider audience, is the process different for different phones (some have extra partitions) or different versions of clockworkmod? Or is the process the same for everyone?

3 Answers 3

4

I tested this, and your concern is valid.

I added a dummy file to /system and then did a nandroid restore. The dummy file survived. Repeated the same test on /data with same result. So I don't know why CWM doesn't wipe those partitions first.

The CWM author probably made an assumption it doesn't matter or there may be a valid reason they don't get wiped.

1
2

For certain devices, such as the Nexus 7, that is not possible because the stock ROM unifies /data and what would normally be used as an SD card with FUSE mounts. If the restore program erased the /data partition, it would wipe out the backup because it's stored within /data. For example, with TWRP it'd be at /data/media/0/TWRP/BACKUPS/(deviceSerial)/ in a subdirectory of one's choosing, but by default is composed of YYYY-MM-DD-HH-MM-SS (buildID) when the backup was started, for example "2013-12-28-14-12-18 KOT49H".

What I think TWRP will attempt to do on a restore is to recursively unlink(2)/rmdir(2) everything EXCEPT the TWRP directory tree. When I did a restore, it printed a message about wiping /data.

It very well could depend on which recovery you use too. TWRP might have a different way than CWM, which may be different from COT and so on. It might also depend on whether the device has an SD card slot or not (a Nexus 7 does not).

1

Usually a NAND restore will overwrite the partitions it restores completely. Everything currently on the partition will be overwritten, and the exact same state from the backup will be restored. So wiping before restoring is not really necessary, as it will be completely overwritten anyway.

Instead it is usually recommended to wipe cache partitions (including dalvik cache) after the NAND backup is restored to make sure that the restored state can be recovered correctly (and is not affected by cache issues).

2
  • 1
    Your answer is what I had originally thought. However, could you provide a link or resource that shows this answer to be accurate? The overall purpose of the question is so that I could know definitively what happens (or is supposed to happen), and not just what I think should happen.
    – Stephen S
    May 13, 2013 at 20:00
  • 2
    Unfortunately no, I don’t have any source to back this answer up. The only thing would be experience, as restoring a backup never leaves anything that has happened since the backup was created (which is its purpose; to restore exactly to the point when the backup was made).
    – poke
    May 13, 2013 at 20:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .