-
Notifications
You must be signed in to change notification settings - Fork 3
Initramfs overlay
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:
- check if we should boot android or recovery and select either boot.cpio or recovery.cpio internal image
- extract internal archive from #1 into /
- 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)
- save init.rc
- extract all archives found in /efs/common/ to / with overwrite
- restore init.rc (this is failsafe preventing bad init.rc in common from disabling both boot and recovery)
- extract all archives found in /efs/boot (or /efs/recovery) to / with overwrite
- save init.rc (it could be changed in #7)
- copy all files from /efs/common/overlay to / with overwrite
- restore init.rc (this is failsafe preventing bad init.rc in common from disabling both boot and recovery)
- copy all files from /efs/boot/overlay (or /efs/recovery/overlay) to / with overwrite
- check for /stage1/extra.sh file and run it if it exists (it can be placed there using overlays) FIXME: I think it should be run after loading all the modules...
- prepend this to init.rc:
import /init.kernel.rc import /init.overlay.rc import /init.extra.rc
- load all modules from /modules (they can be placed there using overlay)
- remove /stage1, /modules and run /init
When extracting package named PACKAGE.ext1.ext2 (like lvm.cpio.gz) it'll look for init.PACKAGE.rc (like init.lvm.rc) in that archive and if it finds one, it'll add a command to import it from /init.ovarlay.rc
You can also include init.extra.rc in one of overlay directories and it'll be imported as well. This one is to avoid touching existing .rc files if you only want to add things, not change them.
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
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).
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.
See Converting /cache and /preload into bigger /cache and moving dalvik-cache
Both cpio and tar archives are supported. Supported compression methods are: gzip (.gz), bzip2 (.bz, .bz2, .bzip2), xz (.xz)
The file name should contain archive and compressor extensions separately: .cpio.gz, .tar.xz, etc. One exception from this is .tgz