Some vendors do not release the kernel source code, which is very bad for freedom and goes against the Linux kernel license (see My device runs the Linux kernel (e.g. Android), but the vendor does not provide the source in the Troubleshooting page.
But you can still extract the kernel image from a device that is running Android and use it to run postmarketOS. Of course this is totally discouraged because we want to make sure that we know the code our devices are running but you might find it useful in order to start hacking on postmarketOS without having the kernel source code.
You can extract the kernel that is running your Android device, it doesn't matter if it's the stock ROM, LineageOS or any custom ROM. For this approach you need the adb
tool and root permissions.
NOTE: in this example the boot partition is named msm_sdcc.1 but it might have a different name in your device
# Connect to your Android device
adb shell
# Find the partition name
ls -l /dev/block/platform/
ls -l /dev/block/platform/msm_sdcc.1/by-name
# From there we know that the boot partition is /dev/block/mmcblk0p14
# Now we just dump the partition to a file (we need to root permissions)
su
cat /dev/block/mmcblk0p14 > /sdcard/boot.img
chmod 0666 /sdcard/boot.img
# Exit from adb and copy boot.img to your computer
adb pull /sdcard/boot.img .
You can use unpackbootimg
(usage is described in [[here|How to find device specific information]]) to extract the kernel from your recently extracted boot.img or from a LineageOS release and run it together with postmarketOS initramfs.
If you extracted the kernel from you Stock ROM, it might not have encryption support enabled and in this case you would not be able to boot from an encrypted partition which is how postmarketOS works by default. To disable encryption in postmarketOS use pmbootstrap install --no-fde
. You might need other modules as well for pmOS to work properly.
# fastboot boot <kernel> [ <ramdisk> ]
fastboot boot \
uncompressed_boot/boot.img-zImage \
~/.local/var/pmboostrap/chroot_rootfs-XXX-XXXX/boot/initramfs-lg-hammerhead