File System in Android

Rutuja Hilay
8 min readJun 23, 2022

Most of the Android users are using their Android phone just for calls, SMS, browsing and basic apps, but from the development perspective, we should know about Android internal structure. Android has several partitions (like boot, system, recovery , data etc) to organize files and folders on the device just like Windows Operating System.

Each of these partitions has its own functionality, but most of us do not know the significance of each partition and its contents. In this blog, we will take you on a tour of Android partitions. So let’s start the blog on the android file system.

There are mainly 6 partitions in Android phones, and other Android devices. Note that there might be some other partitions available, it differs from a Model to another. But logically these 6 partitions can be found in any Android device, which include /boot, /system, /recovery, /data, /cache, and /misc. Additionally, in the Android smartphone, there are two more file system partitions — /sdcard and /sd-ext. Let us now break down each partition separately and explore the Android File system hierarchy.

/boot

The /boot partition consists of the Android kernel and the ramdisk. It contains every single thing that is needed to boot your Android device when powered on. You should only proceed to clear this partition from recovery if it is absolutely necessary. If you do, once the partition is cleared, ensure to reboot the phone only after installing a new boot partition.

/system

The system partition accommodates the entire Android Operating System. It includes the Android GUI as well as the system apps that come pre-installed on Android devices. So, what happens if you wipe this partition? You can still boot the device. We can only put our device into recovery or bootloader mode.

/recovery

This partition is designed for backup and can also be considered the alternative boot option or partition in an Android device. It lets the device boot into recovery mode when backing up data, clearing data, restoring phone to factory settings, and performing other maintenance operations.

/data

Also known as user data partition, it consists of all of the user’s data, including contacts, settings, apps and messages. Wiping this partition will lead to storing your phone to factory settings, having removed all of the apps, messages, and user settings from the Android device.

/cache

This partition stores the frequently accessed app data and its components. Wiping this partition will just clear all the built-up cache, and the device will simply go back to rebuilding it as you continue using it. Clearing cache also frees up some space in your device and can also fix certain issues sometimes.

/misc

This partition contains all the miscellaneous system settings, usually the on/off switches. The settings may include carrier ID or region ID, USB configuration, and also certain hardware settings. This partition is very important since if the partition becomes corrupt or goes missing it can cause several device features to malfunction. A missing /misc partition can also cause the Android device to not boot at all.

/sdcard

This is the space that is available to users to store their files and data. Depending on the device, you could even have more than one sd card partition. If the device has an external SD card slot, then the /sdcard partition refers to the internal storage device, and the external SD card will be assigned a different partition, either a new partition called /sdcard2 or a separate directory within the /sdcard partition itself such as /sdcard/sd. Wiping the partition with the external SD card storage is completely safe, as long as you have backed up the important data or documents you may have on it. Wiping the /sdcard partition with the external SD and storage is safe, as long as you have backed up any important data or documents you may have on it. Wiping the /sdcard partition, however, results in wiping some system and app data and settings, but it still doesn’t hinder the system’s boot processor functionality.

/sd-ext

This is an additional partition of the sdcard partition, which is present only on some devices, typically the ones that have custom ROMS or mods on them. It can be used with certain ROMS that have special features such as APP2SD+ or data2ext enabled. This is a /data partition of the /sd card and stores some user data and settings that are typically stored on the /data partition. This is useful for devices with very limited internal memory.

Without rooting the device, Android users typically can only access the data partition. The contents of this partition are those which you will see in most file managers or when you connect it to a PC. If you have an external SD card attached to the device, you will also be able to view the contents of it in this user-accessible data partition. If your phone doesn’t come packing a decent file explorer or manager, you can simply install one of the powerful third-party file managers available on the Play Store. You can also browse your data files on PC via a USB connection. However, ensure that the phone is in MTP (Media Transfer) or File Transfer mode.

Understanding the Android File Hierarchy

For Android users, it is a variation of the Android file hierarchy.

In Android, the file hierarchy is a single tree, with the top of the tree being “/” — the root of the tree. Under “/” are files and directories.The Android file hierarchy lacks the concept of drives, as in Windows.Instead, file systems are mounted on a directory to create a single integrated tree.

For media based file systems, the file system represents a partition of some media. It makes no difference whether the file system exists on the local device, or on a remote device. Everything is integrated into a single file hierarchy that begins with root.

The term path refers to the path to a file or directory. The absolute path to any file or directory begins with “/” — root.

For example:

Your file application may show the path to the internal flash drive as /mnt/sdcard, or simply “sdcard.” If your Android device includes an external SD Card, you will also see/mnt/extSdCard.

