[Galaxy S II Android Development] K9100ii:
Hi,

Yes, I am very happy with this. :D Yes, magisk hide is often the biggest reason why people want to have magisk. I don't have very much knowledge on patching the kernel (I would like to learn), but I will give you what I can do:

First step would be enabling CONFIG_NAMESPACES and changing it from

# CONFIG_NAMESPACES is not set

to

CONFIG_NAMESPACES=y

in arch/arm/configs/lineageos_i9100-userdebug in the kernel. Then, the next step would be patching the kernel further for the namespaces magisk hide requires (mount ns procfs). I have found that there is already some work done patching the kernel, but it doesn't seem enough and just setting CONFIG_NAMESPACES and removing the 2 lines containing the code:

#ifdef CONFIG_PID_NS
&pidns_operations,

in fs/proc/namespaces.c so it builds (unsure how to build the kernel with this successfully or if this is required) doesn't seem to make magisk hide work. The thread from topjohnwu here https://xdaforums.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445 recommends this patch https://patchwork.kernel.org/patch/201482/ under Android version support, however, my numerous attempts at patching the kernel with this patch have failed, both with git (results in conflicts) and manually (results in errors when building about things being undefined IIRC, maybe lack of knowledge?). These conflicts could possibly be resolved, but I don't know how to. As for the patch/backport mentioned by [MENTION=5695278]ChronoMonochrome[/MENTION], that's for the end of this post (they've failed for me, too, due to conflicts, but it's most probably possible to resolve the conflicts for that patch!).

Just a FYI, if wanted, upgrading the kernel to at least 3.8 might not be possible, as it might make the zImage more than 8MB in size where our boot partition is 8MB maximum, and the amount of hacks that have been put in the kernel to make LOS 16 work on the S2 is insane so re-doing these hacks could be difficult and definitely be time-consuming. The zImage with magisk is 7.6MB right now, near 8MB! Making the boot partition larger and resizing it could be risky (moving lots of important partitions with it!).

As for the script, thank you for it. I have an issue with it where for commands 'cout' and 'croot' in the script, it would say:

build-magisk-kernel.sh: line 24: cout: command not found

and almost the same for croot (just different line number and 'croot' instead of 'cout', of course). I'm using Xubuntu 19.04. I had already done

. build/envsetup.sh

in the root of the LineageOS sources before running the script, so that is not an issue. Copying out the commands in your script and following along works and builds correctly, however. Still less of a challenge than I thought modifying the ramdisk to include magisk would be!

This patch commit could be very useful, very nice find! While trying to patch the kernel using this patch fails for me, as I get conflicts, this patch is a lot more complete and probably goes better with the 3.0 kernel as this patch is for the 3.0 kernel, and the conflicts could be most probably be resolved, though I have no idea on how to do so. The dead sleep issue that was on the S3 doesn't seem to exist for me on my S2 setting CONFIG_NAMESPACES to y with my own kernel. I have attached the .patch file for this commit, use it if you would like to [MENTION=2222292]rINanDO[/MENTION], could make things somewhat easier (unless you've already started patching the kernel using this commit, if so, great.).