[G2 Q&A, Help & Troubleshooting] Sunandroid:
Some basics - About bootloader, kernel, recovery, rom, /system and some other partitions.

There are many noobs out there and sometimes even I am one. Two days ago [MENTION=5113516]Closed Force[/MENTION] asked me, where I know my stuff from and why things are like they are... So I finally decided to write this little guide about how Android devices basically work and what are the special things about our G2.

If you find wrong facts or any other mistakes (grammatical, language, contentwise), please bear with me. That's how I read it in the forums. And of course not everything written on XDA is correct. So please tell me by PM, or by posting in this thread if you have additions, corrections or any other concerns about this OP.

Where I got to know all this stuff? Reading, reading, reading. I first started modding my old HTC desire like 4 years ago. Since then and even before I'm reading. Mainly here on XDA but also on some german forums and wikis. It might have taken me easily 200 hours or more. So the only way to learn for a newbie (and everyone else too) is reading.

Personally I own a D802 variant. I know about some things that were different in details for the US variants, but things should be right as they are.

Finally thanks to

[MENTION=6387591]d00lz[/MENTION] for some extra research/additions and a quick read through.

[MENTION=5644061]Art Vanderlay[/MENTION] for some additions.

So let's get started:

When you press the power button, your device will load the Bootloader. The Bootloader afterwards wil load either the Recovery Image (recovery.img), the Kernel (boot.img) or the Download Mode Bootloader (laf.img), depending on the keys you press. At the moment there are three different bootloaders; The Jellybean one, the KitKat one, and the new Lollipop one. Not one of these Bootloaders can be unlocked yet, so there are workarounds which allow us to boot custom ROMs (specifically Kernels, but more about that later) and custom Recoverys. At the beginning there was the Jellybean Bootloader. The Developers (sorry, I don't know which ones) found out how to get around the locked Bootloader pretty early. They called this workaround Loki. It's intergrated into nearly every ROM except the ones which require the KitKat Bootloader (but that's usually not the reason they don't support the JellyBean one). Anyways, soon the KitKat update came and so did the new KitKat Bootloader. Sadly, LG patched the Loki exploit with this new update. However, the Developers found a new way to get the Bootloader booting files which weren't signed by LG. They called this workaround Bump. Bump basically imitates the LG signature so the bootloader thinks this file was really signed by LG. Obviously this workaround works with the JellyBean Bootloader too. In the Lollipop Bootloader this exploit has been closed and no one knows how to get around the new Bootloader, yet. In conclusion to Bootloaders, as long you have a working Bootloader, your device is not dead. You can usually recover it in some way.

The G2 has about 30 partitions (for a more detailed explanation, look here, thanks [MENTION=6387591]d00lz[/MENTION]). Each partition has its own purpose. One of them is the Recovery partition. Imagine: A Recovery partiton and a working Bootloader are everything you need to keep your phone working. It's kind of an Operating System in itself, completely independent from Android or anything else stored on your Mobile. The great thing about the Recovery partition is that it's so small that it can be run directly in the RAM. This means it's capable of modifing EVERY goddamn partition on your Mobile, including the Bootloader and the Recovery partition itself (means you can flash a new recovery.zip in your current recovery). Attention: if you are using the Recovery with a 4.4 KitKat Bootloader, it needs to be a Bumped Recovery. If it isn't bumped the Bootloader realizes that the Recovery is not genuine and generates a "Secure Boot Error".

Same thing goes for the Kernel. The Kernel is located in your /boot partition (found gzipped inside your boot.img) and is loaded by the Bootloader when you only press the Power Button and you let your Mobile boot normally. This is the reason why your Kernel also needs to be Bumped if you want to get your system booting on a KitKat Bootloader. When 4.4 KitKat came out, most Developers switched over to using LG's 4.4 KitKat sources for their projects. After a while it was realized that 4.2 JellyBean sources were a lot more reliable for AOSP baed ROMs. This is why most AOSP ROMs use the 4.2 JellyBean Bootloader and the 4.2 JellyBean Kernel sources while Stock based ROMs use the 4.4 KiKat Bootloader and 4.4 KitKat Kernel. There are different Kernels for AOSP ROMs and for Stock based ROMs. This is because Stock Kernels support some ROM functionalities that AOSP ROMs don't have, for example; Knock Code. (Note: Knock Code isn't open source, which is also another big reason why it isn't available for AOSP ROMs.) So there are huge differences between Stock and AOSP based ROMs/Kernels. The Kernel (without factoring in the AOSP and Stock issue) can be switch at anytime you want.

Now about the /data partition... All your personal stuff, including Apps, System Settings, App Data and so on will be stored there. The reason why you should clear it every time you change the ROM is that there are many variables set by the ROM you are coming from. Your current ROM may have some tweaks the new one doesn't have which means the new ROM doesn't know how to handle them which leads to crashes and instability.

Now let's get to the ROM... Having a 4.2 JellyBean Bootloader and a 4.2 JellyBean Kernel doesn't mean the top layer has to be 4.2 too. Most of the AOSP based ROMs are based on Googles KitKat or Lollipop sources. And this is true KitKat or Lollipop, with all its functionalities. Those huge version differences cause some problems in development. No wonder some things do not work properly today, but it's still the best working combination at the moment. It's kind of a wonder how it works as it is, but let's be happy with it. I'm very curious how AOSP ROMs with Lollipop Kernel sources will work. Your ROM and your entire existing Operating System is found in the /system partition. This is why it's the main partition which is modified while flashing. Which partitions will be modified and (how) is written in the updater-script file of the file you're going to flash. Theoretically, running a updater-script of a ROM which changes the Bootloader (/aboot partition) can brick your device. That's also the reason why you should only flash stuff made for your device only!

As already said an updaterscript can modify every partition through the recovery. All ROMs bring their own kernel, so you basically don't have to care about it, except you want to use a non-bumped ROM (with kernel) together with the KitKat bootloader.

Finally something about the baseband/modem (these terms are interchangeable). I noticed that the Developers or rather the Original Posters sometimes don't know which baseband the user should use with the ROM. In earlier days the wrong baseband could make the ROM bootloop. Today most ROMs work with most basebands. It's obviously best if you stay on the one you currently are on and just flash another one if something doesn't work (auto-rotation for example). The baseband can be flashed at any time and is on it's own partition.

Okay Download Mode time. It's part of the laf partition (laf.img). This partition is used by LG and it's PC software to recover the phone and bring it back to Stock. It's a partition in itself, but not completely independent of the Bootloader. It's because of this that you can of course have a fully working Bootloader, but a dead Download Mode. This means you will not be able to flash a .KDZ/.TOT file the next time you are in big trouble! ^^

Okay to wrap up I should mention the EFS partition. The EFS partition stores your device's IMEI (and the serial number as far as I know) of your device. NEVER wipe it. With a empty EFS partition you can use your mobile as a brick, ok maybe you can use it as a media tablet, but that's it (WiFi still works, [MENTION=5644061]Art Vanderlay[/MENTION] tested; see below).

Again: if you got questions/additions/correction or see a mistake, post below, or PM me, I'll edit this post...