[Samsung Galaxy S Blaze 4G] dispozable:
Newbie NAPS

Newbie’s Noobguide to Android Partitions and Schematics

[A work in progress]​

I’ve been there... You want to mess around with rooting your phone, or even getting that sweet CyanogenMod everyone’s been talking about. But let’s face it. You don’t know diddlysquat. And the little bit that you do know is just confusing, and those random half-answers on forums are just no help. Why isn’t there an “Android Hacking 101” out there? Well, here it is.

So should I read this guide?

This guide is actually not a guide. It’s meant to explain how the foundations of an Android device work in order to understand what you’re doing when you’re modding an Android phone. It will also help you figure what’s wrong when something goes bad, because you’ll know what you’re actually doing.

This guide is not a step-by-step guide. This guide is meant to educate on the basics of how the software within Android devices work. It covers the different partitions, the software/files within these partitions and their objectives.

Foreword about Android and Linux​

It is important to note that Android is based on Linux. Linux is open source, and so Google took the source code and used it as a basis for Android, which is open sourced as well. Linux is a Unix-like operating system, while Android can be considered Linux-like (and Unix-like). The Unix-like family of operating systems (sometimes known as *nix operating systems) is very large, and they all share much of this schema of how the foundations of the system work. Mac OSX is a BSD variant (also *nix) and iOS is derived from Mac OSX, and therefore is also very similar in many aspects to this schema.

Table of contents

1.	The awesome flowchart

2.	Basic terminology and definitions

3.	The partitions

-------a.	Download Mode (specific to Samsung)

-------b.	Recovery

-------c.	Kernel (sometimes known as Boot)

-------d.	/system

--------------i. What is actually in this partition?

1.	Drivers

2.	User Interface framework

3.	System apps (and bloatware)

4.	Media

--------------ii.	Manufacturer skins

-------e.	/data

--------------i.	What is actually in this partition?

1.	Apps

2.	App data

--------------ii.	Factory reset

-------f.	/cache

-------i.	What is actually in this partition?

1.	Thumbnails

2.	Cached apps

--------------ii.	Why wipe cache

-------g.	/mnt (SD card and mass storage)

4.	Apps, root permissions and SU

-------a.	The root folder

-------b.	System apps vs. data apps

-------c.	Root permissions

-------d.	Why get root

-------e.	Fix permissions

5.	Custom operating systems (custom ROMs) and Recovery

-------a.	Custom ROMs

-------b.	Recovery

-------c.	Nandroid

-------d.	Simplified installation process for (custom) operating systems

6.	ROM manager

7.	Bricked devices

8.	Why not use task killers

-------a.	How memory and storage works

-------b.	Memory management

-------c.	The task killer

-------d.	True multitasking

9.	Ending notes

10.	License

Still missing:

●	Bootloader

●	Baseband (Radio)

●	Troubleshooter

●	Battery stats / “Battery memory”

----------------------------------------------------------------------------------------------------------------------------------------------​

​

Basic terminology and definitions​

This section is for reference and will probably only confuse you if you don’t read the terms in some sort of context. So go read the guide and if you run into a term you’re not familiar with, come back here and see if it’s explained here.

Partition - A section of a storage drive (such as a hard drive or sd card) that is divided so that it functions as an entirely separate storage drive. This is usually used in order to differentiate parts of a drive as if they are physically separate. For the sake of software, there is usually no difference between a hard drive and a partition.

Format/wipe - To completely erase all data on a partition (or drive) and reset the file system (which is the mechanism with which files are stored to and read from a partition).

Image - One file which usually contains an entire partition (or drive). It is called an image because it is as if one would simply take a picture of the partition as it is in its entirety and saved it as an image. Usually done for making backups.

Flashing - Copying an image onto a partition and thus setting the entire partition as defined by the image. Usually done for restoring backups or installing entire operating systems.

ROM (Read Only Memory) - This term is a little tricky, because it’s almost always used incorrectly. ROM is a form of storage that can’t be changed. Since ROM would historically store the operating system, many people use the word “ROM” like it means “operating system”. However, almost anything you’ll ever touch on your Android device is actually not ROM. Many simple (primitive) electronics used to store the operating system (which was usually very simple and didn’t ever need to change) on ROM - it was “printed” on the hardware in the factory, shipped, and it never needed to be changed. Time went along and the ROM was used only to store tools meant to install the operating system, so that even if the operating system was damaged or needed an update, the tools in the ROM could do that. Nowadays, more and more things are stored in volatile memory because technology moves so quickly and most things need to be able to be updated - even the tools used to install the operating system need to be updated (like the recovery in Android).

RAM (Random Access Memory) - The type of memory used for quick access to data which is frequently used. It has smaller capacity and is more expensive than other mass storage (such as hard drives) but it performs much faster.

Binaries - The executable files (usually of applications). These files contain actual instructions for what the application does and how it does it. It mostly does not include data the application is using or making. In Android, binary files end with ‘.apk’ (while in Windows binaries end with ‘.exe’).

