[Q] Using ext4_utils tool - Android Q&A, Help & Troubleshooting

I posted my questions in another thread but got no response.
http://forum.xda-developers.com/showthread.php?t=1933541
I am trying to use the ext4_utils tool to unpack the factoryfs.img in order to modify the system files (add su). No luck so far.
I am now back to square one, testing the unpacking (./simg2img) and repacking (./mkuserimg.sh) tools. All I did was to unpack factoryfs.img, mount it in a temp folder, and repacking the mounted image (with no modification) into a new image. Then I repack this into a tar with md5 checksum (apparently ODIN uses checksum to verify the file to be flashed).
First thing I notice is that, the repacked image files is about 8 MB smaller than the original image (remember all I did was unpack, mount and repack using ext4_utils tool, no modification). When I tried to flash the repacked factoryfs.img (packed into TAR) using ODIN, checksum passed and it proceeded to flashing, but flashing failed.
Anyone have any experience with using ext4_utils to unpack factoryfs.img in order to add su / superuser to the system folder in order to make a rooted Samsung ROM? I feel like I have gone as far as a noob modder can go, and I really appreciate help from the veterans.
NOTE: I know I can use Android Kitchen to root and make a custom ROM, but the modified ROM in ZIP format can only be flashed by CWM. There is no CWM in my Galaxy Player (70 Plus Korean version only). I have a copy of Samsung stock TAR firmware, and I am trying to make a rooted ROM in TAR format which can be flashed by ODIN. I tried Heimdall and it seems that my player is not compatible (device detected but gets "usblib error" when I try to flash).

The repacking command is:
./mkuserimg.sh -s ./tempdir new.img ext4 ./temp XXXmb
I adjusted the "XXXmb" to match the size of the unpacked (eg. output,img) file, and the resulting size of the repacked .img file is now similar to the original factoryfs.img file.
Unfortunately, flashing this still failed (either repacked as a TAR file by itself, or replacing the original factoryfs.img and repacking the TAR firmware).

slim_thumb said:
The repacking command is:
./mkuserimg.sh -s ./tempdir new.img ext4 ./temp XXXmb
I adjusted the "XXXmb" to match the size of the unpacked (eg. output,img) file, and the resulting size of the repacked .img file is now similar to the original factoryfs.img file.
Unfortunately, flashing this still failed (either repacked as a TAR file by itself, or replacing the original factoryfs.img and repacking the TAR firmware).
Click to expand...
Click to collapse
Instead of making the *.tar by this command: tar cvf yourfilename.tar yourdirectoryname ; enter into the directory where all the *.img files reside. then use: tar cvf yourfilename.tar system.img factoryfs.img zImage etc etc. Make sure that the *.tar being created; unpacking it will directly provide those files; not a directory where in that directory all those files reside. This solved my problem. I hope it will solve your problem also.

Related

CS918 Unpacking Archive Path Issue SH

