Skip to content
Marcin Kaluza edited this page Jan 15, 2015 · 7 revisions

Boot sequence

See this file to know exactly how it works https://github.com/mkaluza/Samsung_STE_Kernel/blob/3.0.101/usr/u8500_initramfs_files/init

But in plain english it goes like this:

  1. check if we should boot android or recovery and select either boot.cpio or recovery.cpio internal image
  2. extract internal archive from #1 into /
  3. check /efs dir for boot.cpio.gz or recovery.cpio.gz (this is gzipped in contrast to the internal one!) and extract it to / with overwriting (cpio -i -u)
  4. save init.rc
  5. extract all archives found in /efs/common/ to / with overwrite
  6. restore init.rc (this is failsafe preventing bad init.rc in common from disabling both boot and recovery)
  7. extract all archives found in /efs/boot (or /efs/recovery) to / with overwrite
  8. save init.rc (it could be changed in #7
  9. copy all files from /efs/common/overlay to / with overwrite
  10. restore init.rc (this is failsafe preventing bad init.rc in common from disabling both boot and recovery)
  11. copy all files from /efs/boot/overlay (or /efs/recovery/overlay) to / with overwrite
  12. check for /stage1/extra.sh file and run it if it exists (it can be placed there using overlays)
  13. prepend this to init.rc:
    import /init.kernel.rc
    import /init.overlay.rc
    import /init.extra.rc
    
  14. load all modules from /modules (they can be placed there using overlay
  15. remove /stage1, /modues and run /init

Modifying initramfs

Thanks to the boot sequence described above you can modify initramfs without actually flashing it - it's quite useful for testing:) To change something in android initramfs, add additional/modified files to a boot.cpio.gz archive (cd my_dir; find . | cpio -o -Hnewc | gzip -9 > ../boot.cpio.gz) and place the archive on the /efs partition. There's not much free space there, but for ramdisks it should be enough (if it's too small for you, you're probably doing something wrong). The image will be loaded at next reboot.

Similarly, creating recovery.cpio.gz will modify recovery ramdisk only.

Avoid modifying both images at once - if something goes wrong, you won't be able to boot your phone. If only one image is modified, you can start the other one and remove the problematic archive.

Original ramdisks are here: https://github.com/mkaluza/ste-ramdisk-vanir

Potential uses

Booting on other versions of android

As this ramdisk is for 4.4, it probably won't work on older/other versions. But if you can copy the original ramdisk's contents into boot.cpio.gz archive and place it in /efs, it should boot (but no promises - I didn't test it). Success/failure reports are welcome.

Recovery should always boot as it is rom-independent, so if something goes wrong, you can try and fix it from there (or flash original kernel).

Booting other versions then KitKat

F2FS

I won't cover how to format a partition as f2fs - that's already written on xda somewhere.
Just don't forget to check /sys/block/mmcblk0/device/preferred_erase_size and adjust -s accordingly (segment is 2MB in size) when creating the filesystem.

To make it work with this kernel you need to do two things:

  • copy /system/lib/f2fs.ko to /efs/common/overlay/modules/ (create the directory if it's missing)
  • put complete fstab.samsungjanice to /efs/common/overlay/ - it'll overwrite the default one. It should contain correct entries that mount your converted partitions as f2fs.

To test things, try it first with /preload. If something fails, just delete /efs/common/overlay/fstab.samsungjanice and the system should boot.

LVM

TODO

Clone this wiki locally