[GUIDE] How to restore logd to your device/fix adb logcat read failure or empty logs - General Topics

A few days ago, I flashed a zip onto my phone that set SELinux to permissive. However, there was a problem: it deleted logd, which is essential to adb logcat. Considering I'm an Android developer, that isn't a good thing! It took me a bit to figure out how to get it back, so I'm making this guide to share with you guys to help whatever poor soul has to fix this next.
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!
Prerequisites
The OTA or custom rom zip that your device is currently running
adb
simg2img (available in the Ubuntu software repositories)
sdat2img (available here)
Instructions
Put your OTA/custom ROM zip file in a new folder and unzip it (this example is using the Pure Nexus ZIP):
Code:
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
Now, look for a file named either system.new.dat or system.img.
If you have system.img, then run:
Code:
simg2img system.img system.raw.img
If you have system.new.dat AND system.transfer.list, instead run:
Code:
sdat2img.py system.transfer.list system.new.dat system.raw.img
Either way, you should now have a file named system.raw.img. Next, mount it:
Code:
mkdir system_mnt
sudo mount -t ext4 -o loop system.raw.img system_mnt
This will mount the system image onto the system_mnt folder.
Plug in your device to your computer and make sure USB debugging is enabled, then run:
Code:
adb push system_mnt/bin/logd /sdcard/logd
adb shell
You should now be in a shell connected to your device. Inside, run:
Code:
su
mount -o rw,remount /system
cp /sdcard/logd /system/bin/logd
chmod 755 /system/bin/logd
exit
This will install the logd binary and close the shell.
This next part is very important! Making sure you closed the adb shell and are still inside the directory you created, run:
Code:
ls -Z system_mnt/bin/logd
If the output looks like this:
Code:
? system_mnt/bin/logd
then you have nothing else to do. Otherwise, it might look a bit like this:
Code:
u:object_r:logd_exec:s0 system_mnt/bin/logd
Copy part before the path; in this case, it's:
Code:
u:object_r:logd_exec:s0
Then, run:
Code:
adb shell su root chcon permission /system/bin/logd
replacing permission with the string you copied.
Now you can unplug and restart your device; logd should now be fully working!
Last but not least, run:
Code:
sudo fusermount -u system_mnt
to unmount the system image from your computer.
Enjoy!

Execute command failed while replacing permission
Code:
adb shell su root chcon permission /system/bin/logd
u:object_r:logd_exec:s0
/system/bin/sh: <stdin>[1]: u:object_r:logd_exec:s0: not found

Related

How to get APPS back into system/apps/

