Hi, I'd like to ask a general question (I suppose) about device boot process. I've made some changes in init.rc and I packed again boot.img. Then I flashed it. So, phone shows logo screen. I've changed boot.img again to enable adb by making changes to default.prop.
So, I've packed boot.img and flashed it again. So, phone shows logo screen and I can use adb during boot process, but I don't know how to use adb to get info about android failed boot (adb has not root permissions, though).
What methods could I follow in these cases? Any ideas?
P.S.
My changes at boot.img: I've moved /system, /usrdata and /cache mount commands into an .sh script in ramdisk root directory.
P.P.S.
I've tried also adb pull last_kmsg and I don't see error messages in the little log (~87 kb). When I look at last_kmsg, I see some lines about phone charging (connected to pc), so I think these messages could be related at the moment which phone is connected to pc but turned off (I'm not sure, though) because last_kmsg is related to previous boot process (charging mode with phone turned off?) and the current one (I think). I'd like to read kmsg and not last_kmsg, however, but kmsg can be read only by root (and my current adb has not root permissions, as I said before).
P.P.P.S.
During the boot process, I can pull directories and files from ramdisk root directory (related to boot partition) into my pc by using adb pull command. I've found that 'dev', 'proc' and 'sys' are very well populated of files and sub-directories. Instead, 'data' and 'system' directories are sadly empty. So, I suppose /usrdata and /system related partitions are not mounted at that moment and such thing prevents to load android system.
Solved
I've found a way to get dmesg without using adb shell. It's possible to use busybox dmesg command inside a shell script (placing busybox binary and shell script into ramdisk root directory of boot.img) and run the script by busybox ash command from init.rc, redirecting the output to a logfile. The command inside shell script should look like as the following:
Code:
/busybox dmesg >> /path/to/my/logfile.txt 2>&1
(That way, stderr and stdout will be redirected to a log file, that can be pulled down by adb pull command)
Related
Hello everyone,
I have a T-Mobile L9 Optimus and I have rooted it according to this guide, it was very helpful
http://forum.xda-developers.com/showthread.php?t=2173465
After removing a bunch of bloatware, I also wanted to remove T-Mobile's Boot and Shutdown animations, which on this phone are located in system/media -> bootanimation.zip and shutdownanimation.zip
I used ADB to pull both files into Windows as a backup
Then, I used ADB to open a shell as su:
adb shell
su
Then I realized I couldn't use the rm command for those zip files because the /system folder is mounted as read-only by default. To change that I used the following commands:
mount -o rw,remount /system
then I used the rm command to remove the two zip files
then I used
mount -o ro,remount /system
to have the folder back in its default read-only state
Then I restarted my phone and voila - no shut-down animation and only a default LG and Android animation on startup
Then I re-started Command prompt to get back to ADB (I still don't know how to exit shell and get back to ADB, help on that?) and here's the problem - I can no longer access root permission in ADB.
When I type in adb root, I get "adbd cannot run as root in production builds"
When I type in adb remount, I get remount failed: Operation not permitted
If I open a shell, I can still enter su, but after the procedures above, ADB thinks that my phone is a production build and I would like to know why, and how I can fix it without returning the original bootanimation.zip and shutdownanimation.zip files.
Is there a background process on T-Mobile phones that goes through a default checklist of system files, then determines that a phone must be a production build if some of those files aren't there? Is there a way to modify that process if it exists? I would rather do that than have to put in a "dummy" bootanimation.zip and shutdownanimation.zip
Lastly, if I were to return those original files through shell, would everything return to normal regarding ADB?
So adb shell and su doesn't work for you now ?
Edit:
I missed a part of your post,
That is a normal behaviour. I don't thing you could adb root before removing animations.
Edit:
If you want to run something from command prompt you have to:
adb shell su -c command_goes_here
Hi, I'd like to ask a general question about device boot. I've made some changes in init.rc and I packed again boot.img. In particular, I've added a .sh script to ramdisk root directory.
The script is named mount_partitions.sh and it does just this task. However, boot.img needs a shell to execute it, but /system is not mounted yet, at that point. So, I need to add a shell to to ramdisk root directory so that init executable can run the .sh script.
Exactly, how I could add shell support in boot.img without mounting the system partition? Any ideas?
Solved
I've found a way to use a shell before mounting system partition. Essentially, it's possible to place a busybox binary (i.e. taken from /system/xbin directory located in another android phone with installed busybox) into ramdisk root directory of boot.img, giving it execute permission in init.rc by chmod command, after remounted ramdisk root directory in read-write mode (by mount command put always in init.rc). It could be also be needed to give execute permission to the shell script (always by chmod command).
Then, it's needed run the shell script by busybox ash command, putting it into init.rc. The line looks like as following:
Code:
exec /busybox ash /myscript.sh
Don't forget to put also a line for remounting ramdisk root directory in read-only mode, after ash shell finished to execute the script (always using mount command in init.rc).
Remember to use the following shebang at the beginning of the shell script:
Code:
#!/busybox sh
shouldn't the shebang end with "ash" instead of just "sh"?
it's just a sh script but it could be true.
Hi, I'd like to ask a general question about device boot. I've made some changes in init.rc and I packed again boot.img. While debugging, I would need to check permissions of some files in ramdisk root directory in order to see if they are accessible for reading and/or execution.
How could I get this info by adb during device boot before that /system partition is mounted? Any ideas?
Solved
I've found a way to perform this task. It's possible to use busybox ls command inside a shell script (placing busybox binary and shell script into ramdisk root directory of boot.img) and run the script by busybox ash command from init.rc, redirecting the output to a logfile. The command inside shell script should look like as the following:
Code:
/busybox ls -l / >> /path/to/my/logfile.txt 2>&1
(That way, stderr and stdout will be redirected to a log file, that can be pulled down by adb pull command)
hello everybody,
well as the title says, i've bricked it. i've had TWRP installed (it doesn't boot past the loading screen now) and working with magisk. all good until i decided to be my ol'dumb self and formatted /system before reflashing and even before that, to enable the OEM unlock. so after attempting a reboot to recovery, it just got stuck at TWRP's logo.
then, i booted into fastboot and the phone displayed the Phone unlocked FRP lock screen. so i couldn't flash AOSP 8.1 because of the OEM unlock thing. then i used DC unlocker in an attempt to get around the OEM lock and after rebooting i can't even put the phone in fastboot. it just goes into the TWRP logo and stays there. can't boot into fastboot through adb either.. i tried sticking UPDATE.APP into a folder called dload in my sdcard and pressing vol+&vol- while booting as i read somewhere but no dice..
i did make a backup with TWRP and if i could get write access to /system i could push the files from the backed up /system, which i've tried (adb push system /) but it's read-only.. so wah-wah.. any way of getting write access? i've tried running su in a shell (adb shell) and i get /sbin/sh: su: not found
edit: funny enough, i'm able to push some files into /system (see below)
Code:
D:\Downloads\_LIUGIGB>adb push --sync system /
adb: warning: skipping empty directory 'system\app\Bluetooth\lib\arm64\'
adb: warning: skipping empty directory 'system\app\BuiltInPrintService\lib\arm64\'
adb: warning: skipping empty directory 'system\app\HwIAware\lib\arm64\'
adb: warning: skipping empty directory 'system\app\HwPowerGenieEngine3\lib\arm\'
adb: warning: skipping empty directory 'system\app\HwPowerGenieEngine3\lib\arm64\'
adb: warning: skipping empty directory 'system\app\HwSoundRecorder\lib\arm64\'
adb: warning: skipping empty directory 'system\app\HwVideoEditor\lib\arm\'
adb: warning: skipping empty directory 'system\app\NfcNci_45\lib\arm64\'
adb: warning: skipping empty directory 'system\app\PacProcessor\lib\arm64\'
adb: warning: skipping empty directory 'system\app\PrintSpooler\lib\arm64\'
adb: warning: skipping empty directory 'system\app\SwiftKey\lib\arm64\'
system\: 4950 files pushed. 1040 files s.... 5.5 MB/s (576383367 bytes in 100.358s)
D:\Downloads\_LIUGIGB>adb shell
~ # su
/sbin/sh: su: not found
~ # cd system
/system # ls
app delapp framework
asr emui lib
bin etc lib64
build.prop fake-libs lost+found
cameraplugins fake-libs64
compatibility_matrix.xml fonts
after pushing the files, the phone still won't go into fastboot, when i run adb reboot fastboot, the phone shuts down and if i press power&vol+ or power&vol- the phone does nothing. also plugging the cable while pressing vol- has the same effect: nothing..
edit2: could the fact that my phone is encrypted be an issue too? (this took me here which took me to edit3)
edit3: i formatted userdata through adb shell (/dev/block/platform/hi_mci.0/by-name # make_ext4fs userdata) TWRP and fastboot are back! went into eRecovery and the stock rom is downloading. i hope this solves the issue..
edit4: after downloading & flashing the stock rom my phone is back to life. i'm not sure where i messed up, but i'm sure i did somewhere along the way.. i'll leave this here, maybe someone will find it handy..
You could explain to me how you did it, I have the same problem. please
[Question][ADB] How to "adb push" with timestamps like "adb pull -a"
Hello, as said in the title of the post, I need to push photos to my phone but with their original timestamps. I backupped my internal storage with the command
Code:
adb pull -a -p /sdcard "PC_directory"
But I need a command to re-transfer everything back to my phone. I'd like to do this, because othewise, all the photos in my gallery will be set to the actual phone's date. Is there a way to do that? Thank you in advance!
Would also like to know if there is a solution to transfer files via adb while preserving timestamps.
You may use dd command to do a 1:1 ( bitwise ) copy of data / files - requires the source data / files are housed in an .IMG-file.
I believe you can achieve it by creating an archive with tar and output it to stdout. Then pipe it to adb exec-in with a tar command to extract it on the phone.
Update: tested it out and it seems that exec-in outputs to a file and you need to create an intermediate archive on the receiving device.