Revert back to factory defaults after rooting and installing CM7 Rooting your Android and flashing CM7 seems pretty straightforward (SGS2 as an example).  I'm a complete notice and notice that you have to replace the recovery partition thingy in the process.  Lots of people say doing this invalidates the warranty, understandably.  This leads me on to wonder if it's irreversible.

Is there a way to completely un-root, put the stock ROM and recovery thingy back onto the handset - so that it is back in the exact same state when you opened the box?  Are there prerequisites to this, i.e. can I backup the recovery and the ROM before I start rooting, etc, and how?
The Galaxy S II doesn't have a locked bootloader, so DavidAP's (deleted) post doesn't really apply in this case.  It's also theoretically possible to exploit a flaw in a bootloader or something and re-lock it, though I don't know of such a method.  But anyways.

As noted here, it may be possible to fully back up a Samsung device through Odin, though we haven't been able to get it working.  Doing so would allow you to backup your stock ROM and restore it in perfect condition.  Via Odin you can also flash a stock firmware image, completely obliterating any trace of rooting.  This also might not be perfect, depending on where you get the firmware image &mdash; some of them are re-packed OTA updates and so on, and different from any "real" Odin package Samsung might use internally.

The problem is not with the real data on your phone, though; as noted it's easy to go back to stock and leave no trace of rooting.  There's a counter that gets incremented when you flash your phone with Odin.  It's possible to reset this counter, but that increments another counter.  Samsung does check this counter sometimes so you should flash with ClockworkMOD or Mobile Odin to avoid that.

If you brick your phone, that's certainly your fault and I wouldn't expect help from the carrier/manufacturer.  If you need them to fix a cracked screen or something I wouldn't expect them to care about any flashing you may have done, though who knows.  That said, I of course am not encouraging you to void your warranty; that's up to you.