Loyal AMLOGIC fanboy here messing around with a CS918 for only the third time . . . .
I am trying to run a shell to unpack an archive, there's a smali file that downloads the archive to /sdcard/Android/data, this part works fine.
The SH should then unpack to the same directory, this part fails.
My question is, does the directory path format require changing depending on your action (even though it's all going to the same place)?
I unpacked the rom's IMG file to see how other scripts are interacting with the filesystem and am seeing the following paths used by different files - but they all go to the same place:
/data/user/0/
/mnt/sdcard/Android/data/
/data/data/
Here is what the .sh file is trying to accomplish:
tar -xf /sdcard/Android/data/settings.tar -C /sdcard/Android/data/
rm /sdcard/Android/data/settings.tar
For the record, this works flawlessly on AMLOGIC using the path:
/storage/emulated/legacy/Android/data
Just incase anyone comes across this via searching:
The correct path is /mnt/sdcard/Android/data/ - but you have to run the batch as root

[solved] Tar.gz Segmentation fault on non-fat partition

This is about command line program.
Since I moved form JB to KK-based Carbon ROM, I can no longer compress files using "tar z", because I get "Segmentation fault" error.
It still works without z parameter (compressing with gzip), but I need those files to be compressed.
I have a strange problem with tar gz compression.
I used to have SD card mounted as a fat32 partition. However, now I changed it so that external sdcard is being mounted under /data/media/0 and is formated to ext4 (or f2fs - makes no difference, because this error happens on either).
In the old setup, I could run
Code:
tar cvzf
on a folder in this partition without any issue.
However, in this new setup if I run it, I get
Code:
tar cvzf
Segmentation fault.
I discovered, that if I remove the z parameter, it proceeds just fine. But he resulting tar file is not gz-compressed and hence unfit to my applications.
I confirmed this behaviour on two different ROMs so far: CarbonRom JB 4.3.1 and CarbonRom KK 4.4.4.
Does anyone have any idea what could be amiss here? Is android unable to tar.gz files on non-fat32 partitions?
Updated details.
I still have no idea what is causing the problem. However, I did find a solution / workaround, which does the same thing:
Instead of directly calling gzip from tar like so:
Code:
tar cvzf
I pipe tar's output to gzip like so:
Code:
tar -cv directory/ | gzip > archive.tar.gz
and the segmentation fault is circumvented.

Help with building and flashing a pre-rooted stock rom.

I've tried multiple methods, but I can't seem to get the pre-rooted ROM to flash properly, however, the completely stock ROM flashes just fine, so I'm wondering what in the heck I'm doing wrong.
Here's what I've done after I add the su binaries and deodexed:
-- make_ext4fs WITH -s
-- make_ext4fs WITHOUT -s
-- make_ext4fs WITHOUT -s THEN img2simg
-- This method
After those, I tried these:
-- tar -H ustar -c sboot.bin cm.bin boot.img recovery.img system.img cache.img modem.bin >> Flash.tar
-- tar cfx Flash.tar sboot.bin cm.bin boot.img recovery.img system.img cache.img modem.bin
-- Using 7zip to add the file to a pre-existing tar
-- Renaming system.img to system.img.ext4 (Didn't fail, but it just hanged at recovery at the top and system.img.ext4 as the last log entry)
However, every time it gets to the system.img, it fails, saying "Complete(Write) operation failed."
Is there any fix to this? Or is my phone not accepting a custom system.img?
I've used both Odin3 v3.10.7 and v1.85
Thanks in advance!

Advice : Porting Indian ROM to Chinese ROM on Samsung Galaxy A8 8000 Model (China)

hi
I purchased a Samsung Galaxy A8 A8000 from China. I did not like its ROM since it lacked Google Apps and other stuff. So i decided to port system apps (apps+priv-app) from an indian rom. I am totall new to ROM stuff and to linux as well but i decided to go with virtual box and learn few things along the way.
For this,
first i extracted indian rom, it contained following
boot.img, cache.img, hidden.img, modem.bin, recovery.img, sboot.bin and system.img
then i extracted chinese rom, it contained different files as below
aboot.mbn, boot.img, cache.img.ext4, hyp.mbn, modem.bin, NON-HLOS.bin, recovery.img, rpm.mbn, sbl1.mbn, sec.dat, system.img.ext4 and tz.mbn
Since i donot want to mess with partitions and modem and other stuff so i decided to port only apps from indian rom and built an odin flashable tar file
For this i navigated various forum, i even dont exactly remember all but i am thankful to all who wrote useful stuff that helped me decide what to do, well most important of these were
http://forum.xda-developers.com/showthread.php?t=1974014
http://forum.xda-developers.com/showthread.php?t=1941239
http://rwilco12.com/forum/showthread.php?tid=92
first of all i converted indian rom system.img to system.raw using following command in linux virtualbox ubuntu 15.04
simg2img indsystem.img indsystem.raw
then i mounted this raw image using this command
mkdir indsystem
mount -o loop indsystem.raw indsystem/
then i converted chinese rom system.img to system.raw using same command as above
simg2img chcsystem.img chcsystem.raw
then i mounted this chinese raw image using this command
mkdir chcsystem
mount -o loop chcsystem.raw chcsystem/
then i created a system_new.img.ext4 file of 3.1GB size with this command
dd if=/dev/zero of=system_new.img.ext4 bs=4k count=775000
then i formated new image with ext4
mkfs.ext4 system_new.img.ext4
then probably i override the file system check and then mounted new ext4 image
tune2fs -c0 -i0 system_new.img.ext4
mkdir system_new
mount -o loop system_new.img.ext4 system_new
here i had a problem, i could not copy files from both indian and raw mounted images to my new ext4 image since i did not have permission to copy to the destination folder. then i made use of superuser access
gksu nautilus /path/to/image/folder
then i had full access and copied chinese rom to my new ext4 image.
cp -v -r -p chcsystem/* system_new/
then i deleted app, priv-app, font, framework, media, etc/permissions/allfiles-starting-with-android.-and-com.-and-allshare_library.xml from ext4 image.
then i manually copied these folders and permission files from indian system raw image file to my new ext4 image file
next i copy /system/lib/libandroid_runtime.so from chinese rom to the system/lib/ directory of indian rom and then deleted lib folder from chinese rom and replaced it with indian rom
then i sync files with "sync" command
then unmounted all partitions.
I then replaced system.img.ext4 file in my original rom with one that i have just made.
Now i need to compile these files back into flashable tar files with md5sum check with
tar -H ustar -c image_1 image_2 > your_odin_package.tar
md5sum -t your_odin_package.tar >> your_odin_package.tar
mv your_odin_package.tar your_odin_package.tar.md5
1. but before i do so I need some advance developer to please help me out and give some confidence as to the approach that i have used. is that correct.
2. Secondly, if someone can tell me tar ball flashing order for my rom since i heard it is important while compiling odin flashable tar file.
aboot.mbn, boot.img, cache.img.ext4, hyp.mbn, modem.bin, NON-HLOS.bin, recovery.img, rpm.mbn, sbl1.mbn, sec.dat, system.img.ext4 and tz.mbn
3. Also Is it possible that i convert system.img.ext4 into flashable odin tar file with above commands and flash only system image with Odin without messing with anyother settings.
Thank you
No one would like to help me out here.
Hi. I plan to do the same for my SM-A7000. did you get your to work?
waqasjeral said:
hi
I purchased a Samsung Galaxy A8 A8000 from China. I did not like its ROM since it lacked Google Apps and other stuff. So i decided to port system apps (apps+priv-app) from an indian rom. I am totall new to ROM stuff and to linux as well but i decided to go with virtual box and learn few things along the way.
For this,
first i extracted indian rom, it contained following
boot.img, cache.img, hidden.img, modem.bin, recovery.img, sboot.bin and system.img
then i extracted chinese rom, it contained different files as below
aboot.mbn, boot.img, cache.img.ext4, hyp.mbn, modem.bin, NON-HLOS.bin, recovery.img, rpm.mbn, sbl1.mbn, sec.dat, system.img.ext4 and tz.mbn
Since i donot want to mess with partitions and modem and other stuff so i decided to port only apps from indian rom and built an odin flashable tar file
For this i navigated various forum, i even dont exactly remember all but i am thankful to all who wrote useful stuff that helped me decide what to do, well most important of these were
http://forum.xda-developers.com/showthread.php?t=1974014
http://forum.xda-developers.com/showthread.php?t=1941239
http://rwilco12.com/forum/showthread.php?tid=92
first of all i converted indian rom system.img to system.raw using following command in linux virtualbox ubuntu 15.04
simg2img indsystem.img indsystem.raw
then i mounted this raw image using this command
mkdir indsystem
mount -o loop indsystem.raw indsystem/
then i converted chinese rom system.img to system.raw using same command as above
simg2img chcsystem.img chcsystem.raw
then i mounted this chinese raw image using this command
mkdir chcsystem
mount -o loop chcsystem.raw chcsystem/
then i created a system_new.img.ext4 file of 3.1GB size with this command
dd if=/dev/zero of=system_new.img.ext4 bs=4k count=775000
then i formated new image with ext4
mkfs.ext4 system_new.img.ext4
then probably i override the file system check and then mounted new ext4 image
tune2fs -c0 -i0 system_new.img.ext4
mkdir system_new
mount -o loop system_new.img.ext4 system_new
here i had a problem, i could not copy files from both indian and raw mounted images to my new ext4 image since i did not have permission to copy to the destination folder. then i made use of superuser access
gksu nautilus /path/to/image/folder
then i had full access and copied chinese rom to my new ext4 image.
cp -v -r -p chcsystem/* system_new/
then i deleted app, priv-app, font, framework, media, etc/permissions/allfiles-starting-with-android.-and-com.-and-allshare_library.xml from ext4 image.
then i manually copied these folders and permission files from indian system raw image file to my new ext4 image file
next i copy /system/lib/libandroid_runtime.so from chinese rom to the system/lib/ directory of indian rom and then deleted lib folder from chinese rom and replaced it with indian rom
then i sync files with "sync" command
then unmounted all partitions.
I then replaced system.img.ext4 file in my original rom with one that i have just made.
Now i need to compile these files back into flashable tar files with md5sum check with
tar -H ustar -c image_1 image_2 > your_odin_package.tar
md5sum -t your_odin_package.tar >> your_odin_package.tar
mv your_odin_package.tar your_odin_package.tar.md5
1. but before i do so I need some advance developer to please help me out and give some confidence as to the approach that i have used. is that correct.
2. Secondly, if someone can tell me tar ball flashing order for my rom since i heard it is important while compiling odin flashable tar file.
aboot.mbn, boot.img, cache.img.ext4, hyp.mbn, modem.bin, NON-HLOS.bin, recovery.img, rpm.mbn, sbl1.mbn, sec.dat, system.img.ext4 and tz.mbn
3. Also Is it possible that i convert system.img.ext4 into flashable odin tar file with above commands and flash only system image with Odin without messing with anyother settings.
Thank you
Click to expand...
Click to collapse
Hi waqasjeral. Have you already ported the Indian rom to the a8000?

system.raw

I followed this tutorial to merge many system_№.img file, to one, but I get a system.raw file. If I rename it to system.img, how can I verify if it can be flashed via fastboot?
The file can be explored with ext2explore
I followed the tutorial on Windows, but I can also switch to Ubuntu.
alessio89g said:
I followed this tutorial to merge many system_№.img file, to one, but I get a system.raw file. If I rename it to system.img, how can I verify if it can be flashed via fastboot?
The file can be explored with ext2explore
I followed the tutorial on Windows, but I can also switch to Ubuntu.
Click to expand...
Click to collapse
On Ubuntu I used the command
Code:
file system.raw
and the output was that the file is in ext4 format.
Executing the same command on a system.img file, extracted from a Google Factory Image, the output was that the file is an Android Sparse Image, so my hope wrote in OP has been annihilated.
After some searches, luckily I found a way to convert an ext4 image in an Android Sparse Image:
Type in Terminal
Code:
img2simg system.raw system.img
(if img2simg isn't installed, the Terminal should prompt to install it)
and executing this time the file command on the output file, the result is Android Sparse Image!
I followed the entire process also for userdata and cache partitions.
But unfortunately, the first part of the process for generating the .raw file works only on Windows for me. I've posted the issue on the related thread (linked in OP), but I don't received any answer yet, so for the moment for merging many .img files in an only one, you need to split the job in Windows and Ubuntu…

Categories

Resources