-1

Most Android devices that I am aware of programmed to mount the system partition at /system. All partitions get mounted at folders underneath /. Looking at my device's /proc/mounts shows that rootfs, some kind of special filesystem is mounted at /, unlike on desktop versions of Linux that mount something like /dev/sda1 at /. Besides folders, there are also important files like init directly under /. Where do these files and folders come from?

4
  • 1
    Those files and folder structure are created by using the content of the ramdisk contained in the boot.img. That's why any modifications you perform on a file located at / gets rolled back on reboot. – Grimoire May 16 '16 at 14:55
  • @DeathMaskSalesman while being short, that's basically the answer to this question. Enhance it a little (what is a boot image etc), and it should be pretty fine :) Pointer to link to: Can somebody explain the boot process of an Android device? – Izzy May 16 '16 at 16:20
  • 1
    @Izzy I'm sorry, honorable colleague, but I guess that the privilege of publishing the answer will be yours. While being happy that my answer might address the question, I have no time to invest in mining the necessary info about ramdisks and boot.img content, since I've been notified that I've to review some critiques I made. Might you take the pleasure of answering in my stead? – Grimoire May 17 '16 at 10:02
  • Near duplicate: android.stackexchange.com/q/130348/218526 – Irfan Latif Feb 17 '20 at 13:16
1

Doing this answer on behalf of Death Mask Salesman who currently lacks the time:

To get a general idea of how the boot process on Android works, please take a look at Can somebody explain the boot process of an Android device? Don't get confused of the term "Dalvik" there: for Android 5+ simply replace it by "ART", the process is the same.

Step 3 is explained there as [The] Linux kernel [takes control], which will, together with the init process, initialize the base system, e.g. caches, file systems, etc. This is where file systems are set up. Details on those can be found e.g. in Android Folder Hierarchy: Basically, there are multiple partitions on the device where e.g. the OS components are stored (/system), the user data go to (/data) then the SD cards, etc; then there are "virtual file systems" like /proc and /dev.

The root file system (/) is something special, and comes from a so called "initial RAM disk" (Initrd), which is loaded from a file (a so called Boot image). Hence on each boot, the root file system is "generated" freshly from that file – replacing all changes you've made to it prior that boot. There are several boot scripts executed to perform this job (usually it's the init.rc you see in the root folder – but depending on the device, it could be other/additional scripts), e.g. creating additional "directories and mounts".

Additional details can be found behind the following links:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.