The actual names may vary, but the concept remains the same.

For example, CyanogenMod mounts the external flash drive on /mnt/sdcard, and the internal flash as /mnt/emmc. The important point to remember is that each of these directories represents a mount point for a file system.

As a normal user, an Android file only displays the file systems to which you have access.These file systems are just a part of the entire file hierarchy.To see the complete Android file hierarchy, you need “root” access.In this case, “root” refers to a special user account that has system administration privileges.When you “root” an Android device, you are gaining access to the root account.There is a reason for not automatically granting root access — one tiny mistake can go a long way.However, for those experienced in Linux commands and Linux system administration, it opens the hood to the underlying structure of Android.

Types Of File System In Android

As mentioned in Android Kernel versus the Linux Kernel, Android uses the Linux kernel. All file, and directory, operations from an application flow through a kernel abstract layer called the Virtual File System (VFS).Each file system has a separate kernel module that registers the operations that it supports with VFS.

By separating the implementation from the abstraction, adding a new file system becomes a matter of writing another kernel module.These modules are either part of the kernel, or are dynamically loaded on demand.The Android kernel comes with a subset of the vast collection of file systems that range from the Journal File System (JFS) for AIX (IBM’s version of Unix) to the Amiga file system.All the fancy footwork is hidden from the user, as the kernel handles all the work when it mounts a file system.The kernel configuration file determines what file system modules are compiled, and whether they are built into the kernel, or dynamically loaded.

Consequently, the Android kernel only contains those file system modules that are relevant to its operation.

Flash Memory Android File System

  • exFAT: Originally created by Microsoft for flash memory, the exFAT file system is not a part of the standard Linux kernel. However, it still provides support for Android devices in some cases. It stands for Extended File Allocation Table.
  • F2FS: Users of Samsung smartphones are bound to have come across this type of file system if they have been using the smartphone for a while. F2FS stands for Flash-Friendly File System, which is an Open Source Linux file system. This was introduced by Samsung 4 years ago, in 2012.
  • JFFS2: It stands for the Journal Flash File System version 2. This is the default flash file system for the Android Open Source Project kernels. This version of Android File System has been around since the Android Ice Cream Sandwich OS was released. JFFS2 has since replaced the JFFS.
  • YAFFS2: It stands for Yet Another Flash File System version 2. Funny as the name might sound like, it is actually a serious business! It has not been a part of the AOSP for a while now and is rarely found in Android smartphones. However, it does tend to make a few appearances every now and then.

Media-based Android File System

EXT2/EXT3/EXT4 : Ext, which stands for the EXTended file systems, are the standards for the Linux file system. The latest out of these is the EXT4, which has now been replacing the YAFFS2 and the JFFS2 file systems on Android smartphones.

MSDOS: Microsoft Disk Operating System is known to be one of the oldest names in the world of Operating Systems, and it helps FAT 12, FAT 16 and FAT 32 file systems to run.

VFAT: An extension to the aforementioned FAT 12, FAT 16 and FAT 32 file systems, the VFAT is a kernel module seen alongside the MSDOS module. External SD cards that help expand the storage space are formatted using VFAT.

Pseudo File Systems

  • CGroup: Cgroup stands for Control Group. It is a pseudo file system which allows access and meaning to various kernel parameters. Cgroups are very important for the Android File System as the Android OS makes use of these control groups for user accounting and CPU Control.
  • Rootfs: Rootfs acts as the mount point, and it is a minimal file system. It is located at the mount point “/”.
  • Procfs: Usually found mounted at the /proc directory. The procfs file system has files which showcase the live kernel data. Sometimes this file system also reflects a number of kernel data structures. These number directories are reflective of the process IDs for all the currently running tasks.
  • Sysfs: Usually mounted on the /sys directory. The sysfs file system helps the kernel identify the devices. Upon identifying a new device, the kernel builds an object in the sys/module/ directory. There are various other elements stored inside the /sys/ folder which helps the kernel communicate with various Android File Systems.
  • Tmpfs: A temporary file system, tmpfs is usually mounted on /dev directory. Data on this is lost when the device is rebooted.

We believe that reading this article would help you explore the Android File system in the easiest way. Exploring the Android file system hierarchy is important for troubleshooting various issues and it also helps you organize your Android device.

Authors: Group 68

  1. Chaitanya Ranaware
  2. Preeti Raul
  3. Rutuja Hilay
  4. Nishant Tekale
  5. Aayush Wagh

--

--