Read-Write, Read-Only (R/W, R/O) - Software permissions for reading and/or writing to a partition. Read-Write (rw) permissions allow the software to see what’s in the partition and to modify it. Read-Only (ro) permissions only allow the software to see what’s in the partition without being able to modify it.

Stock/vanilla - A term used for the plain, unmodified form of software, usually meaning what the software is “supposed” to be like. In the case of Android, it would usually be the Android that Google distributes (that which the source can be found in the AOSP).

AOSP - Android Open Source Project. This is the actual project Google is working on called Android. After they complete a new version and release it, the source code is released. Hence, this source code is colloquially known as AOSP.

Source Code - The source code is the actual programming code that software engineers (programmers) write to make software. This code alone does nothing, it’s just the “instructions” for software, and for it to work, you need to take the code and “compile” or “build” it so that when you put it on a machine or in an operating system it will actually work.

Open Source - Open source is a way of saying that someone took their code and opened it up to the world, so that anyone can copy that code and use it for whatever they wish (depending on the license). Many times open source software allows anyone to contribute to it and add their own code. Open sourcing is also a philosophy that basically says that software can or should be “open” in such a way that people can contribute, reuse and build upon existing code.

Details needed

Baseband / Modem / Phone / Radio - The driver software for the actual cell radio - the chipset that actually connects to the cellular network and deals with calls, texts and cellular data.

The partitions

Download Mode (specific to Samsung)

Diagnostic and recovery mode for Samsung technicians. Flashes whole images - including baseband and system, even when partitions are not intact (can be used as last resort recovery). Done with a Samsung PC application straight to the phone’s memory via USB.

Recovery

Alternative boot for updating system. May also include diagnostic, flashing, and other miscellaneous tools. All custom ROMs and mods are based on using the (usually modified) recovery to “update” the operating system (in the system partition).

Kernel (sometimes known as Boot)

The kernel is, as implied, the kernel of the operating system, which includes the most basic instructions for the operating system on how to interact with hardware, such as how to read and write files or how much power to draw from the battery. Such critical instructions must be loaded first, before anything else is to take place.

/system

This is the actual operating system. This is what is called “Android” or “CyanogenMod” or “MIUI” (or on parallel systems, “iOS” or “Windows”). “Updating your phone” or “Updating Android” literally means flashing an image on top of the system (flashing = writing on to the entire partition).

Android on a phone is like Windows on a PC. Just like you can differentiate between programs, files, etc. and Windows itself - that is essentially the distinction with Android.

Because the system software is very critical, the entire system partition is read-only - meaning that it can’t be modified or changed without “root” permissions. This read-only attribute is a well established security measure present in all *nix OSs, and allows the user to rest assured that (theoretically) no matter what, the system itself is safe and cannot be compromised (but just so you know, as a rule of thumb: nothing is uncompromisable).

What is actually in this partition?

●	Drivers

The operating system includes the drivers, each of which is the specific language with which the apps speak with the hardware of the phone (the screen, memory, camera, speaker, microphone, gps, wifi, etc). The drivers are different with every device because every device uses a specific make of hardware. That is to say, the processor on the HTC Nexus One is different than that of the Samsung Galaxy S II. The GPS of the HTC Sensation is different than that of the Motorola RAZR.

●	User Interface framework

The operating system includes the framework for most of the UI elements. Basically, that means that an app can tell the OS to show a sliding bar, and the OS will show the sliding bar from the UI framework. That’s usually why almost all sliding bars, checkboxes, buttons, fonts, etc. almost all look the same - they’re all taken from the system’s UI framework. Each and every app may or may not use the built-in framework, and most fullscreen apps (such as games) have their own dedicated UI. In Android, the status/notification bar is part of the system’s UI framework, which is why it’s not as easy to customize.

●	System apps (and bloatware)

There are a few permanent applications that are installed on the phone by default, such as the launcher (“homescreen app”), the phone app, the messaging app, etc. Bloatware are apps that are pre-installed on the phone as system apps that the user doesn’t feel s/he needs. They can’t be uninstalled without root permissions (because they are in a read-only partition). In Android 4.x system apps (including bloatware) can be disabled by the user (making them virtually non-existent on the phone and is usually just as good as uninstalling).

System apps can be found in /system/app/.

●	Media

The system media is the folder that includes ringtones, notification ringtones, alarm rings, and UI interaction sound effects - all (usually) stored in .ogg audio format (an open source format). This folder includes the boot animation as well (the animation that appears as the phone is booting).

System media can be found in /system/media/

Manufacturer skins

Manufacturer skins (such as HTC’s Sense, Samsung’s TouchWiz, Motorola’s Blur, etc.) is an umbrella term for all the modifications a manufacturer has done to change the UI, Media, and sometimes also referring to the system apps installed in the system. Since Android is open source, manufacturers may do whatever they wish to it before selling it, and they believe they add functionality and value to Android by doing so.

