• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root Android partitions, kernels explained

novox77

Leeeroy Jennnkinnns!
Jul 7, 2010
3,964
3,257
This is a rewrite/repost, condensed and updated with information that I think is useful to a lot of rooted users. Partitions and kernels aren't frequently discussed. Most of us know that they exist but don't really know how they work. Hopefully it all becomes clear after reading this :)

The phone's internal memory (not the SD card) is solid-state (flash) memory, AKA NAND. It can be partitioned much like a normal hard drive can be partitioned. The bootloader exists in its own partition. Recovery is another partition; radio, system, cache, etc are all partitions.

Here are the standard partitions on an Android phone:

/misc - not sure what this is for.
/boot - bootloader, kernel
/recovery - holds the recovery program (either clockworkmod or RA recovery for a rooted Evo)
/system - operating system goes here: Android, Sense, boot animation, Sprint crapware, busybox, etc
/cache - cached data from OS usage
/data - user applications, data, settings, etc.

The below partitions are not android-specific. They are tied to the hardware of the phone, but the kernel may have code allowing Android to interact with said hardware.

/radio - the phone's radio firmware, controls cellular, data, GPS, bluetooth.
/wimax - firmware for Sprint's flavor of 4G, WiMax.


During the rooting process, a critical piece of the process is disabling a security system built into the bootloader that protects these partitions from accidental (or intentional) modification. This is what's referred to as "unlocking NAND." The security system can be set to active or inactive. S-ON means the security is in place (NAND locked). S-OFF means the security is off (NAND unlocked). When S-OFF, you have the ability to modify all partitions. With S-ON, you only have write access to /cache and /data. Everything else is read-only.

When you flash a custom ROM, that ROM typically includes a kernel and an OS. That means the /boot and /system partitions will be modified at a minimum. Some ROMs require a clean install, so a format of the /data and /cache partitions is sometimes built into the .zip that you flash. This is essentially doing a factory reset. See next paragraph.

When you do a factory reset (AKA: wipe, hard reset, factory wipe, etc.), you are erasing the /data and /cache partitions. Note that a factory reset does NOT put your phone back to its factory state from an OS standpoint. If you've upgraded to froyo, you will stay on froyo, because the OS lives in /system, and that is not touched during a factory reset. So "factory data reset," as it says under Settings > SD & phone storage, causes confusion. It's not a factory reset. It's a factory DATA reset. Now you know the distinction.

The SD card can also be partitioned to include a section dedicated to storing user apps. To create the partition, your SD card needs to be formatted. Typically a user will copy all the contents in the SD card to a PC hard drive, wipe the card and partition it, and then copy everything back.


Onto kernels....

A kernel is a layer of code that allows the OS and applications to interface with your phone's hardware. The degree in which you can access your phone's hardware features depends on the quality of code in the kernel. The homebrew (rooting) community for HTC has made several kernel code improvements that give us additional features from our hardware that the stock kernel does not. When you flash a custom ROM, you automatically get a kernel. But you can also flash a standalone kernel ROM on top of the existing one, effectively overwriting it. These days, the difference in custom kernels is less about new features and more about alternate configurations. Choosing a custom kernel is basically choosing one that works best with your ROM.

Kernel developers are typically responsible for a small, specific feature in the kernel. For example, netarchy's contribution to custom kernels mainly revolve around removing the framerate restriction that was present in the stock HTC kernel. However, because of the open-source philosophy of all the devs, each kernel "distribution" contains the work of several devs. They openly share new code that they deem will benefit everyone. Basically the best features stay in, and the distributor of the kernel will give credit where credit's due. This means that for any custom kernel you try, you might be using netarchy's FPS fix. It's all a team effort. A new improvement will make it to most if not all of the various kernel distributions in a short amount of time.

For the Evo, the hot features of custom kernels are:

-- a fix to remove the 30fps cap imposed by HTC and improve touch tracking sensitivity (HTC finally fixed this in their stock kernel late last year)

-- disabling perflock to enable CPU throttling. Great for increasing the performance of your phone and/or improving battery life

-- iptables firewall to enable wifi-tethering via the wifi-tether app

-- 3 or 5 point multitouch support (not too many practical applications)

-- HAVS, a control system that dynamically adjusts the voltage based on CPU load. This has proven to be a battery saver, but it can actually have the opposite effect when multiple control systems are operating (like setCPU).

-- BFS kernel task scheduler as an alternative to the standard CFS

-- SBC (the ability to charge your battery beyond the default safe limit). The concept is similar to overclocking a processor: you're overriding the safety limits established to achieve additional performance. The benefit here is that you may gain more use of your battery per charge. The drawback is that you can damage the battery and significantly reduce its longevity. Some kernels claim they are using a safe technique to prevent battery damage. Just be aware of the potential risks.

