How Android Works?
Android is an Open Source Operating System for mobiles, tablets and Televisions that is developed by Google.
Well, everyone just uses their smartphones and enjoy stuffs that android offers. Ever wondered how it works? How the apps run? What is inside the hood? Here, we will explain how android works and explain its partition architecture.
Android is a Linux based OS that is designed for mobile devices like smartphones and tablets. The OS has evolved a lot in the past few years from black and white phones to colored smart phones or mini computers. And Android is the most widely used OS that was founded in Palo Alto in California in 2003. Android supports a large number of applications and comes with advanced features for the users. The hardware supporting the Android software is based on the ARM architecture.
As per shown in the image above when the device boots up the bootloader calls the kernel and the kernel loads drivers from system libraries and then the system boots by executing binaries followed by drivers.Now after executing all the binaries the system calls its framework which includes lots of services. After the framework being loaded the system apps gets into there work. For all sets of features there are different sets of apps.Now to lets know about the bootloader and recovery of android.Every android device have a boot-loader and recovery.
First come to boot-loader
How Android Works?
Here in this piece of writing, we will discuss about the partitions of an android device. The partition layout usually varies between the versions and vendors, but a few partitions are always present in all Android mobile devices. The following sections will explain the common partitions that are found in most Android devices. Each partition serves different functions during the booting process
Bootloader also known as UBOOT . its like BIOS of Computer. It is the first thing that runs when the hardware communicates with software. When the device shows its manufacturer logo also known as bootlogo that mens bootloader has been loaded perfectly. Bootloader is quite handy to developers cause its the only thing that helps developers to bring there phone back to life even its dead or bricked due to System/boot issues. The OS can be flashed bootloader using partitions. We will discuss about partitions in this guide
In Android, recovery means the dedicated, bootable partition that has the recovery image installed. A combination of key presses will boot your phone to recovery, where you can find tools to restore your phone by wiping data as well as install official OS updates/OTA Updates. As Android is open and has the recovery source code available, building a custom version with more and different options is relatively easy as well. Let’s look at both options.
The stock recovery(which comes with the device by default) is pretty limited, Its main purpose is to delete all or some user data and files, or to perform system updates manually with signed and verified delta update packages. Normally, both these operations are started from the running Android system, but you can do things manually and boot right into recovery yourself. When you tell your phone to do a factory reset. recovery is what boots up and erases the files and data. Likewise with updates— when we restart to install an official OS update, it’s done in recovery.
The Custom recovery is full featured .It has all options that stock recovery has except that it has lots of options like backup partitions ,restore partitions,File manager,installing images directly to partitions.The famous custom recoveries are TWRP and CWM Recovery.
Android is linux based os and has its own sets of partition structure . PC GNU/Linux users: please note this is completely different from x86 (PC Linux) partition table. You will not come across partitions denoted as sda1, sda2, sdb1, sdb2, and so on. Instead, it will be structured as follows:
Boot: This partition in Android contains the kernel image and also a RAM disk that is combined via the mkbooting. To flash the kernel without flashing a new partition, a virtual partition is used:
- Kernel: This is a partition that helps to overwrite only the kernel and writes the new image on the old one. In order to do this, it first determines the start location of the existing kernel image in the eMMC and then copies to that location considering that the new kernel image might be bigger than the existing one. The bootloader can also make some space by moving any data that follows it or leaving any operation that contains an error. In case the development kernel is incompatible, then you may have to update the dtb partition present there or the vendor or system partition that is associated with the kernel modules.
- Ramdisk: The virtual Ramdisk partition overwrites the RAM disk with the new image over the previous one. And for this, it identifies the start location of the existing ramdisk.img in the eMMC and then copies it to the location, while considering that the new RAM disk may be larger than the present one. The Bootloader can either abandon the operations that contain an error or make some space by moving the data that follows it.
System: This partition contains the Android framework. This includes the Android GUI and also the system applications that are pre-installed in the device. if in case you delete this partition, it will remove Android from the device without making it unbootable. And you can put your phone into the recovery mode and install the new ROM.
Recovery: This partition stores the images that are booted during the OTA process. If in case the device supports the A/B updates, then the recovery can be a RAM disk that contains the boot image instead of the separate image. Recovery also uses the misc partition, which is of 4KB or larger.
Cache: This partition stores any temporary data of a device that uses the A/B updates. It need not be writable from the bootloader, it has to be erasable. The size of the cache totally depends on the device type and also on the availability of space on userdata.
Data: This partition contains the user’s data that include sms, contacts, setting and other android applications that are installed. When you do the factory reset, this partition will get wiped out and your device will go back to the initial state when you used it for the first time.
This is the partition where Android stores frequently accessed data and app components. Wiping the cache doesn’t effect your personal data but simply gets rid of the existing data there, which gets automatically rebuilt as you continue using the device.
This partition contains miscellaneous system settings in form of on/off switches. These settings may include CID (Carrier or Region ID), USB configuration and certain hardware settings etc. This is an important partition and if it is corrupt or missing, several of the device’s features will will not function normally.
This is not a partition on the internal memory of the device but rather the SD card. In terms of usage, this is your storage space to store your media, documents, downloads, pictures, videos, ROMs etc. on it. It is like the equivalent of the ‘ Users/[Username] ‘ folder in Windows and ‘ /home/~ ‘ folder in x86 Linux. Wiping it is perfectly safe as long as you backup all the data you require from it, to your computer first. Though several user-installed apps save their data and settings on the SD card and wiping this partition will make you lose all that data.
On devices with both an internal and an external SD card – devices like the Samsung Galaxy S and several tablets – the /sdcard partition is always used to refer to the internal SD card. For the external SD card – if present – an alternative partition is used, which differs from device to device. In case of Samsung Galaxy S series devices, it is /sdcard/sd while in many other devices, it is /sdcard2. Unlike /sdcard, no system or app data whatsoever is stored automatically on this external SD card and everything present on it has been added there by the user. You can safely wipe it after backing up any data from it that you need to save.
This is not a standard Android partition, but has become popular in the custom ROM scene. It is basically an additional partition on your SD card that acts as the /data partition when used with certain ROMs that have special features called APP2SD+ or data2ext enabled. It is especially useful on devices with little internal memory allotted to the /data partition. Thus, users who want to install more programs than the internal memory allows can make this partition and use it with a custom ROM that supports this feature, to get additional storage for installing their apps. Wiping this partition is essentially the same as wiping the /data partition – you lose your contacts, SMS, market apps and settings.
/Boot (Is NOT viewable in Android)
/Recovery (Is NOT viewable in Android)
/Data (Userdata) (Is viewable in Android)
/Cache (Is viewable in Android)
/System (Is viewable in Android)
/Misc (Is NOT viewable in Android)