Skins are very controversial, because they modify the read-only partition which cannot be undone by the user without root permissions. Many people dislike the modifications and find it makes the phone lose value, or simply find it a drag to have to modify the system in order to revert what the manufacturers have done

.

That being said, I’ve heard many people praise skins for actually making phones better than stock android. It is simply a matter of taste - and that is the reason there are so many custom ROMs out there - because different people like different modifications to the operating system.

/data

The system partition includes all functionality and it is read-only, which means it supposedly never changes after it comes out of the factory. However, the phone does get new things written to it (such as apps, saved data, etc.) and every user’s phone is different than another. There needs to be a place where the user can store everything done to the phone. That’s the data partition - it stores everything that has been added on top of the system after it left the factory and the user begins using it.

What is actually in this partition?

●	Apps

Apps (such as those downloaded from the market, or sideloaded from the sd card) are the executable binaries (.apk’s) that the system recognizes as applications the user can run. These can usually be seen in the app drawer.

Apps can be found in /data/app/.

●	App data

App data includes all data saved by apps. Apps need to save data; games need to save campaign saves and high scores, the contacts app needs to save contacts’ info and the call log, chat apps save logs of chats, email apps save emails, etc. Everything the app needs to remember - is saved as app data. The data partition is read-only, however each app gets its own folder and can only read and write to that folder (so that apps can’t snoop around what you’re doing in other apps).

Frequently asked, app data includes: SMSs and MMSs (Messaging app’s data), saved wifi networks and their passwords (not sure which app’s data), call logs and phone contacts (Contacts app’s data), and the phone’s settings (Settings app’s data). When you wipe data (factory reset), all these will be lost if you don’t back them up.

App data can be found in /data/data/.

When one does a “factory reset”, the data partition (along with the cache partition) is wiped. This ensures the operating system is intact, however, anything and everything the user installed or added or changed while using the installation will be erased, including all apps and their data, all settings - basically everything except for Android itself.

It is important to note that a factory reset does not erase files and data that are saved on the SD cards

(see /mnt below).

/cache

The cache partition is designated for storing files meant for easy, quick access. Files such as thumbnails that keep being called up are copied to cache. Cache has a similar role as RAM, however it is not stored in RAM - it is more akin to virtual memory (such as in Windows). Apps don’t actually write to cache, the OS determines which files are being asked for frequently, and decides which files are worth being copied to cache.

What is actually in this partition?

●	Thumbnails

Thumbnails are the little preview pictures for images in the gallery. These are created so that you can see the images without opening them, however they are much smaller and are only stored for the sake of convenience to the user (to get a preview of the images) and for the sake of convenience to the system (so that it doesn’t have to make a preview every time you glance at the gallery).

●	Cached apps

Apps that have been loaded into RAM and are used frequently are not cleared after the user closes them (see memory management below). If RAM is full and space needs to be made, loaded apps and data (such as a paused game) are copied over to the cache so that they can be loaded later on without having to restart the application from the data partition.

Sometimes issues occur when cache files are corrupt or misplaced - such that applications may be calling the wrong files or bad cache files. In such cases, wiping cache is a good thing - it clears up any files that may be cause issues. Cache files are not critical - they can be deleted without causing any issues, and therefore the cache can be wiped safely at any time (thumbnails will be erased, however the gallery will simply create them again).

Wiping the cache will most likely slow the system down temporarily (as it can no longer rely on files stored for quick access); but as it re-creates cache files, the system will return to its normal performance.

Cache files are obviously related to data, and therefore when wiping data, cache must be wiped as well (a “factory reset” does this automatically). For example, if an app (in data) is using thumbnails (in cache), wiping the app requires wiping the thumbnails as well.

/mnt (SD card and mass storage, also known as storage)

The SD cards are meant for storage. Usually, the internal storage is small and limited, and an internal or external SD card can be added to the phone to allow storage of very large files (such as photos and music). For the sake of proportion, normally the internal storage is no larger than several GBs (which are divided up between /system, /data, /cache, etc.), while storage is minimally several GBs, and are usually as large as several dozen GBs (most SD cards sold today are 8 to 64 GBs). Storing music and photos in internal storage is not realistic, hence the ability to mount SD cards. Newer versions of Android (Honeycomb and ICS) allow for mounting USB storage (such as hard drives), which expands the potential storage size to terabytes.

The difference between an internal and external SD card is simply its physical location. Many phones today are sold with internal SD cards that are actually SD cards built into the phone and cannot be physically removed, however, it is identical in function to an external SD card placed in an SD card slot.

When doing a “factory reset” (wiping /data and /cache), files on storage are not erased. When wanting to remove all personal information on a phone, one must do a factory reset and also remove (or wipe) all storage media.

Storage can be found in /mnt/ or /sdcard/ (e.g. /mnt/sdcard/, /mnt/emmc/, /mnt/USBDisk1/, etc.)