Note about 4G and HDMI:
AOSP ROMs (ROMs based on pure Android without 3rd party manufacturer's code) are currently lacking robust 4G and HDMI support. This is because 4G and HDMI are hardware-specific features, not Android-specific, so there is no existing kernel code in the Android Open Source Project (AOSP) that is specific to 4G or HDMI support.

HTC is the manufacturer of the phone, so it has intimate knowledge of the hardware it uses in the phone; therefore the kernel that HTC has written does support HDMI and 4G. The problem is that the kernel is also tied in with their Sense UI that it's not possible to simply extract the portions of the code governing 4G and HDMI. Therefore, Sense-based ROMs support 4G because they simply borrow the existing HTC code. Meanwhile AOSP ROMs have to write their own code for 4G and HDMI in order to support it. Their ability to do this depends on how much info they can obtain about the hardware components in the phone and any drivers they may be able to find. Otherwise, it's really a task of reverse-engineering the hardware, which can be a thankless, time consuming task.


For a more in-depth read into how partitions work in Android/Linux, take a look here, courtesy of Akazabam:
http://androidforums.com/evo-4g-all...ore-information-about-android-partitions.html
 
this needs to kept at the top of this forum (if not already) at all times along with the other useful things we always refer back to. Thanks again

thanks for the vote of confidence :) To get this stickied, you'll need to PM a moderator and make the request. Otherwise they won't know of this thread's existence to see the post you just made.

BTW, akazabam is working on some more info to go along with this. so stay tuned.
 
Upvote 0
Wonderful post. Was very helpful, thanks :)

welcome to the forums. thanx for bringing this thread back from the dead. i really like this thread. novoxx is awesome.

here is another great read as well:http://androidforums.com/evo-4g-all...ore-information-about-android-partitions.html this is also from another guru who has been absent from this forum for awhile now. but akazabam was and still is the king around these parts in my eyes at least.

as bruce campbell said in army of darkness "hail to the king, baby"
 
Upvote 0
Absolutely correct about akazabam. I was lucky enough to be around for a while before he went absent. He truly was an android encyclopedia.