I updated my rom and there are some omitted apps that I would like to get back into system/apps/ for example VoiceDialer.apk, but I cannot seem to get them back on. I am using Fresh Rom 0.4 and the phone is obviously rooted. maybe I am doing something wrong in adb shell but I keep getting one of 2 different erors. Either permission denied or adb not found. Thank you in advance for your help.
flaav8r said:
I updated my rom and there are some omitted apps that I would like to get back into system/apps/ for example VoiceDialer.apk, but I cannot seem to get them back on. I am using Fresh Rom 0.4 and the phone is obviously rooted. maybe I am doing something wrong in adb shell but I keep getting one of 2 different erors. Either permission denied or adb not found. Thank you in advance for your help.
Click to expand...
Click to collapse
1) Permission denied - make sure that when you do an adb shell, you're root (have the # prompt) and make sure you've mounted /system as rw (adb remount)
2) adb not found - make sure there's only one adb.exe on your computer and that it's the one from the SDK and that the SDK's /tools directory is in your path (to be safe, you can always just run adb from that directory)
jmanley69 said:
1) Permission denied - make sure that when you do an adb shell, you're root (have the # prompt) and make sure you've mounted /system as rw (adb remount)
2) adb not found - make sure there's only one adb.exe on your computer and that it's the one from the SDK and that the SDK's /tools directory is in your path (to be safe, you can always just run adb from that directory)
Click to expand...
Click to collapse
1. the procedure I used is this: from the cmd prompt in the androidsdk/tools/ directory:
adb shell
$ su
# mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
# cd /system/app
# adb push VoiceDialer.apk system/app
but its a no go. Can't understand why.
BTW, I have the VoiceDialer.apk file in the androidsdk/tools folder just to make the push easier.
Ok, here is a screen shot from my command prompt window. I know someone knows what the hell I'm doing wrong. Just wanna get the damn voice dialer back on my phone. Please help, thank you.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Barry>cd \
C:\>cd androidsdk\tools\
C:\AndroidSDK\tools>adb shell
* daemon not running. starting it now *
* daemon started successfully *
$ su
su
# mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
# adb push VoiceDialer.apk /system/app/
adb push VoiceDialer.apk /system/app/
adb: not found
#
you cant do adb push while in shell ($ or #). Exit out and just try tying the adb push
goku14238 said:
you cant do adb push while in shell ($ or #). Exit out and just try tying the adb push
Click to expand...
Click to collapse
When I do that I get permission denied or something to that effect.
Yeah there's a post about this in the Fresh thread.
The most straightforward way is this:
Reboot to the recovery partition.
adb shell into the phone.
Issue the following command to mount the system partition:
mount -t yaffs2 /dev/block/mtdblock3 /system
Type exit to exit the shell.
Then do:
adb push c:\directory-with-the-apks /system/app
jonnythan said:
Yeah there's a post about this in the Fresh thread.
The most straightforward way is this:
Reboot to the recovery partition.
adb shell into the phone.
Issue the following command to mount the system partition:
mount -t yaffs2 /dev/block/mtdblock3 /system
Type exit to exit the shell.
Then do:
adb push c:\directory-with-the-apks /system/app
Click to expand...
Click to collapse
Thank-you, I will give it a try.

Change the boot sound w/o re-flash the ROM for G7

It's my fault to have post this message here.
It's for G7, but I think it is also OK for Incredible.
========================================
1. Prepare a short mp3 and name it android_audio.mp3
2. Put the mp3 under the adb folder
3. Save the following code as !bootaudio.bat (I use this name)
4. Turn your phone into ADB debugging mode
5. run !bootaudio.bat
6. Reboot your phone and have fun!
This should work on almost all G7
Tips: During the boot animation, the volume would change twice. So I suggest insert 1 second before the audio for escaping from the volume changing side-effect.
Code:
adb shell mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
adb shell rm /data/local/android_audio.mp3
adb push android_audio.mp3 /data/local/
adb shell rm /system/customize/resource/android_audio.mp3
adb shell ln -s /data/local/android_audio.mp3 /system/customize/resource/android_audio.mp3
adb shell ls -l --color=never /data/local
adb shell ls -l --color=never /system/customize/resource/
adb pull /system/customize/CID/default.xml
pause
Script description:
Mount the system path to enable writing access.
Remove the original boot sound if it exists.
Push your mp3 into the data/local, where the bootanimation.zip is.
Make a link to data/local/android_audio.mp3
List the two affected pathes for you to confirm the result
Pull the default.xml out from the phone, if you find it not work after reboot, you can check the xml to see what the actural fullpath it is using. And manually change the script to try again.
My current boot sound is attached to the thread.
G7?
Sent from your mom's phone

[Q]Installing busybox

Hi,
I'm trying to install busybox into a development board by downloading the pre-compiled binary and following the installation steps here. However, after doing so, I'm still unable to use the commands in /system/busybox. For example, when I try to run mknod, it shows me the following error:
Code:
./sh: mknod: not found
Basically, I did the following:
In Linux
Code:
adb root
adb remount
adb push busybox /system/busybox
adb shell
In device adb shell
Code:
cd /system/busybox
./busybox --install .
./sh
cd /system/bin
mv sh sh.android
ln -s /system/busybox/sh sh
It would seem like what I did to install busybox didn't work. May I know what's the correct procedure to install it?
I tried creating symlinks using the same ln command and it works, but do I have to do this manually for every single command?
Thanks!
goister said:
Hi,
I'm trying to install busybox into a development board by downloading the pre-compiled binary and following the installation steps here. However, after doing so, I'm still unable to use the commands in /system/busybox. For example, when I try to run mknod, it shows me the following error:
Code:
./sh: mknod: not found
Basically, I did the following:
In Linux
Code:
adb root
adb remount
adb push busybox /system/busybox
adb shell
In device adb shell
Code:
cd /system/busybox
./busybox --install .
./sh
cd /system/bin
mv sh sh.android
ln -s /system/busybox/sh sh
It would seem like what I did to install busybox didn't work. May I know what's the correct procedure to install it?
I tried creating symlinks using the same ln command and it works, but do I have to do this manually for every single command?
Thanks!
Click to expand...
Click to collapse
You didn't add /system/busybox to your PATH
Sent from my LT26i using XDA
Hi,
Where would I add it? init.rc or something?
Anyone?
Thanks!

Restore your Baseband in MT65XX Devices

HOW TO RESTORE YOUR BASEBAND IF YOU LOST IT DURING A FORMAT - MT65XX DEVICES
Thanks go to abdullahi_ for this solution. His original post from another forum can be found below:
https://forum.hovatek.com/thread-116-post-376.html#pid376
Prequisites
Phone Rooted
Smart Phone Flash Tool Backup - Specifically protect_f file (for a Dual SIM phone, maybe different for a single SIM phone)
Linux OS - I used Ubuntu in a virtual machine
Android SDK platform tools for ADB access
From a terminal (CTRL + ALT + T)
Code:
mkdir -p ~/protect_f/f
cd ~/protect_f
At this point copy the file "protect_f" in the ~/protect_f
then continue:
Code:
sudo mount -t ext4 -o loop protect_f f/
Enter your password
then continue:
Code:
cd f
sudo chown -R $USER:$USER *
Copy the files in the f/md folder to a folder on your phone and using a file manager with root access copy the two files into the /protect_f folder or any toher means
NOTE: You will probably get back your cell access immediately. However, please continue to make the permissions and ownership are the same as the original.
Also if you have a dual SIM, one of the files from the protect_f folder will automatically be created in the protect_s folder
To clean up the files on the Linux OS:
Code:
cd ~/protect_f
sudo umount f/
cd ~
rm -rf protect_f
To change permissions and ownership on the files
From an adb shell for your phone:
Code:
su
cd /protect_f
ls -l
Take note of the ownership of the md folder, on the phone I used they were ccci & nvram, in Linux the ownership was 9996 & 9997.
At this point I put the phone in airplane mode, just as a precaution to make sure the rest went smoothly
Code:
cd md
chown ccci:nvram *
chmod 660 *
If you have a DUAL SIM phone, for the second folder....
Code:
cd /protect_s/md
chown ccci:nvram *
chmod 660 *
You can now take the phone off of airplane mode and reboot your phone to be sure it is working,
ALL DONE!
REMOVED

Moto 5g ace_kiev_lineage18.1_/data/media not found

ok ive yet to have to ask any ? on xda yet cause i feel like i dont know jack lol
BUT i do need help wile trying to remember linuix commands for adb shell and trying to replace boot animation.zip ans learned the mv file file2 overwrite/rename (i must say i find sort of retarted,but i dont do this for a living) and relized i had remount system as rw i exit shell heres the super mistake please help b4 i have to restart from stock
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Minimal ADB and Fastboot>adb remount
Using overlayfs for /vendor
Now reboot your device for settings to take effect
remount succeeded
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Minimal ADB and Fastboot>adb reboot
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Minimal ADB and Fastboot>adb devices
List of devices attached
ZY22CCHMQT recovery
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Minimal ADB and Fastboot>adb shell
kiev:/ # cd system/media
cd system/media
/system/bin/sh: cd: /system/media: No such file or directory
2|kiev:/ # cd /system
cd /system
kiev:/system # cd /media
cd /media
/system/bin/sh: cd: /media: No such file or directory
2|kiev:/system # cd media
cd media
/system/bin/sh: cd: /system/media: No such file or directory
On stock, it is located at /system/product/media

Categories

Resources