How to mount a ramdisk in Android before it starts?

4.6k Views Asked by At

Is it possible to mount a ramdisk in Android before the Android framework starts, but after the underlying Linux kernel has started? If so, what commands should I use?

Thanks!

2

There are 2 best solutions below

0
On

Based on some reference books I read, an Android system starts up in following main steps:

  1. CPU reads a hard-coded address which usually points to some bootloader program
  2. The bootloader initializes the RAM, puts basic hardware in a quiescent state, loads the the kernel and RAM disk, and jumps to the kernel.
  3. start_kernel() initializes subsystems and proceeds to call the init function of built-in drivers.
  4. The kernel mount its root system (from ramdisk.img).
  5. init.rc is then called to set up the environment variables such as system path, mount other filesystems, start native daemons and so on.

Now, to answer your question: "Is it possible to mount a ramdisk in Android before the Android framework starts, but after the underlying Linux kernel has started?" -- I think this is exactly what android did.

0
On

You have to write shell script which you invoke from init.rc files. Another approach could be write a C program which gets launched from init.rc as daemon.

The init is the middle place where linux has booted almost while android frameowrk is about to begin booting.