[LG V20 Guides, News, & Discussion] runningnak3d:
Since so many people are asking, I figured I would write up a quick tutorial on how to modify a boot image. A boot image is a kernel, and an initrd packaged together along with some other information.

This will only concentrate on tearing one apart, modifying it, and putting it back together -- making your own kernel and packaging it is outside the scope.

So, the big thing going around right now is the fact that the lovely carriers have this process (rctd) that runs and chews up CPU. rctd stands for Root Check Toolkit Daemon -- and it does what it sounds like. It checks if you have root, it checks if the system partition has been modified, it checks if the kernel has been modified, etc...etc... Most importantly, it chews up a LOT of CPU and disk IO to do this.

For this to work, you need to have a Linux install, or WLS on Windows 10.

Ubuntu comes packaged with abootimg:

apt install abootimg

abootimg is used to extract / create / update the Android Boot Image, but first we need out boot image.

adb reboot recovery

adb pull /dev/block/bootdevice/by-name/boot boot.img

Now we extract it.

abootimg -x boot.img

This will give you 3 files:

bootimg.cfg // feel free to take a look if you want, but do not change anything in this file or your kernel probably won't boot.

zImage // This is the Linux kernel. If you grab the sources, and compile a kernel, this is what you get. Again, leave it alone.

initrd.img // This is the initrd (Initial Ramdisk). It is loaded by the kernel to give you a working environment before anything else is loaded. This is what we need to modify

Before we modify initrd, we have to extract it. It is a compressed cpio file. There are several ways to extract it, but this is the method I use:

mkdir initrd_temp
cd initrd_temp
zcat ../initrd.img | cpio -idv

zcat cats the file while decompressing it. cpio -idv ... -i means extract (yea, wtf), -d means create the directory tree, and -v just means verbose

So now we are in a directory (initrd_temp) with all the files that are in the initrd. The one we care about is init.lge.rc -- we need to edit this file.

If you open it up in an editor, search for this section:

# LG RCT(Rooting Check Tool)
service rctd /sbin/rctd
class late_start
user root
group root
seclabel u:r:rctd:s0

service ccmd /system/bin/ccmd
class core
user system
group system
socket ccmd stream 0660 root system
seclabel u:r:ccmd:s0

Delete all of that, or comment it out using # signs

Now we need to package everything back up.

find . | cpio --create --format='newc' | gzip -9 > ../newinitrd.img
cd ..
abootimg --create newboot.img -f bootimg.cfg -k zImage -r newinitrd.img

When you are done, you will have newboot.img, and you need to flash it.

Since we are still in recovery:

adb push newboot.img /sdcard
adb shell
cd /sdcard
dd if=newboot.img of=/dev/block/bootdevice/by-name/boot

Reboot and enjoy your new -- faster -- rctd and ccmd free kernel.

If doing it this manual way isn't for you, [MENTION=7055541]Zacharee1[/MENTION] has created a script to automate the procedure. I wrote this for people that like to know exactly what is going on. Feel free to poke around in the other files that are in your initrd. You may find other things that you want to tweak. However, be careful, you could make a kernel that won't boot. If that happens, just get into recovery and flash one that does :)

-- Brian