[Galaxy Note5 Q&A, Help & Troubleshooting] garyd9:
Here's the script... If you have questions, you can ask, but I probably won't answer (unless I decide it's an intelligent question from someone that knows what they are doing.)

If you need unpackbootimg or mkbootimg, use google. Otherwise adb is pretty standard, and the rest of the stuff is pretty standard on most linux distros.

Folks, this is getting into the technical nitty gritty of things, and I don't have the patience this week for teaching. The fact that I'm posting this script should be enough for anyone fluent with mucking with android boot images...

Edit: I've been asked not to post a script that automates this process. In retrospect, that's probably a good idea. However, my motives are different from the person who made the request. The request was originally to hopefully block problems with future versions of supersu and/or this process. It's not in a "final" form. My motive, on the other hand, is to force people to learn what they are doing instead of blindly running scripts on images. You know that old cliche about about giving a man a fish vs teaching them to fish? Well, I'm a bad teacher, but I've found that if I give the root answers (no pun intended), that people will more often search out the rest of the solution...

(For those who already know what they are doing, please ignore the fluff in these directions.. for those that don't, enjoy the learning process - it's the more valuable than you might realize.)

That being said...

THIS CAN AND LIKELY WILL CHANGE OVER TIME. IT WORKS FOR ME ON THE IMAGES I'VE TESTED. IT WORKS WITH SUPERSU V2.52. I CAN'T AND WON'T PROMISE ANYTHING OTHER THAN THE FACT THAT IT WORKED FOR ME AT THE TIME OF THIS MESSAGE. LEARN WHAT ALL THIS IS DOING AND WHY BEFORE CONTINUING.

The first step is to unpack the boot img. There's a tool for that called unpackbootimg. Then you need to open up the ramdisk. It's packaged with cpio and some compression (usually gzip.) If you google things like "unpackbootimg gunzip cpio" you'll find the steps needed...

So, with that newly unpacked ramdisk, you need to modify a few different things. First, follow instructions from [MENTION=631273]Chainfire[/MENTION] on fixing up the sepolicy file. If you go to the very first post in this thread, it references another thread where I was "talking to myself" and working out the issue. It links to a supersu thread that documents what needs to be done for sepolicy.

You'll also need to edit the "fstab" file. Before continuing, please understand what "fstab" does. Google is your friend. So, you need to remove the mount options "support_scfs" and "verify" from the "fstab.samsungexynos7420 file" where it mounts the /system partition. (I'm not entirely sure that "verify" has to be removed, but it's what I've been doing anyway.)

Now, you aren't quite done yet. In order to fix the issue of the device not going into deep sleep, take a look at post 17 in that thread I referenced above. Go ahead and take a peek now: http://xdaforums.com/showpost.php?p=63225712&postcount=17

We are trying NOT to recompile the kernel, so the writes to the sys filesystem will work. Funny thing.. post #18 in that same thread shows how I accomplished that. (Easy, right?)

Now you have all the modifications needed for the ramdisk. time to repack it up. Remember that string I suggested you google earlier? Replace "gunzip" with "gzip" when you search with google and you'll be well on your way.

For re-making the boot image, there's a tool called "mkbootimg" that you'll want. If you run it with no parameters, you'll see that there are a LOT of options. Thankfully, when you ran "unpackbootimg", it left around a bunch of files that contain values that you can use for each one of those values. Nice tool, isn't it? (Well, most of them. the kernel will be called something like "boot.img-zImage" and the ramdisk is the thing you just repacked.)

Oh... don't make the mistake I often make: remember to include the dtb file. (--dt parameter.) For some reason, I always forget that file.

So, the newly created boot.img file can be flashed directly with TWRP (and maybe Philz -- I don't know.) You can also put it in a tarball and flash with ODIN (google for instructions) or create a .zip file flashable with Philz/TWRP (again, google for instructions.)

---

Take care

Gary