Maybe as a supplement to the rooting for dummies guide, someone should compile all of akazabams threads (which isn't very many amazingly) and link them in the guide. Just a thought.
Also if someone would do a search for posts by akazabam you could probably answer 99% of questions asked. Period. He knew everything!
 
Upvote 0
So, can I install a custom kernel without a custom rom? :thinking: (sgs+)

welcome to the forums!!!!!!!!!!!!!!
not sure how it is on your phone as this is an evo forum, but most roms will need a kernel to run it. so as soon as you flash a rom any previous kernel installed on your phone will get replaced by the kernel that comes with the rom. you will need to flash the custom kernel after flashing a rom.

i would link you to the right forum, but there are so many versions of your phone that i do not know which one. so i would go here: http://androidforums.com/ and find your phone. any other questions about your phone specifically please post it in the respective forum.
 
Upvote 0
Wow. I know this is exactly one year to the day after novox77 wrote the original post, but I wanted to comment on it anyway.

I have to say that your write up is spot on, as I have done my research on this subject, and I really like the level of information in it. I absolutely love the minute details of how things work, including Android of course, and you pack a lot of insight into your posts in such a way that the advanced user and the greenhorn can both benefit from them to a great extent.
 
Upvote 0
i know nothing about kernels. which ones should i use and how do i install them

here you go:
http://androidforums.com/evo-4g-all-things-root/389360-kernels-dummies.html

and also you will need to use setcpu as well:
http://androidforums.com/evo-4g-all-things-root/210253-setcpu-guide.html

what rom are you on? that will determine what kernels we could recommend. there are kernels for gingerbread sense and there are kernels for aosp roms. so it will depend on what you are on.

if you are on sense (gingerbread) then try the unversal freedom kernel.

if you are on aosp then try the tiamat sbc kernel.

as far as installing them, all you will need to do is wipe dalvik cache and cache and then flash the kernel.

edit:do not forget to make a nandroid backup before flashing the kernel.
 
Upvote 0
Very New here. Appreciate the tutorial. I was wondering if someone could write a step by step explanation of what happens in a typical android phone from Step 1 : Press power/on switch on phone. Step 2 : etc. till the screen comes alive. I'm trying to determine if my htc tmobile MT4G is totally dead or if it has corrupted start up files and just doesn't do anything. (dead screen also.). I'm thinking the only thing that will let me monitor whats going on inside would be some kind of SDK monitor or such. Excuse the long post. :)
 
Upvote 0
Very New here. Appreciate the tutorial. I was wondering if someone could write a step by step explanation of what happens in a typical android phone from Step 1 : Press power/on switch on phone. Step 2 : etc. till the screen comes alive. I'm trying to determine if my htc tmobile MT4G is totally dead or if it has corrupted start up files and just doesn't do anything. (dead screen also.). I'm thinking the only thing that will let me monitor whats going on inside would be some kind of SDK monitor or such. Excuse the long post. :)
welcome to the forums!!!!!!!!!!!!!!!!!
well when a phone boots up it will load temp files into both the dalvik cache and cache on your phones internal partitions. these are only temp files and sometimes can cause issues. that is why from time to time it can help to wipe dalvik cache and cache. not sure on the mt4g as this is the evo forums, but you might want to try and wipe the caches and see if that helps.

you also might want to post this in the http://androidforums.com/mytouch-4g-all-things-root/ as well.
 
  • Like
Reactions: auldman
Upvote 0
A friend of mine has just started getting into Android and he was wondering where HBOOT, itself, is stored amongst the partitions on the NAND chip. In the original post it says that the /boot partition has the bootloader and the kernel. He thought that HBOOT might reside there but I told him it could not be because you would be wiping that every time you flash a new ROM or chose "format boot" in recovery. The boot.img file that a Nandroid backup creates is derived from that partition as well.

Anyway, I did some digging around and it seems that HBOOT has a partition table stored in the /misc partition, however that may or may not be where it, itself, is stored. I was looking at the hexadecimal numbers of the HBOOT partition table it and it seems like HBOOT is perhaps stored in a hidden partition above the /misc partition starting at 0x00000000. Does anyone know if this is true? I am mostly asking for my friend's edification because he became concerned that formatting the /boot partition would obliterate his HBOOT, which I think is untrue. I, myself, am almost 100% sure that there is no easy way to format or clear HBOOT. So, if anyone knows the true location of HBOOT, I would love to hear from them
 
  • Like
Reactions: rameshprathap
Upvote 0
A friend of mine has just started getting into Android and he was wondering where HBOOT, itself, is stored amongst the partitions on the NAND chip. In the original post it says that the /boot partition has the bootloader and the kernel. He thought that HBOOT might reside there but I told him it could not be because you would be wiping that every time you flash a new ROM or chose "format boot" in recovery. The boot.img file that a Nandroid backup creates is derived from that partition as well.

Anyway, I did some digging around and it seems that HBOOT has a partition table stored in the /misc partition, however that may or may not be where it, itself, is stored. I was looking at the hexadecimal numbers of the HBOOT partition table it and it seems like HBOOT is perhaps stored in a hidden partition above the /misc partition starting at 0x00000000. Does anyone know if this is true? I am mostly asking for my friend's edification because he became concerned that formatting the /boot partition would obliterate his HBOOT, which I think is untrue. I, myself, am almost 100% sure that there is no easy way to format or clear HBOOT. So, if anyone knows the true location of HBOOT, I would love to hear from them

well i know that it is not in the misc partition. the new rooting methods requires that you update the misc partition so that you can downgrade the hboot. so i know it is not there.
 
  • Like
Reactions: LBPHeretic
Upvote 0
well i know that it is not in the misc partition. the new rooting methods requires that you update the misc partition so that you can downgrade the hboot. so i know it is not there.

I totally agree with you. I think that the /misc partition contains, among a few other things, the HBOOT partition table which is what sets the sizes for the various partitions on the NAND chip of the device. :)

I just wonder if there is a hidden /HBOOT partition above the /misc partition as I stated earlier. I am sure that someone has figured this out. I did an extensive amount of research into it last night and learned a lot, but it was not conclusive as to where the location of HBOOT is on the NAND chip. I hate not knowing how something works or where it is located. ;)
 
Upvote 0
When you flash a ROM it says you are modifying /boot and /system, but I don't think you need s-off to do this.
Flashing a ROM with a recovery, e.g. clockwork, work whether you have s=on or s=off, right?

During the rooting process, a critical piece of the process is disabling a security system built into the bootloader that protects these partitions from accidental (or intentional) modification. This is what's referred to as "unlocking NAND." The security system can be set to active or inactive. S-ON means the security is in place (NAND locked). S-OFF means the security is off (NAND unlocked). When S-OFF, you have the ability to modify all partitions. With S-ON, you only have write access to /cache and /data. Everything else is read-only.

When you flash a custom ROM, that ROM typically includes a kernel and an OS. That means the /boot and /system partitions will be modified at a minimum. Some ROMs require a clean install, so a format of the /data and /cache partitions is sometimes built into the .zip that you flash. This is essentially doing a factory reset. See next paragraph.
 
Upvote 0
With the new HTC DEV method to unlock your bootloader you do not need S-OFF to get a custom recovery on the device and flash ROMS & Kernels.

Before this, you needed S-off to get a custom recovery on the device in order to do anything. You can still flash ROMS & kernels with S-ON as long as you have a custom recovery on the device.


The S-OFF S-ON status signifies whether or not you can update things NOT signed by HTC in the bootloader.
 
  • Like
Reactions: ocnbrze
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones