[Q] Any way to "install" system.img? - Nexus 7 (2013) General

I've been tinkering with building aosp framework and kernel from source. I've got it loaded and running on my N7. I've made some changes to an xml file, and the subsequent build resulted in only a new system.img file being generated. Is there any way to "install" the system.img file without wiping the system area first? Or is "fastboot flash system system.img" the only way to update the system area of the ROM? I don't want to have to use Recovery to install gapps and supersu again if I can avoid it.

Try mounting the .IMG file into a folder you created with
sudo(or su) mount -o loop ~/system.img /path/to/created/folder
It may mount it and you should be able to get what you want out of the file and then just replace the individual files and reboot or flash them by themselves in a .zip.

di11igaf said:
Try mounting the .IMG file into a folder you created with
sudo(or su) mount -o loop ~/system.img /path/to/created/folder
It may mount it and you should be able to get what you want out of the file and then just replace the individual files and reboot or flash them by themselves in a .zip.
Click to expand...
Click to collapse
I tried everything I could think of including specifying all different types of filesystems including iso9660 and nothing recognizes the image. I tried it on my Ubuntu 12.04 machine as well as the tablet, no success, I guess I'll just have to flash it with fastboot.

There is ways to do it. Aosp used to include the necessary tools to do it, but I haven't really cloned aosp source since gingerbread so I can t remember exactly where or if they're still there(if I do some digging I can figure it out but you may already have flashed. I'll still look into it cause it may be of use to others).

Maybe try this in the future
Here's a binary that should work, make it executable first--
http://db.tt/OZnlRJ4L
./simg2img system.img output.img
Then
mkdir systest(make this folder anything you want)
mount -o loop output.img systest(or whatever you made the folder above)
I haven't tested this but I may when I get a chance.

Way cool man, it works. I was able to mount the output IMG without issue. . :good: :good: :good:
Sent from my aosp N7 JSS15Q w/A029 TouchScreen firmware

Related

[UPDATE 22/08/12] ROM Cooking Guide (One Package)

This is how I made ROM, I'll try to write the steps as simple as I can. For advanced users only!
Update 22/08/11:
Revised packaging steps.
Update 13/08/11:
Removed unwanted method for ROM cooking.
Update 04/08/11:
Modified extract and repack ROM guide and added extracting system.rfs guide.
Things you need:
Base firmware
Archiver software (7zip recommended)
Any Linux environment to build ROM or Cygwin
APK Manager to optimize and decompile *.apk files
MagicISO (Optional) if you want to extract system.rfs
And the last thing is... You need enough experience in android world
So, here is the steps to cook a ROM:
Flash your phone with your desired base firmware
Make required modifications
Pull system.rfs from your phone by running this command on adb shell or Terminal Emulator:
Code:
dd if=/dev/stl12 of=/sdcard/system.rfs
Extract any *.tar.md5 files from your base firmware to your working folder with 7zip
Replace the current system.rfs with your modified one
EDIT: Pack your ROM by running this code via terminal or just pack it with 7zip/WinRAR as *.tar
Code:
tar -H ustar -c * >> ROMNAME.tar
change ROMNAME to your desired, well, ROM name.
Here is (yet) useful guide to modify your ROM.
Extract system files on system.rfs to make modding easier:
Extract PDA file (*.tar.md5) files with 7zip
Open system.rfs with MagicISO
To extract it, just drag and drop
NOTE: Never edit your ROM with MagicISO because the file permissions will be ignored, use MagicISO only for extracting files from system.rfs
Deodex, and Zipalign (optimize) your ROM apk files:
Ready to use deodex + root for KPN: http://forum.xda-developers.com/showthread.php?t=1196230
Ready to use deodex + root for KPH and other firmware: http://forum.xda-developers.com/showthread.php?t=1118048
Open APK Manager
To zipalign your apk files, in apk manager folder /place-apk-here-to-batch-optimize put your:
framework-res.apk, twframework-res.apk and all system apk
but not these:
AxT9IME, Calculator, Camera, Email, MMS, Phone, Screen Capture, Settings, Swype, Thinkdroid, Voice search
Choose Choose option 15
Then choose both (zp)
Let it run and done.
Now put back the apk files where they belong in the ROM.
How to put these apk files to my ROM? Copy these files to appropriate locations, such as /system/app to your ROM's /system/app, and etc.
Another handy modification guide:
Unpack and repack boot.img - http://forum.xda-developers.com/showthread.php?t=1173427
Convert firmware filesystem to ext4 - http://forum.xda-developers.com/showthread.php?t=1202049
Overscroll glow for any firmware - http://forum.xda-developers.com/showthread.php?t=1215933"
Give thanks to all dev who made that possible!
If you have more guides to put here, please PM me.
Am I pertamax?
hehe..just kidding.
Nice Info....great share.
I would want the Fla.sh Rom :'(
Thats a gr8 share...Thank you...)
saiftheboss7 said:
I would want the Fla.sh Rom :'(
Click to expand...
Click to collapse
sorry... once again, I'm sorry, I can't continue my ROM
Helpful thread man!
Thanks!
Great job taking your time to make this! Unfortunately, i dont even know the basics but now I know where to check when I do
fla.sh said:
sorry... once again, I'm sorry, I can't continue my ROM
Click to expand...
Click to collapse
Hey!
THX man, nice thread. Very useful!
Just PM to MOD, that they close you previous thread, a bout fla.sh.ROM. Or ppl just waiting it and asking.
CHEERS!
i think the most troublesome problem i encounter is to repack system.rfs. yes it can be mounted in magiciso, but howto repack/compile it back?
an0nym0us_ said:
i think the most troublesome problem i encounter is to repack system.rfs. yes it can be mounted in magiciso, but howto repack/compile it back?
Click to expand...
Click to collapse
Just save it.
didnt work when i just save it. my device got bootloop
an0nym0us_ said:
didnt work when i just save it. my device got bootloop
Click to expand...
Click to collapse
What modification you've added to your ROM? Maybe that modification causing the problem...
fla.sh said:
What modification you've added to your ROM? Maybe that modification causing the problem...
Click to expand...
Click to collapse
As Linux, MagicISO read RFS image as a FAT filesystem. File permissions can not be maintained. A better way but need linux:
1. Mount system.rfs as FAT and mount it to /tmp/rfs
2. Make ext4 image, and mount it to /tmp/system
3. Copy /tmp/rfs contents to /tmp/system
4. Make modification inside /tmp/system
5. Fix file permissions inside /tmp/system
6. Umount both image
7. Make ODIN flashable image, contains system.rfs (now in ext4 format) and CF-Root-S5830 boot and recovery image (for ext4 support)
8. Boot to Windows and flash your new firmware using ODIN.
ketut.kumajaya said:
As Linux, MagicISO read RFS image as a FAT filesystem. File permissions can not be maintained. A better way but need linux:
1. Mount system.rfs as FAT and mount it to /tmp/rfs
2. Make ext4 image, and mount it to /tmp/system
3. Copy /tmp/rfs contents to /tmp/system
4. Make modification inside /tmp/system
5. Fix file permissions inside /tmp/system
6. Umount both image
7. Make ODIN flashable image, contains system.rfs (now in ext4 format) and CF-Root-S5830 boot and recovery image (for ext4 support)
8. Boot to Windows and flash your new firmware using ODIN.
Click to expand...
Click to collapse
I use this command to mount rfs:
Code:
mount -o loop system.rfs /some_dir
Can you share us the command?
now thats really informative. thanks
ROM unpacking and repacking gude has been corrected. Tested by me. If you have any problems, just ask here.
Thanks.
I think you should add the date of update in the title, so that everyone can know about the update...
BTW thanks for this amazing guide...
Love it!!!
After making changes to system.rfs, how to save it as .rfs again?
adiles said:
After making changes to system.rfs, how to save it as .rfs again?
Click to expand...
Click to collapse
Please take look at the first page, it's updated, you know?
After I created md5 file and selected it in odin, it says "invalid image type" and "invalid model binary". How to solve that? After that I continued, skipped these errors and flashed, my phone stopped at boot screen with text "Galaxy ACE....". Plz help me

[Q] how to make .img files from existing tablet?

I have a complete setup for the Nexus 7, part of a product we are working on, that I need to easily clone on "virgin" tablets for production. The app requires a rooted OS.
I want to write an installation script using fastboot to unlock the bootloader, erase partitions, then flash them with .img files for each partition (kernel, system, cache, etc.).
How do I extract .img files from my "master" tablet? I have an understanding from some where that these are simple byte-for-byte dumps of the partition -- is this true? As such can I create a .img file by simple doing 'cat blkfile >file.img' where "blkfile" is the appropriate block device for the partition in question?
Or do I need to use 'dd'? Or something else?
I have searched and searched, and can't find an anwer. I've found other answers using some tools to create these files from a build on a PC, but nothing about creating them from an existing tablet.
Thanks in advance!
Use the dd command. You can use it both to dump and write a partition. It's how I install recovery programs like TWRP
Sent from my Nexus 7
You can use dd for the boot partition and recovery partition - they are raw binary blobs. (Don't use dd on other Android devices, esp. those that have MTD flash devices, though - it only works most of the time there)
If you want to use the same fastboot-based scenario that Google uses for factory image sets, then for the system & userdata image files you will need to find out about "sparse ext4 filesystem images"
If you took a raw block-device based dump of any of your tablet ext4 partitions, you could actually take those image files and mount them on any other linux machine (using a loopback mount procedure).
But you will find that if you attempt to do that with the Google factory ".img" files (for system & userdata partitions), they will not mount. It's not a simple matter of a offset superblock, either.
Since these are the formats that the stock recovery expects, I suppose you ought to use those formats if you want to do the "all at once all partitions" fastboot flashing if you plan on using the stock recovery.
Note that there is absolutely nothing that prevents you from unpacking whatever you want from whatever archive format you want - so long as the recovery's busybox supports the archive format correctly - you could use cpio or pax or tar archives for that matter. (The stock recovery's "toolbox" has very little functionality, so this comment applies to custom recoveries, which typically have more robust functionality in their busybox) You will be writing your own scripts to do those things though, typically either in one of two ways:
1.A mount target filesystem partition
1.B do a deep recursive remove at that mountpoint ( rm -rf * )
1.C unpack your archive into same mount point ( tar xf archive.tar, etc)
1.D unmount the mount point
OR
2.A unmount target partition and zero it out (dd if=/dev/zero, flash_erase, etc)
2.B recreate filesystem in partition (mke2fs -t ext4 etc)
2.C mount target filesystem
2.D unpack your archive into the same mount point (tar xf archive, pax, cpio, unyaffs2, etc)
2.E unmount that mountpoint
Even though this post is for the Samsung Galaxy S II, the same thing applies to the factory Nexus 7 images from Google:
http://forum.xda-developers.com/showthread.php?t=1081239
As that thread mentions, the simg2img and mkuserimg.sh programs are part of the Android project.
Here's a Nexus 7 thread where the contributor built the tools for both x86 linux and arm linux
Finally, I should note that because /system is typically mounted read-only, imaging /system from the live OS is no big deal. Trying to do the same thing with /data is an extremely dopey idea, however. Accurate backups are rarely made from live read-write filesystems.
cheers
Thank you so much for all the great information! I hit thanks for both of you.
The link to the nexus 7 thread is what I need... This is for my company, and I need a simple cloning solution that can be performed by a non-technical assembly person. The fastboot install procedure is about as simple as it gets.
Thanks again!

Flashing Now Fails

I've been flashing N7 with no issues as recently as over the weekend. Today I tried to flash a new ROM and it failed. Tried a second, different ROM, same result. Do not know what I did. Any thoughts?
Error log would help greatly.
How do I get/generate the log? Haven't had to do it before.
Thanks,
Paul
The logs= errors displayed on the screen provided by the interface you use to flash the rom (recovery, computer...)
Does this help any?
TWRP V2.4.4.0
Updating partition details
E: Unable to open zip file
Error flashing zop
Updating partition details...
do I need to create a partition? Never get more details despite the tease.
Thanks,
First -
Try and download a different (NEWER) TWRP. Re-flash TWRP. Try again
or
Have you tried completely wiping the device? And pushing a ROM from ADB or using a USB OTG and Memory stick?
I had issues with my nexus becoming VERY unstable. Leading to issues.
I completely, and I mean completely, wiped. To the point that all that device basically had was a recovery, and a bootloader.
I proceeded to flash again, BOOM all fixed up.
Is there a new TWRP?
I did a factory restore after wiping everything thing, if that is what you mean?
It was working as expected last week, don't know what I did to screw it up
Boot recovery try the operation, choose advanced then copy log to sdcard. The paste the log results.
sent via electromagnetic radiation.
ibsk8 said:
Boot recovery try the operation, choose advanced then copy log to sdcard. The paste the log results.
sent via electromagnetic radiation.
Click to expand...
Click to collapse
Did this, and it said it copied but I am unable to locate it. It says 0\media\data But that folder structure doesn't exist, at least according to file expert
Will a complete wipe/restore create a partition?
pmgreen said:
Will a complete wipe/restore create a partition?
Click to expand...
Click to collapse
None of the instructions currently found in this forum alters the partitioning of the N7. Not fastboot & not the custom recovery, either.
You are chasing a red herring I think. That message you see is about the recovery performing a scan to check to see if there is a change in file systems (or partitioning of external devices) ... which might have occurred in preceding (custom recovery) operations, but didn't in this particular case.
pmgreen said:
Does this help any?
TWRP V2.4.4.0
Updating partition details
E: Unable to open zip file
Error flashing zop
Updating partition details...
Click to expand...
Click to collapse
Focus your efforts here; it certainly looks like a first-order problem.
bftb0 said:
None of the instructions currently found in this forum alters the partitioning of the N7. Not fastboot & not the custom recovery, either.
You are chasing a red herring I think. That message you see is about the recovery performing a scan to check to see if there is a change in file systems (or partitioning of external devices) ... which might have occurred in preceding (custom recovery) operations, but didn't in this particular case.
Focus your efforts here; it certainly looks like a first-order problem.
Click to expand...
Click to collapse
Think reinstalling TWRP would help? It was working fine so I'm a bit stumped what changed and why
pmgreen said:
Think reinstalling TWRP would help? It was working fine so I'm a bit stumped what changed and why
Click to expand...
Click to collapse
You can also soft-boot a recovery without actually flashing it, e.g.
Code:
fastboot boot custom-recovery.img
I suppose you could then poke around and see if it is having troubles mounting any of the normal partitions (/data, /system, or /cache). Look in the kernel boot log of the recovery (cat /proc/kmsg or "dmesg") to see if anything looks strange, etc.
There have been a couple of reports from folks who developed problems that looked like eMMC flash media errors - loss of partitions, failure to mount /data, et cetera. At the moment though, your symptoms are very generic and non-specific, as in "it doesn't boot".
I suppose you saw no errors at all reported on the screen during that stock-install-via-fastboot procedure?
bftb0 said:
You can also soft-boot a recovery without actually flashing it, e.g.
Code:
fastboot boot custom-recovery.img
I suppose you could then poke around and see if it is having troubles mounting any of the normal partitions (/data, /system, or /cache). Look in the kernel boot log of the recovery (cat /proc/kmsg or "dmesg") to see if anything looks strange, etc.
There have been a couple of reports from folks who developed problems that looked like eMMC flash media errors - loss of partitions, failure to mount /data, et cetera. At the moment though, your symptoms are very generic and non-specific, as in "it doesn't boot".
I suppose you saw no errors at all reported on the screen during that stock-install-via-fastboot procedure?
Click to expand...
Click to collapse
The only error is that it can't open the zip. I've tried downgraded TWRP, then upgrading back. Tried flashing the existing rom.
Nothing has worked. The N7 is functional, just will not allow me to flash
pmgreen said:
The only error is that it can't open the zip. I've tried downgraded TWRP, then upgrading back. Tried flashing the existing rom.
Nothing has worked. The N7 is functional, just will not allow me to flash
Click to expand...
Click to collapse
Well, if the source material can't be opened, then there is nothing to be flashed.
So maybe it is better to call this a "can't open files" problem instead of a "can't flash" problem.
Are there any special characters in the file name ... or spaces? If so, try renaming the file so the name only contains [a-z], [A-Z], [0-9] plus dash, underscore, and dot.
The other thing that can happen is if you drop a file in /data/media/0 as the root user, it will show up under /sdcard, but can't be read by non-privileged users via the /sdcard/ path. I'm not sure what the exact details are here - much less why this would effect the recovery (as you would expect everything to be running as root there) - but you can detect this problem by using a terminal emulator, and looking for differences in ownership or file permission:
Code:
$ su
# cd /data/media/0
# ls -ld *
use chown and chmod as appropriate to fix files as needed
bftb0 said:
Well, if the source material can't be opened, then there is nothing to be flashed.
So maybe it is better to call this a "can't open files" problem instead of a "can't flash" problem.
Are there any special characters in the file name ... or spaces? If so, try renaming the file so the name only contains [a-z], [A-Z], [0-9] plus dash, underscore, and dot.
The other thing that can happen is if you drop a file in /data/media/0 as the root user, it will show up under /sdcard, but can't be read by non-privileged users via the /sdcard/ path. I'm not sure what the exact details are here - much less why this would effect the recovery (as you would expect everything to be running as root there) - but you can detect this problem by using a terminal emulator, and looking for differences in ownership or file permission:
Code:
$ such
# cd /data/media/0
# ls -ld *
use chown and chmod as appropriate to fix files as needed
Click to expand...
Click to collapse
Thanks bftb, you are correct it's a can't open zip. No error than fail and it can't open the zip. It says updating partition but nothing changes
The file names are from the developers, once of which I recently successfully flashed. Tried coping the log to the SD card, but unable to find /data/media/0. Do I need to recreate a partition?
(FYI there was an auto-correct typo in my prior post - "su" not "such". Derp)
pmgreen said:
Do I need to recreate a partition?
Click to expand...
Click to collapse
No. (There is no way to do that with the tools we have anyway)
Unless what you mean by "recreate" is rebuild/reinitialize a filesystem in a partition - that's a possibility.
You need to try and figure out why you can't read files.
As a workaround, you can put files on a USB key (FAT formatted, not NTFS) and using TWRP access them by putting the USB key on the other end of a OTG cable.
Your posts are a bit vague - I can't even tell if you have tried other ROM files, whether you checked them to see if they are the correct size/checksum, etc.
pmgreen said:
Tried coping the log to the SD card, but ...
Click to expand...
Click to collapse
At this point, your best approach is still to follow the initial advice of 'ibsk8'. Look in the log file for any further details about errors that occurred.
The logs are typically in /cache/recovery/ or (while the custom recovery is running) in /tmp
Use "adb pull" to get the log file to your PC and have a look at it. If you can't find anything obvious in there, then cut-n-paste the file to http://pastebin.com and provide the link to us.
bftb0 said:
At this point, your best approach is still to follow the initial advice of 'ibsk8'. Look in the log file for any further details about errors that occurred.
The logs are typically in /cache/recovery/ or (while the custom recovery is running) in /tmp
Use "adb pull" to get the log file to your PC and have a look at it. If you can't find anything obvious in there, then cut-n-paste the file to http://pastebin.com and provide the link to us.
Click to expand...
Click to collapse
I am not familiar using ADB pull. Tried using a root file manager to access the log but don't see.
Greatly appreciate your help, let me know what other info I should paste.
Thanks,

[MOD][SCRIPT] Get More Storage by Relocating Dalvik Cache!

DISCLAIMER: YOU AGREE TO TAKE FULL RESPONSIBILITY FOR YOUR DEVICE IF YOU PROCEED.
The original thread (http://forum.xda-developers.com/moto-g/general/mod-save-data-space-cache-partition-t2942765) was getting to cluttered up with development and testing so I decided to start a new thread with the "finished" product. The original thread will be renamed to Q&A/Development. We might even ask for the old thread to be closed down. (up to @Bert98, the thread's creator.)
Moto G's internal eMMC card has a ~600Mb partition called /cache, which is not used since the apps' cache is stored in /data, so the latter fills up and the first one stays empty.
Owning a 8Gb model, having 600Mb not available for storage really bugged me, because my phone's memory (/data partition) was always full because it's a 5.7Gb space shared between apps and microSD files.
Now, it may not work for you if:
a) you have A LOT of apps installed.
And by "a lot", I mean more than 90-100 apps, but if you have a 8Gb model, you probably don't
b) you're running ART (this is default in lollipop and newer)
Since ART uses a lot more space than dalvik, the space in the /cache partition probably won't be enough. When I was running ART, it used 1Gb more than dalvik.
Original post by @Bert98
Click to expand...
Click to collapse
This was tested on my moto g 16GB which is running RetailUS_4.4.4 kitkat with CWM recovery. The custom ROM procedure was tested on the same phone but with cm11 Nightly installed.
Prerequisites:
1. You must have "adb root" functioning. If you don't head to this thread: http://forum.xda-developers.com/showthread.php?t=1687590 and there is a free download link at the bottom of the post.
Download and install the apk on your phone. Open up adbd insecure (the new app) and grant it superuser rights PERMANENTLY. Check the box that says "enable insecure binary" and make sure to check the box
that says "enable at boot."
2. You must have a recovery that can accept adb shell commands.
3. Root Access Duh?!
4. A windows machine capable of running batch files.
5. A decent text editor, notepad will work but notepad++ is strongly recommended. (Only needed if you are using STOCK ROM procedure)
Please, please make a nandroid backup before you continue!!!!
Stock ROM procedure:
Read the directions very carefully and then read them again, before continuing.
1. Download the cachemover_v1.3.zip from: LINK REMOVED DUE TO SCRIPT ISSUES.
2. Extract the contents.
3. Connect device to PC and navigate to the extracted folder.
4. Double click/Run the cachemover_Stock.bat
5. Follow the onscreen instructions until you get to the part where it says to edit a file.
6. About halfway through the script it will pull a file called "init.qcom.post_boot.sh" to the folder.
7. Open it with a TEXT editor and navigate to about line 487 (Might be different for 8gb model). Look here for a better understanding: https://www.dropbox.com/s/jr5lyl5s5i2jtpg/where to paste code.PNG?dl=0
8. Start a new line and paste this code in the file: (Refer to the image above for help)
Code:
chmod 655 /cache
chmod 655 /cache/dalvik-cache
chmod 655 /cache/dalvik-cache/*
9. Make sure to save the file in the same folder as the cachemover_Stock.bat
10. Press any key to continue on the script and let it do its thing.
11. It will reboot several times and land you on the home screen/lock screen.
12. If the script hangs after a reboot, you need to unlock the device to reestablish a connection with your computer.
13. There might be one or two force closes but once you close the notifications they will not come back.
Custom ROM procedure:
USE THIS FOR ROMS THAT DO NOT REMOUNT OR CHANGE PERMISSIONS OF /CACHE ON BOOT
1. Download the cachemover_v1.3.zip from: https://www.dropbox.com/s/bzj34g4q1s61ojz/cachemover_v1.3.zip?dl=0
2. Extract the contents.
3. Connect device to PC and navigate to the extracted folder.
4. Double click/Run the cachemover.bat
5. Follow the onscreen instructions.
If anything goes wrong:
Go to recovery, wipe cache, then wipe dalvik-cache and reboot. This should get your device back to how it was.
(If you used STOCK ROM procedure)
The script made a backup of the "init.qcom.post_boot.sh" file to /sdcard/init_backup
You can restore the shell script to /system/etc/ via shell commands or by using a root browser. To restore permissions:
Code:
chmod 740 /system/etc/init.qcom.post_boot.sh
chown root:root /system/etc/init.qcom.post_boot.sh
Custom ROM procedure already has a restore script!
I am currently working on an auto restore script for stock and that will be relased soon, hopefully! :good:
Changelog:
v1.0 - First stable release. Does not work on STOCK ROM.
v1.1 - Added a restore script.
v1.3 - Added support for STOCK ROM. There are still a few bugs.
How it works?!?!
Coming soon...
Huge thanks to @Bert98 and @dd043
Hit the thanks button if it worked! I went through about 50 factory resets, and reflashed the ROM about 25 times, and put about 10 hours of work into this script! Really motivates me for future projects. :laugh:
Thanks for your help man and effort.
I encountered a problem, everything works up until my device boots in CWM to fix permissions, then just sits there doing not alot I don't even see the option in my CWM.
Any ideas? cheers
Sent from my XT1032 using XDA Free mobile app
When it reboots to cwm unplug the cable and replug it, if it hangs just type these commands manually from a command window.
chmod 655 /cache
chmod 655 /cache/dalvik-cache
chmod 655 /cache/dalvik-cache/*
reboot
If this does not work you may ned to go into mounts & storage in the cwm menu and click mount /cache. Then try the commands again.
I'm having some issues on stock.
I thought 0655 fixed everything but no, I can't install any app after moving the dalvik-cache to /cache. I tried chmoding 0777 on the new cache folder, on /cache itself, to no avail.
Code:
E/dexopt cannot open '/data/dalvik-cache/[email protected]' for output
Anyone can confirm it's not only my device? And/or can help find a fix?
Also does someone knows how to execute commands on a particular init step? Real init.rc scripts can do:
Code:
on post-fs-data
mount -o bind /cache/dalvik /data/dalvik-cache
It there was a way to achieve the same from post_boot/init.d we could mount -o bind /cache/dalvik /data/dalvik-cache and all permissions issues would disappear as well as the need for symlink.
You have a typo in the threads title. Just a heads up.
Vuciz said:
You have a typo in the threads title. Just a heads up.
Click to expand...
Click to collapse
Thanks for letting me know!
dd043 said:
I'm having some issues on stock.
I thought 0655 fixed everything but no, I can't install any app after moving the dalvik-cache to /cache. I tried chmoding 0777 on the new cache folder, on /cache itself, to no avail.
Code:
E/dexopt cannot open '/data/dalvik-cache/[email protected]' for output
Anyone can confirm it's not only my device? And/or can help find a fix?
Also does someone knows how to execute commands on a particular init step? Real init.rc scripts can do:
Code:
on post-fs-data
mount -o bind /cache/dalvik /data/dalvik-cache
It there was a way to achieve the same from post_boot/init.d we could mount -o bind /cache/dalvik /data/dalvik-cache and all permissions issues would disappear as well as the need for symlink.
Click to expand...
Click to collapse
Let me try and do that right now... Ill get back to you if it does!
My script works on stock btw... But the mount way seems a bit easier and might cause less errors than my way.
Try it please.
skyguy126 said:
Let me try and do that right now... Ill get back to you if it does!
My script works on stock btw... But the mount way seems a bit easier and might cause less errors than my way.
Try it please.
Click to expand...
Click to collapse
Yes I've tried your script, all went well but the result is the same. The script itself works nicely btw
Applications present before moving cache work perfectly, but I can't install anything new. I suspect it might be my device but before wiping everything I'd prefer feedback from others :fingers-crossed:.
I cannot install new apps as well. The mount command you showed me has the same effect too. I honestly don't know anymore, the sym link did not allow the install of new apps nor did the mount command you sent me. Correct me if I am wrong.
Edit: Going through all the init files on my phone to see which one remounts /cache at boot.
Why does the init.rc get overwritten at boot. Is it because the kernel (boot.img) is the one that copies it over? I have found by changing the perms/locations in this file and init.target.rc you can achieve what this mod is trying to acomplish.
I don't see the mount cache command in CWM strange
I've managed to get back to normal, thanks for everyone's help though, I will keep and eye on the thread
Sent from my XT1032 using XDA Free mobile app
non-windows version?
Thanks for this tool. It's a great idea and our Motos really need it.
However, I have a problem - I do not own a windows license (os x and ubuntu user) and I would prefer not to spend $120 just to use it for this script. Pirating is out of the question for me.
I was wondering if there is any chance of having this script written for linux and/or mac. If impossible, is there a LEGAL way of running windows in a virtual machine? Something like a trial or similar?
If you know how just convert it to shell script for osx and Linux. I give you permission to do this but you may not take credit or rehost your creation.
Ok so I have the kernel extracted and we could modify and flash that, but I believe that it's not really necessary. There are a lot of risks to flashing kernels and I am not willing to take it. So is there a way we can modify dalvik so it creates it's cache in /cache instead.
skyguy126 said:
Why does the init.rc get overwritten at boot. Is it because the kernel (boot.img) is the one that copies it over? I have found by changing the perms/locations in this file and init.target.rc you can achieve what this mod is trying to acomplish.
Click to expand...
Click to collapse
Yes the init.rc is in the boot ramdisk. I don't think it would be worth the trouble to rebuild a boot.img. The moto g is fairly unbrickable but it's quite a lot of work to setup an environment to rebuild an image :/.
Too bad for the mount command, I was sure it was working but maybe I had changed something else and don't quite remember the steps to reproduce
We could possibly implement a shell script toggler for when we need to install new apps, but I'm afraid it'd become annoying fairly quickly: I noticed the issue initially because google play services decided to update itself, failed, and broke all google apps. As far as I know this autoupate can't be disabled.
Thanks for trying!
dd043 said:
Yes the init.rc is in the boot ramdisk. I don't think it would be worth the trouble to rebuild a boot.img. The moto g is fairly unbrickable but it's quite a lot of work to setup an environment to rebuild an image :/.
Too bad for the mount command, I was sure it was working but maybe I had changed something else and don't quite remember the steps to reproduce
We could possibly implement a shell script toggler for when we need to install new apps, but I'm afraid it'd become annoying fairly quickly: I noticed the issue initially because google play services decided to update itself, failed, and broke all google apps. As far as I know this autoupate can't be disabled.
Thanks for trying!
Click to expand...
Click to collapse
How about making a simple apk that toggles this feature. Something like when you click the icon it doesn't even open but gives a little notification of success. Something like that. I myself am not experienced with apks but I can put together a shell script for the apk.
skyguy126 said:
Ok so I have the kernel extracted and we could modify and flash that, but I believe that it's not really necessary. There are a lot of risks to flashing kernels and I am not willing to take it. So is there a way we can modify dalvik so it creates it's cache in /cache instead.
Click to expand...
Click to collapse
Patching dalvik itself sounds promising. It can probably be done with in a batch script with a command line hex editor.
The path is defined in frameworks/base/cmds/installd/installd.h
Code:
#define DALVIK_CACHE_PREFIX "/data/dalvik-cache/"
Not sure if there is another mention in the source tree.
But there's nothing to say we wouldn't face the same issue, the error message in the logcat is pretty generic
dd043 said:
Patching dalvik itself sounds promising. It can probably be done with in a batch script with a command line hex editor.
The path is defined in frameworks/base/cmds/installd/installd.h
Code:
#define DALVIK_CACHE_PREFIX "/data/dalvik-cache/"
Not sure if there is another mention in the source tree.
But there's nothing to say we wouldn't face the same issue, the error message in the logcat is pretty generic
Click to expand...
Click to collapse
Ill try it. I don't mind doing a bunch of resets because I am using my moto g as a test bench anyway. My daily driver is the OnePlus One
dd043 said:
Patching dalvik itself sounds promising. It can probably be done with in a batch script with a command line hex editor.
The path is defined in frameworks/base/cmds/installd/installd.h
Code:
#define DALVIK_CACHE_PREFIX "/data/dalvik-cache/"
Not sure if there is another mention in the source tree.
But there's nothing to say we wouldn't face the same issue, the error message in the logcat is pretty generic
Click to expand...
Click to collapse
EDIT: Unfortunately it didn't work. I don't know if I modified the installd file correctly. The program I used is HxD.
Is there a way we can force dalvik to start after the directories are created. And change dalvik to create it in /cache.

Fire HD8 7th Gen - recovery completely gone

Hello,
Please and thanks in advance for any assistance!
I've successfully rooted my HD8 7th gen fire tablet, thanks to the many helpful posts here. However during some of my failed attempts while using Magisk, TWRP App, etc, I've somehow managed to wipe out my stock Recovery partition/files. I can do normal booting fine and I'm sure that I have root, as confirmed by the # at ADB shell and the Root Checker apps available.
I've tried the following:
-Entered Fastboot mode and tried several commands there: always resulting in a 'the command you input is restricted on locked hw' (So, obviously, my bootloader is locked (but I've overwritten it somehow, so it makes me think that at some point I was able to unlock it and overwrite it?)
-Flashfire, TWRP, Magisk and Flashify apps - successful messages every time I try, but no joy when trying to enter recovery mode (it's possible I'm trying to flash the wrong recovery.img file? - does anyone have it and what is it's size? i searched my tablet for the file and found two: one 17mb and the other 8mb - both "flashed" successfully, but no joy when trying to boot into them)
-adb su commands
-Giving up and doing a full Factory Restore via the GUI - it just tries to reboot to the recovery mode, which doesn't exist, so i can't do anything.
-Giving up and doing a full Factory Restore via Fastboot mode - 'the command you input is restricted on locked hw'
I was so happy I was able to obtain root, but if something gets wonky or I decide to try the much raved about resurrection image, i need to have the recovery boot available if/when everything goes wrong.
Please and thanks again for any advice.
Daveychan said:
Please and thanks again for any advice.
Click to expand...
Click to collapse
It's fairly simple but cumbersome to recreate recovery with root. You need to locate the original install-recovery script for your Rom. You may search in /etc or /system/etc . Most likely though your SuperSu deleted it.
So you download your particular Rom version from amazon, unpack it into a system image via mtk-extractor, mount that system image, and find the files.
You can mount this extracted system.bin either on Linux, or directly on your tablet. Just push it to /sdcard, and do this: https://stackoverflow.com/questions/36448234/how-to-mount-a-loop-device-in-android
Then you run the full install-recovery script which will patch your boot.img into recovery partition.
Alternatively, you can beg someone here to dump their HD8 2017 recovery, and upload the image here. So you can dd it in using root into the appropriate partition.
See, I told you - it's all very simple !
Edit: @dondraper23 - can you help a fellow XDA-er? Just dd your HD8 2017 recovery, and post it here.
Code:
dd if=/dev/block/platform/soc/by-name/recovery of=/sdcard/recovery.img
Then zip it, and post it here.
Thank you very much for the fast reply. Much appreciated!
I’ll give this a try ASAP and post back.
If anyone has the recovery.img for the HD8 Gen7, please do post it.
Thank you again!
Okay, i've spent several hours on this and I need to ask for more help.
I managed to get the system.img file from the Amazon .bin as you described. (I used the MTK Extractor for that. It's 1.57 GB by the way.) Next, I moved the system.img file to my Fire's SD card, then I connected the Fire to my Linux, and mounted the system.img file in Linux so I can see the file directory.
I can now see the install-recovery.sh file, located in the /bin folder of the mounted image, but it's read-only. Even by opening to that path via terminal with SU and trying to chmod 777 the file, it's still locked as read-only.
So, I don't know what to do next. I can't copy the file, and I don't see how to run the file via Fire anyway. (Was I supposed to somehow mount the system.img file via ADB commands and then run it that way? If so, I don't know how to do that.)
Sorry if I've asked something obvious or silly. As before, I appreciate the assistance!
Please and Thanks!
Daveychan said:
Okay, i've spent several hours on this and I need to ask for more help.
I managed to get the system.img file from the Amazon .bin as you described. (I used the MTK Extractor for that. It's 1.57 GB by the way.) Next, I moved the system.img file to my Fire's SD card, then I connected the Fire to my Linux, and mounted the system.img file in Linux so I can see the file directory.
I can now see the install-recovery.sh file, located in the /bin folder of the mounted image, but it's read-only. Even by opening to that path via terminal with SU and trying to chmod 777 the file, it's still locked as read-only.
So, I don't know what to do next. I can't copy the file, and I don't see how to run the file via Fire anyway. (Was I supposed to somehow mount the system.img file via ADB commands and then run it that way? If so, I don't know how to do that.)
Sorry if I've asked something obvious or silly. As before, I appreciate the assistance!
Please and Thanks!
Click to expand...
Click to collapse
Sure, just copy that install-recovery.sh file to your tablet, into /data/local/tmp. There is also another file you will need, it's /system/recovery-from-boot.p . Copy this one to /data/local/tmp as well. Then edit your install recovery script, to point to this /data/local/tmp/recovery-from-boot.p . Then just su, chmod 777 your install recovery script, and run it. It should take your boot, and patch it into recovery using recovery-from-boot.p patch file.
Thank you for the fast reply. But because that sh file its read-only, I can't open it or copy it.
Error when running the script
Hello again,
I managed to get around the read-only problem (opening everything as Superuser in Linux was the trick to making that work, for other noobs who may be following along with my pain here.)
I grabbed those two files as you indicated and followed the instructions. Unfortunately I was met with a ton of error messages. Here they are:
=====================
[email protected]:/data/local/tmp # /data/local/tmp/install-recovery.sh
contents of partition "/dev/block/platform/mtk-msdc.0/by-name/recovery" didn't match EMMC:/dev/block/platform/mtk-msdc.0/by-name/recovery:7022592:38eeb844c578f6bbfb6edf8ddf7ba1112200a25c
file "EMMC:/dev/block/platform/mtk-msdc.0/by-name/recovery:7022592:38eeb844c578f6bbfb6edf8ddf7ba1112200a25c" doesn't have any of expected sha1 sums; checking cache
failed to stat "/cache/saved.file": No such file or directory
failed to load cache file
patch EMMC:/dev/block/platform/mtk-msdc.0/by-name/boot:4720640:9dc6d0ebab0b237a7b2f31ae0fabe026da83cda5: LoadPartitionContents called with bad filename (EMMC:/dev/block/platform/mtk-msdc.0/by-name/recovery)
contents of partition "/dev/block/platform/mtk-msdc.0/by-name/recovery" didn't match EMMC:/dev/block/platform/mtk-msdc.0/by-name/recovery
contents of partition "/dev/block/platform/mtk-msdc.0/by-name/boot" didn't match EMMC:/dev/block/platform/mtk-msdc.0/by-name/boot:4720640:9dc6d0ebab0b237a7b2f31ae0fabe026da83cda5
source file is bad; trying copy
failed to stat "/cache/saved.file": No such file or directory
failed to read copy file
=====================
I'm attaching the two files i pulled from the system.img file - as converted from the .bin file downloaded from Amazon (as above), in case you are still willing to help out and can take a look. (I edited the install-recovery.sh file to the correct path already, so it's not the original anymore.)
MUCH APPRECIATED!
Thank you!
Daveychan said:
Hello,
Please and thanks in advance for any assistance!
I've successfully rooted my HD8 7th gen fire tablet, thanks to the many helpful posts here. However during some of my failed attempts while using Magisk, TWRP App, etc, I've somehow managed to wipe out my stock Recovery partition/files. I can do normal booting fine and I'm sure that I have root, as confirmed by the # at ADB shell and the Root Checker apps available.
I've tried the following:
-Entered Fastboot mode and tried several commands there: always resulting in a 'the command you input is restricted on locked hw' (So, obviously, my bootloader is locked (but I've overwritten it somehow, so it makes me think that at some point I was able to unlock it and overwrite it?)
-Flashfire, TWRP, Magisk and Flashify apps - successful messages every time I try, but no joy when trying to enter recovery mode (it's possible I'm trying to flash the wrong recovery.img file? - does anyone have it and what is it's size? i searched my tablet for the file and found two: one 17mb and the other 8mb - both "flashed" successfully, but no joy when trying to boot into them)
-adb su commands
-Giving up and doing a full Factory Restore via the GUI - it just tries to reboot to the recovery mode, which doesn't exist, so i can't do anything.
-Giving up and doing a full Factory Restore via Fastboot mode - 'the command you input is restricted on locked hw'
I was so happy I was able to obtain root, but if something gets wonky or I decide to try the much raved about resurrection image, i need to have the recovery boot available if/when everything goes wrong.
Please and thanks again for any advice.
Click to expand...
Click to collapse
You shuld try:
-Extract an ota update in a folder
-Run from the folder with the extracted files
Code:
fastboot flash boot boot.img
the recovery is in boot.img, doing this helped me on a similar situation
Thanks to @bibikalka for pointing me to this thread
On the 7th gen fire hd8 TWRP doesn't work yet
t0x1cSH said:
You shuld try:
-Extract an ota update in a folder
-Run from the folder with the extracted files
Code:
fastboot flash boot boot.img
the recovery is in boot.img, doing this helped me on a similar situation
Thanks to @bibikalka for pointing me to this thread
On the 7th gen fire hd8 TWRP doesn't work yet
Click to expand...
Click to collapse
It's not enough to reflash boot.img ! Recovery is created on boot by patching boot.img, but the OP's fire has messed up recovery creation scripts due to SuperSu. So he needs to either re-run the recovery creation script manually - which seems to produce errors, or simply flash a full recovery image - hence my request to extract it from a fire with working recovery.
Hey, I'll pull the recovery off mine tomorrow
NFSP G35 said:
Hey, I'll pull the recovery off mine tomorrow
Click to expand...
Click to collapse
That would be fantastic! Thank you much!
Here you go
Daveychan said:
That would be fantastic! Thank you much!
Click to expand...
Click to collapse
Just FYI, to flash this image file into recovery (assuming you have the recovery image sitting in /sdcard/recovery.img):
Code:
dd if=/sdcard/recovery.img of=/dev/block/platform/mtk-msdc.0/by-name/recovery
bibikalka said:
It's not enough to reflash boot.img ! Recovery is created on boot by patching boot.img, but the OP's fire has messed up recovery creation scripts due to SuperSu. So he needs to either re-run the recovery creation script manually - which seems to produce errors, or simply flash a full recovery image - hence my request to extract it from a fire with working recovery.
Click to expand...
Click to collapse
this is the recovery partition straight from my hd8 2017
but i am very curious about a thing, if you look at booth the boot.img and the recovery partition they contains exactly the same data, in the same structure so why cant he simply flash boot.img?
t0x1cSH said:
this is the recovery partition straight from my hd8 2017
but i am very curious about a thing, if you look at booth the boot.img and the recovery partition they contains exactly the same data, in the same structure so why cant he simply flash boot.img?
Click to expand...
Click to collapse
They do have a lot of similarities, that's why recovery is created by patching boot via a relatively small patch file. But, they are still different! That recovery menu is contained entirely within the recovery image, while the boot image does not do that.
Just to add to this, you don't need to flash the boot.img to use install-recovery.sh.
You can also modify the script to read boot from an img file.
k4y0z said:
Just to add to this, you don't need to flash the boot.img to use install-recovery.sh.
You can also modify the script to read boot from an img file.
Click to expand...
Click to collapse
Do you care to post a script that does that, and writes into a recovery image file? The syntax of that patch command is a bit messy, so I would not mind having a debugged working script
Hello again,
My apologies for the delay, work was busy this week, and I couldn't find the time to check the solution until now.
I'm so VERY HAPPY to report that all worked well, and the recovery.img and the command line you provided worked perfectly. (WOW! Thank you!)
For those who want the details, the message after the command in the terminal was:
==
#dd if=/sdcard/recovery.img of=/dev/block/platform/mtk-msdc.0/by-name/recovery
----
34816+0 records in
34816+0 records out
17825792 bytes transferred in 1.159 secs (15380320 bytes/sec)
==
I then did a full power down, and then a started it up again while holding the top-left Volume key and the Power key, and look at that! I'm sitting at the Amazon system recovery screen again! <insert YAY! here>
I'm not sure if it matters, but I thought I'd mention it. At the bottom of the screen in orange letters, it says:
===
E:Error in /cache/recovery/last_kmsg
(No space left on device)
===
So, after a little bit of searching, I selected "wipe cache partition", rebooted again into recovery, and the error is gone now.
Another normal reboot started the "Optimizing apps..." thingy, but it finished quickly and I can confirm that all my stuff is still there. Just to be sure, I did another reboot to recovery, no error messages this time, and then another regular reboot, with no optimizing.
It appears that everything in my world is good again!
My sincerest gratitude and appreciation to all who helped contribute and support this solution.
THANK YOU VERY MUCH!
Daveychan said:
the much raved about resurrection image .
Click to expand...
Click to collapse
Out of curiosity, what is this? There is an image, other than stock, for the 7th Gen HD8?
Resurrection-remix
xnatex21 said:
Out of curiosity, what is this? There is an image, other than stock, for the 7th Gen HD8?
Click to expand...
Click to collapse
It's a WIP for the HD8 I've read. My friend has this on his HD7 and swears it's twice as fast as the regular.
Here's some info:
https://forum.xda-developers.com/kindle-fire-hd/7-development/rom-resurrection-remix-5-1-x-t3234535
and here:
https://forum.xda-developers.com/le-pro3/development/9-0-resurrection-remix-v7-0-t3894663

Categories

Resources