Note that these steps were designed with Linux in mind, though they might be adaptable to Cygwin/OSX with some effort.
Also, make sure you delete any SELinux permissive scripts from init.d/su.d first!
- The OTA or custom rom zip that your device is currently running
- simg2img (available in the Ubuntu software repositories)
- sdat2img (available here)
Put your OTA/custom ROM zip file in a new folder and unzip it (this example is using the Pure Nexus ZIP):
mkdir restore_logd cp pure_nexus_hammerhead-7.0-20161025-HOMEMADE.zip restore_logd cd restore_logd unzip pure_nexus_hammerhead-7.0-20161025-HOMEMADE.zip
If you have system.img, then run:
simg2img system.img system.raw.img
sdat2img.py system.transfer.list system.new.dat system.raw.img
mkdir system_mnt sudo mount -t ext4 -o loop system.raw.img system_mnt
Plug in your device to your computer and make sure USB debugging is enabled, then run:
adb push system_mnt/bin/logd /sdcard/logd adb shell
su mount -o rw,remount /system cp /sdcard/logd /system/bin/logd chmod 755 /system/bin/logd exit
This next part is very important! Making sure you closed the adb shell and are still inside the directory you created, run:
ls -Z system_mnt/bin/logd
adb shell su root chcon permission /system/bin/logd
Now you can unplug and restart your device; logd should now be fully working!
Last but not least, run:
sudo fusermount -u system_mnt