[Q] How to rebuild partition table of YP-G70 - General Questions and Answers

Hi xda-developers.
I've a Galaxy S Player 5.0 (YP-G70) and I have the following situation:
The device uses MMC partition table, and the internal storage partitions are listed as /dev/block/mmcblk0p*, external SD -> /dev/block/mmcblk1p*. I got my partition table deleted by accident, so my device doesn't boot.
I tried to repartition with Odin using the right PIT file but it didn't work. So I compiled my own kernel with stock initrd, activating unsecure mode, adb and busybox in order to manually repartition my internal storage. Now it boots into recovery mode and I can do some things with adb (push, pull), but when I try 'adb shell', I get the following error:
Code:
- exec '/system/bin/sh' failed: No such file or directory (2) -
Obiously, I put the file in /system/bin/sh in the ramdisk with +x permissions. Even I can pull the file doing 'adb pull /system/bin/sh'. I compiled a modified adbd so it can use /sbin/sh and got the same result.
Code:
- exec '/sbin/sh' failed: No such file or directory (2) -
So for now I can't get into shell to manually repartition my device.
I tried other things:
Code:
adb pull /dev/block
pull: building file list...
skipping special file 'loop7'
skipping special file 'loop6'
skipping special file 'loop5'
skipping special file 'loop4'
skipping special file 'loop3'
skipping special file 'loop2'
skipping special file 'loop1'
skipping special file 'loop0'
skipping special file 'ram15'
skipping special file 'ram14'
skipping special file 'ram13'
skipping special file 'ram12'
skipping special file 'ram11'
skipping special file 'ram10'
skipping special file 'ram9'
skipping special file 'ram8'
skipping special file 'ram7'
skipping special file 'ram6'
skipping special file 'ram5'
skipping special file 'ram4'
skipping special file 'ram3'
skipping special file 'ram2'
skipping special file 'ram1'
skipping special file 'ram0'
skipping special file 'mmcblk0'
By reading the output I know it detects internal storage but it doesn't have any partitions, only mmcblk0.
Also, I got a full dd dump from another device and tried to push it via adb, it didn't work.
I'm running out of ideas. Maybe someone can help me to create a working initrd in which I can get into console or has another idea to rebuild my partition table.
Thanks in advance!

Related

ROOT without adb driver?

everthing I read refers to load adb driver.
what do you do if you dont have the driver?
adb drivers == nothing found
any attempt with adb
error: device not found
trying to root Audiosonic 7"
every program refers to loading the adb driver no adb driver to load
I've rooted other devices the easy way, someone advises howto
I WOULD like to learn how to root the device, without a know adb driver.
can someone point me to the RIGHT information to read or do please
android 4.0.4
Kernal version :
3.0.36 +
[email protected] #76
Build number :
RK292X_ANDROID4.0.4-SDK-v1.00.00
rk2926sdk-eng 4.0.4 IMM760 20121215.042649 release-keys
There is a way to make your device compatible with adb, even if you can't find driver for it. Below is how I made my old Creative Ziio compatible with adb:
- download and install Google USB driver
- open file android_winusb.inf from the driver's directory. Find section [Google.NTx86] (if you have 32-bit Windows) or [Google.NTamd64] (for 64-bit). At the end of the section, add the following lines:
; Creative Ziio 7"
%SingleAdbInterface% = USB_Install, USB\VID_2350&PID_0102
%CompositeAdbInterface% = USB_Install, USB\VID_2350&PID_0102&MI_01
- find the device in Device Manager and update driver using previously installed USB driver
- add the folowing line to %HOME/.android/adb_usb.ini:
0x2350
- restart adb server
You can get vid&pid from the DeviceManager.
knutson said:
There is a way to make your device compatible with adb, even if you can't find driver for it. Below is how I made my old Creative Ziio compatible with adb:
- download and install Google USB driver
- open file android_winusb.inf from the driver's directory. Find section [Google.NTx86] (if you have 32-bit Windows) or [Google.NTamd64] (for 64-bit). At the end of the section, add the following lines:
; Creative Ziio 7"
%SingleAdbInterface% = USB_Install, USB\VID_2350&PID_0102
%CompositeAdbInterface% = USB_Install, USB\VID_2350&PID_0102&MI_01
- find the device in Device Manager and update driver using previously installed USB driver
- add the folowing line to %HOME/.android/adb_usb.ini:
0x2350
- restart adb server
You can get vid&pid from the DeviceManager.
Click to expand...
Click to collapse
Very informative post. That's what we like to see
well the audiosonic in normal mode shows up as T-07B in recovery it shows as rk2928sdk
added the vid/pid I got from each (different)
unmerged/merged
nomal mode adb devices finds nothing
recovery mode adb devices finds 0123456789ABCDEF RECOVERY
tried adb shell in recovery and got exec '/system/bin/sh' folder or file not found
ok need a break and try attacking this again
singleadbinterface
compositeinterface
best to use both? 1? looking through android_winusb.ini seem like a mixed bag some both, one etc
Yes, both singleadbinterface and compositeinterface are needed. Also do not forget to modify adb_usb.ini.
Also, make sure that USB debugging is enabled on your device, note that this option should be changed only when device is disconnected from USB.
To check that adb is working,try to install something with
adb install ./some_application.apk
knutson said:
Yes, both singleadbinterface and compositeinterface are needed. Also do not forget to modify adb_usb.ini.
Also, make sure that USB debugging is enabled on your device, note that this option should be changed only when device is disconnected from USB.
To check that adb is working,try to install something with
adb install ./some_application.apk
Click to expand...
Click to collapse
so, just to be specific, and not presuming
to root the device I should be in normal mode or recovery? (last 2 roots I did was in normal mode but they where design root methods)
if normal mode, how can you install if the device not found (which device)
device set and confirmed in debugging mode
thanks for the help, even just confirming things for me
just to advised
I tried installing an app
in normal mode error device not found---- waiting on device
in recovery mode seemd to load but got exec '/system/bin/sh' folder or file not found (interestingly enough, got twice)
so either still a driver problem or need to solve the error (god i've been at this for a few days now)
wolfbite.aus said:
just to advised
I tried installing an app
in normal mode error device not found---- waiting on device
in recovery mode seemd to load but got exec '/system/bin/sh' folder or file not found (interestingly enough, got twice)
so either still a driver problem or need to solve the error (god i've been at this for a few days now)
Click to expand...
Click to collapse
Are you mounting /system partition with ADB prior to trying to push files to the partition?
cant mount /system
# adb shell
- exec '/system/bin/sh' failed: No such file or directory (2) -
is there a sh file somewhere I can push and try???
but adb pull /system gave me bin/busybox
adb pull /data gave me
But each clue you give me gives new ideas (mount got me looking into push/pull
seems I can
adb push so found a su and did adb push /system/bin/su
seemed to work
# adb push su /system/bin/
4576 KB/s (91980 bytes in 0.019s)
then tried
# adb pull /system/
pull: building file list...
pull: /system/bin/busybox -> ./bin/busybox
pull: /system/bin/su -> ./bin/su
2 files pulled. 0 files skipped.
2443 KB/s (1899036 bytes in 0.758s)
adb pull /
pull: building file list...
skipping special file 'rknand_sys_storage'
skipping special file 'ppp'
skipping special file 'network_throughput'
skipping special file 'network_latency'
skipping special file 'cpu_dma_latency'
skipping special file 'rk29-ipp'
skipping special file 'xt_qtaguid'
skipping special file 'galcore'
skipping special file 'binder'
skipping special file 'device-mapper'
skipping special file 'i2c-dev'
skipping special file 'alarm'
skipping special file 'uinput'
skipping special file 'keychord'
skipping special file 'usb_accessory'
skipping special file 'mtp_usb'
skipping special file 'android_adb'
skipping special file 'pmem'
skipping special file 'ion'
skipping special file 'fuse'
skipping special file 'ashmem'
skipping special file 'verifyid'
skipping special file 'vcsa1'
skipping special file 'vcs1'
skipping special file 'vcsa'
skipping special file 'vcs'
skipping special file 'ptmx'
skipping special file 'tty63'
skipping special file 'tty62'
skipping special file 'tty61'
skipping special file 'tty60'
skipping special file 'tty59'
skipping special file 'tty58'
skipping special file 'tty57'
skipping special file 'tty56'
skipping special file 'tty55'
skipping special file 'tty54'
skipping special file 'tty53'
skipping special file 'tty52'
skipping special file 'tty51'
skipping special file 'tty50'
skipping special file 'tty49'
skipping special file 'tty48'
skipping special file 'tty47'
skipping special file 'tty46'
skipping special file 'tty45'
skipping special file 'tty44'
skipping special file 'tty43'
skipping special file 'tty42'
skipping special file 'tty41'
skipping special file 'tty40'
skipping special file 'tty39'
skipping special file 'tty38'
skipping special file 'tty37'
skipping special file 'tty36'
skipping special file 'tty35'
skipping special file 'tty34'
skipping special file 'tty33'
skipping special file 'tty32'
skipping special file 'tty31'
skipping special file 'tty30'
skipping special file 'tty29'
skipping special file 'tty28'
skipping special file 'tty27'
skipping special file 'tty26'
skipping special file 'tty25'
skipping special file 'tty24'
skipping special file 'tty23'
skipping special file 'tty22'
skipping special file 'tty21'
skipping special file 'tty20'
skipping special file 'tty19'
skipping special file 'tty18'
skipping special file 'tty17'
skipping special file 'tty16'
skipping special file 'tty15'
skipping special file 'tty14'
skipping special file 'tty13'
skipping special file 'tty12'
skipping special file 'tty11'
skipping special file 'tty10'
skipping special file 'tty9'
skipping special file 'tty8'
skipping special file 'tty7'
skipping special file 'tty6'
skipping special file 'tty5'
skipping special file 'tty4'
skipping special file 'tty3'
skipping special file 'tty2'
skipping special file 'tty1'
skipping special file 'tty0'
skipping special file 'console'
skipping special file 'tty'
skipping special file 'kmsg'
skipping special file 'urandom'
skipping special file 'random'
skipping special file 'full'
skipping special file 'zero'
skipping special file 'null'
skipping special file 'kmem'
skipping special file 'mem'
skipping special file 'ttyGS3'
skipping special file 'ttyGS2'
skipping special file 'ttyGS1'
skipping special file 'ttyGS0'
skipping special file 'video0'
skipping special file 'rtc0'
skipping special file 'mma8452_daemon'
skipping special file 'ttyS2'
skipping special file 'ttyS0'
skipping special file 'ttyS1'
skipping special file 'property_service'
skipping special file 'event2'
skipping special file 'event0'
skipping special file 'event1'
skipping special file 'fb1'
skipping special file 'fb0'
skipping special file '001'
skipping special file '001'
skipping special file 'timer'
skipping special file 'controlC0'
skipping special file 'pcmC0D0c'
skipping special file 'pcmC0D0p'
skipping special file 'system'
skipping special file 'radio'
skipping special file 'events'
skipping special file 'main'
skipping special file 'mtdblock10'
skipping special file 'mtdblock9'
skipping special file 'mtdblock8'
skipping special file 'mtdblock7'
skipping special file 'mtdblock6'
skipping special file 'mtdblock5'
skipping special file 'mtdblock4'
skipping special file 'mtdblock3'
skipping special file 'mtdblock2'
skipping special file 'mtdblock1'
skipping special file 'mtdblock0'
skipping special file 'loop7'
skipping special file 'loop6'
skipping special file 'loop5'
skipping special file 'loop4'
skipping special file 'loop3'
skipping special file 'loop2'
skipping special file 'loop1'
skipping special file 'loop0'
skipping special file 'mtd10ro'
skipping special file 'mtd10'
skipping special file 'mtd9ro'
skipping special file 'mtd9'
skipping special file 'mtd8ro'
skipping special file 'mtd8'
skipping special file 'mtd7ro'
skipping special file 'mtd7'
skipping special file 'mtd6ro'
skipping special file 'mtd6'
skipping special file 'mtd5ro'
skipping special file 'mtd5'
skipping special file 'mtd4ro'
skipping special file 'mtd4'
skipping special file 'mtd3ro'
skipping special file 'mtd3'
skipping special file 'mtd2ro'
skipping special file 'mtd2'
skipping special file 'mtd1ro'
skipping special file 'mtd1'
skipping special file 'mtd0ro'
skipping special file 'mtd0'
^C
# adb pull /system
pull: building file list...
pull: /system/bin/busybox -> ./bin/busybox
1 file pulled. 0 files skipped.
2736 KB/s (1807056 bytes in 0.644s)
# ls
bin
# ls bin
busybox
adb ls /
still no sh
any ideas?
what about
000081a4 0001e9ff 00000000 rk29xxnand_ko.ko.3.0.8+
000081a4 0001e995 00000000 rk29xxnand_ko.ko.2.6.32.27
# adb ls /
000041ed 00000000 51470583 .
000041ed 00000000 51470583 ..
000041ed 00000000 51470583 cache
000041ed 00000000 51470583 mnt
000081a4 000006f9 00000000 ueventd.rk29board.rc
000081a4 00000f71 00000000 ueventd.rc
000081a4 00000110 00000000 ueventd.goldfish.rc
000041ed 00000000 51470585 tmp
000041ed 00000000 00000000 system
000041ed 00000000 51470583 sys
000041e8 00000000 00000000 sbin
000081a4 0001e9ff 00000000 rk29xxnand_ko.ko.3.0.8+
000081a4 0001e995 00000000 rk29xxnand_ko.ko.2.6.32.27
000041ed 00000000 00000000 res
0000416d 00000000 00000000 proc
000081e8 00000626 00000000 init.rc
000081e8 000191ac 00000000 init
000041ed 00000000 00000000 etc
000081a4 00000908 00000000 default.prop
000041ed 00000000 51470d4e data
000081e8 0003abe4 00000000 charger
000041c0 00000000 4fd5637e root
000041ed 000009b0 51470585 dev
# adb ls /sys
000041ed 00000000 51470583 .
000041ed 00000000 51470583 ..
000041ed 00000000 514718d3 fs
000041ed 00000000 51470583 devices
000041ed 00000000 514718d3 dev
000041ed 00000000 514718d3 bus
000041ed 00000000 51470583 class
000041ed 00000000 514718d3 firmware
000041ed 00000000 514718d3 kernel
000041ed 00000000 514718d3 power
000041ed 00000000 514718d3 module
000041ed 00000000 51470583 block
000041ed 00000000 514718d3 android_gsensor
000041ed 00000000 514718d3 sd-sdio
# adb ls /sbin
000041e8 00000000 00000000 .
000041ed 00000000 51470583 ..
0000a1ff 00000007 00000000 ueventd
000081e8 0001dd74 00000000 resize2fs
000081e8 00046330 00000000 recovery
000081e8 0002da68 00000000 mke2fs
000081e8 00012700 00000000 mkdosfs
000081e8 0004345c 00000000 e2fsck
000081e8 00022d40 00000000 adbd
.s
tried copying over the sh from second android
pushed to 1st android
# adb ls /system/bin/
000041ed 00000000 514722b2 .
000041ed 00000000 00000000 ..
000081ff 00025744 514721d6 sh
000081b6 0001674c 4ffd3b72 su
000081ed 001b92d0 00000000 busybox
# adb shell
- exec '/system/bin/sh' failed: No such file or directory (2) -
still fails
wonder if file permission thing, if so howto chage without shell capability
# adb root
adbd is already running as root
wolfbite.aus said:
tried copying over the sh from second android
pushed to 1st android
# adb ls /system/bin/
000041ed 00000000 514722b2 .
000041ed 00000000 00000000 ..
000081ff 00025744 514721d6 sh
000081b6 0001674c 4ffd3b72 su
000081ed 001b92d0 00000000 busybox
# adb shell
- exec '/system/bin/sh' failed: No such file or directory (2) -
still fails
wonder if file permission thing, if so howto chage without shell capability
# adb root
adbd is already running as root
Click to expand...
Click to collapse
As for the sh script, there isn't one that I know of. Sorry.
You must also apply file permissions with chmod for each file that you push to the device. Most file permissions are going to be 0644 or 0755.
All the Linux commands you are using are actually symlinked to busybox in your /system/bin folder. I would recommend updating your busybox installation while you are in the process of rooting with this method.
You should also update the SuperUser.apk in /system/app since you updated/replaced the su binary in /system/bin. A wise precautionary measure is to also install a copy of the su binary in /system/xbin.
the adb command seems to work push, pull, /
adb shell still gives me
- exec '/system/bin/sh' failed: No such file or directory (2) -
tried pushing busybox (succesful)
but getting same error with shell
how do you apply chmod without shell?
can you break down what the hexidecimal values mean (tried searching)
# adb ls /system/bin/
000041ed 00000000 514722b2 .
000041ed 00000000 00000000 ..
000081ff 00025744 514721d6 sh
000081b6 0001674c 4ffd3b72 su
000081ed 001b92d0 00000000 busybox
tried setting file permissions befor pushing, didnt work
tried upgrading img but got signature verification errors no matter what I through at it
(not worried about bricking this one, slight kid damaged screen and another to use for final results
theres probably mor i can do with adb but its learn as we go
wolfbite.aus said:
the adb command seems to work push, pull, /
adb shell still gives me
- exec '/system/bin/sh' failed: No such file or directory (2) -
tried pushing busybox (succesful)
but getting same error with shell
how do you apply chmod without shell?
can you break down what the hexidecimal values mean (tried searching)
# adb ls /system/bin/
000041ed 00000000 514722b2 .
000041ed 00000000 00000000 ..
000081ff 00025744 514721d6 sh
000081b6 0001674c 4ffd3b72 su
000081ed 001b92d0 00000000 busybox
tried setting file permissions befor pushing, didnt work
tried upgrading img but got signature verification errors no matter what I through at it
(not worried about bricking this one, slight kid damaged screen and another to use for final results
theres probably mor i can do with adb but its learn as we go
Click to expand...
Click to collapse
Permissions must be set after pushing to the device.
guess thats it then
if I cant get a shell, then nothing else to do
[Failed] ROOT without adb driver?
close thread
useful post
but afraid of the codes
What i Did
I took the google usb driver, then downloaded the (supposed) usb drivers from my manufactuer. The maker of my phone, totally screwed up their usb drivers, they didn't have the right vid/pid 's for it( checked the drivers in a linux distro) . Opened the manufactuer's driver, changed the vid/pid's to what was supposed to be there, in it, and the google driver too. Opened the device manager(windows) and ran the "have disk" option, to get the right recognition, and all of the (ADB interface, Bootloader Interface, Composite..) intalled correctly.SDK, eclipse, QtAdb, run great, the only problem is not recognizing what bootloader is in phone( it's locked). I think you're doing a little too much, for your problem.
wolfbite.aus said:
guess thats it then
if I cant get a shell, then nothing else to do
Click to expand...
Click to collapse
hang in there brah i rooted my 2 days ago. i got the a/sonic 10.1 rk2928 chip
how i did it? hrmm i downloaded the rk29 root tool its some where on xda forums. find it.! once i plugged the usb cable into my tablet from pc all drivers installed only one didn't that one t-22b i think. so i used my samsung s2 drivers that was already installed. and walla! adb started working the rest i left for the root kit runme.bat hope that helped good luck!

[Q] cannot supercid and lost mmcblk0p4 file

i did super cid using supercid.sh file in mac to my HTC one XL/at&t
and i got this error
please help me..
mkdir: tmp: File exists
./supercid.sh: line 43: ./adb: cannot execute binary file
./supercid.sh: line 44: ./adb: cannot execute binary file
Copying your misc partition to your sdcard partition...
./supercid.sh: line 47: ./adb: cannot execute binary file
Making a backup copy of the file, just in case...
./supercid.sh: line 50: ./adb: cannot execute binary file
Copying the file to your computer so we can work with it...
./supercid.sh: line 53: ./adb: cannot execute binary file
Making a backup copy here too...
cp: tmp/mmcblk0p4: No such file or directory
Converting the image file to text...
xxd: tmp/mmcblk0p4: No such file or directory
Checking to see what your CID is now...
grep: tmp/mmcblk0p4.txt: No such file or directory
grep: tmp/mmcblk0p4.txt: No such file or directory
grep: tmp/mmcblk0p4.txt: No such file or directory
We don't recognize your current CID.
You need to provide more information. What are your bootloader details? Are you perm rooted? What tutorial were you following? What commands came before the text you have posted here? What do you mean by you've lost the file?
PS. You've posted this in the General Section, I'll ask for it to be moved to the Q&A Section for you.
Sent from my Evita

Unable to install any Rom , /system: No such file or directory

So I tried to install LineageOS on my Honor 8. I unblocked the Bootloader and I am currently able to get into TWRP and Fastboot Mode. I did change the filesystem for the cache system and data as described in this video: w w w. youtube.com /watch?v=X7yDPszoQ5s to enable the encrypted folders.
When I try to install any ROM I am getting the following Errors in red:
E: unknown command (log)
Updater process ended with ERROR: 7
Error installing zip file 'romname'
Also:
Skipping MD5 check: no MD5 file found
could not detect filesystem for /dev/block/bootdevice/by-name/system at /system: No such file or directory
unmount of /system failed; no such volume
patching system image uncoditionally...
E1001: Failed to update system image.

CONVERSION CWM/TWRP backup-files to .IMG files (for Bootloader>FlashBoot Flash) ?

Hello all,
My Chinese notwellknown phone model does not have TWRP, but I have made live TWRP/CWM (yes both) backup files:
system.ext4.win (TWRP) and its md5
system.ext4.tar and (CWM) and its md5.
If one day, I have a bootloop and want to restore those file via Bootloader: (Power button & Vol-)
then: fastboot -S 130M flash system system.img
So how do I create a "system.img" from one of the files above (system.ext4.win or system.ext4.tar) ?
A) Before someone sidetrack the topic, I have done MANY TIMES SUCCESSFULLY the command: fastboot -S 130M flash system "stock-system-file.img" with this phone ( .img extracted from stock zip/tar). (* 1)
B) I didn't ask: "Is there other way to restore ?" I asked: How to convert *.ext4.win (twrp) or *.ext4.tar (cwm) files to .img files just like the ones uncompressed from a stock zip/tar.
(*1) Of course there are other ways to restore, like temporarily fastboot boot twrp.img then restore from there or from twrp>adb. But that's not what the question is asking.
........... Thank you everyone ...........
sintoo said:
Hello all,
My Chinese notwellknown phone model does not have TWRP, but I have made live TWRP/CWM (yes both) backup files:
system.ext4.win (TWRP) and its md5
system.ext4.tar and (CWM) and its md5.
If one day, I have a bootloop and want to restore those file via Bootloader: (Power button & Vol-)
then: fastboot -S 130M flash system system.img
So how do I create a "system.img" from one of the files above (system.ext4.win or system.ext4.tar) ?
A) Before someone sidetrack the topic, I have done MANY TIMES SUCCESSFULLY the command: fastboot -S 130M flash system "stock-system-file.img" with this phone ( .img extracted from stock zip/tar). (* 1)
B) I didn't ask: "Is there other way to restore ?" I asked: How to convert *.ext4.win (twrp) or *.ext4.tar (cwm) files to .img files just like the ones uncompressed from a stock zip/tar.
(*1) Of course there are other ways to restore, like temporarily fastboot boot twrp.img then restore from there or from twrp>adb. But that's not what the question is asking.
........... Thank you everyone ...........
Click to expand...
Click to collapse
Here is a thread for converting TWRP/CWM backups into a flashable zip. I know you aren't looking for how to create a flashable zip but the guide instructs how to extract the system.ext4.win and system.ext4.tar to get the system.img from the backup, this is the part that you need.
https://forum.xda-developers.com/showthread.php?t=2746044
Sent from my SM-S767VL using Tapatalk
first, system.img usually can be downloaded somewhere, no need to restore twrp backup for system. don't you think you will find a download? second, if you restore system you may required to restore vendor and boot too. boot.emmc.win can be flashed from fastboot directly, but for vendor you need to convert. the same way. third, system.img can have different formats. you need to know which file system type, partition size, and if it is sparsed image or not. file system type is EXT4 in your case because twrp backup is named system.ext4.win
for "converting" the system.ext4.win* file(s) into system.img you do it in two steps. first you need to create a empty ext4 image file. after the empty disk image is mounted somewhere, you simply unpack the backup files into the mounted disk. so it's not really converting, more like copying.
You need a linux machine for this
so let's begin with partition size
on a working device you can simply check from system or recovery. find the symlink, resolve the symlink for system, get #blocks (=size) for respective block partition, for example mmcblk0p99
for some reason xda blocks code for ls -l (lower case -L there is no space between)
Code:
find /dev/block -name by-name
ls - l /dev/block/platform/bootdevice/by-name
cat /proc/partitions
Note: the above commands need to be run on target android device only. use adb shell or terminal emulator. all other commands below need to be run on host linux pc
if gathering partition size on the device itself is not an option for you, if you have a mediatek chipset you can simply look into scatter file. OTA zip files most likely contain scatter file. if you don't have a scatter file for your ROM version, you can create your own scatter file with WwR MTK
use hex2dec calculator for partition_size: 0x9C800000 = 2625634304 bytes = 2564096 KiB (#blocks)
if you don't have mediatek device i am running out of ideas. you can boot into twrp from fastboot and check, or find a ROM and check the file size hopefully it is not a sparsed image.
Once you know the partition size, now proceed to create a empty file (avoid to do this on fat32 host if size is bigger > 4 GiB)
and format the file to ext4 (or f2fs if needed)
Code:
dd if=/dev/zero of=system.img bs=1 count=0 seek=2625634304
mke2fs -t ext4 system.img
if all went well you can create a mount point on host and mount the empty disk image. the following commands need to be run with root permissions. you can do it from sudo or as root
Code:
mkdir system
sudo -i
cd /home/$SUDO_USER
mount -t ext4 -o loop,rw,noexec,noatime system.img system
you can now unpack the tar files into system. make sure the folder structure remains intact, if the archive contains the folder /system you should unpack to ~ (this will create all files in ~/system) otherwise you need to unpack to ~/system (or cd into ~/system)
for cwm all files need to be concatenated. for twrp do not concatenate each file is a standalone tar archive. if you have android > kitkat 4.4.2+ make sure you use the proper flags for selinux context
Code:
tar --selinux --xattrs --numeric-owner -vxpf system.ext4.win000
tar --selinux --xattrs --numeric-owner -vxpf system.ext4.win001
or
Code:
cat system.ext4.tar000 system.ext4.tar001 | tar --selinux --xattrs --numeric-owner -vxp
the unpacking may produce errors malformed header or something, make sure all files extracted anyway. i have read somewhere better use star instead of tar which can handle twrp files in the right way, unfortunately haven't tested yet
to avoid any problems with permissions you should check/set for system again
Code:
chown -h 1000:1000 system
chmod 0755 system
chcon -h --reference system/bin system
after unpacking just unmount the disk image
Code:
umount system
rmdir system
exit
If you want to create a sparse image you can use the img2simg tool
Code:
sudo apt-get install android-tools-fsutils
img2simg system.img system.smg
This method is just written on the fly especially for your request, everything untested. I really don't know if this file is flashable from fastboot, do it at your own risk!
aIecxs said:
first, system.img usually can be downloaded somewhere, no need to restore twrp backup for system. don't you think you will find a download? second, if you restore system you may required to restore vendor and boot too. boot.emmc.win can be flashed from fastboot directly, but for vendor you need to convert. the same way. third, system.img can have different formats. you need to know which file system type, partition size, and if it is sparsed image or not. file system type is EXT4 in your case because twrp backup is named system.ext4.win
for "converting" the system.ext4.win* file(s) into system.img you do it in two steps. first you need to create a empty ext4 image file. after the empty disk image is mounted somewhere, you simply unpack the backup files into the mounted disk. so it's not really converting, more like copying.
You need a linux machine for this
so let's begin with partition size
on a working device you can simply check from system or recovery. find the symlink, resolve the symlink for system, get #blocks (=size) for respective block partition, for example mmcblk0p99
for some reason xda blocks code for ls -l (lower case -L there is no space between)
Code:
find /dev/block -name by-name
ls - l /dev/block/platform/bootdevice/by-name
cat /proc/partitions
Note: the above commands need to be run on target android device only. use adb shell or terminal emulator. all other commands below need to be run on host linux pc
if gathering partition size on the device itself is not an option for you, if you have a mediatek chipset you can simply look into scatter file. OTA zip files most likely contain scatter file. if you don't have a scatter file for your ROM version, you can create your own scatter file with WwR MTK
use hex2dec calculator for partition_size: 0x9C800000 = 2625634304 bytes = 2564096 KiB (#blocks)
if you don't have mediatek device i am running out of ideas. you can boot into twrp from fastboot and check, or find a ROM and check the file size hopefully it is not a sparsed image.
Once you know the partition size, now proceed to create a empty file (avoid to do this on fat32 host if size is bigger > 4 GiB)
and format the file to ext4 (or f2fs if needed)
Code:
dd if=/dev/zero of=system.img bs=1 count=0 seek=2625634304
mke2fs -t ext4 system.img
if all went well you can create a mount point on host and mount the empty disk image. the following commands need to be run with root permissions. you can do it from sudo or as root
Code:
mkdir system
sudo -i
cd /home/$SUDO_USER
mount -t ext4 -o loop,rw,noexec,noatime system.img system
you can now unpack the tar files into system. make sure the folder structure remains intact, if the archive contains the folder /system you should unpack to ~ (this will create all files in ~/system) otherwise you need to unpack to ~/system (or cd into ~/system)
for cwm all files need to be concatenated. for twrp do not concatenate each file is a standalone tar archive. if you have android > kitkat 4.4.2+ make sure you use the proper flags for selinux context
Code:
tar --selinux --xattrs --numeric-owner -vxpf system.ext4.win000
tar --selinux --xattrs --numeric-owner -vxpf system.ext4.win001
or
Code:
cat system.ext4.tar000 system.ext4.tar001 | tar --selinux --xattrs --numeric-owner -vxp
the unpacking may produce errors malformed header or something, make sure all files extracted anyway. i have read somewhere better use star instead of tar which can handle twrp files in the right way, unfortunately haven't tested yet
to avoid any problems with permissions you should check/set for system again
Code:
chown -h 1000:1000 system
chmod 0755 system
chcon -h --reference system/bin system
after unpacking just unmount the disk image
Code:
umount system
rmdir system
exit
If you want to create a sparse image you can use the img2simg tool
Code:
sudo apt-get install android-tools-fsutils
img2simg system.img system.smg
This method is just written on the fly especially for your request, everything untested. I really don't know if this file is flashable from fastboot, do it at your own risk!
Click to expand...
Click to collapse
Cygwin works as well, it doesn't necessarily "have" to be Linux.
There is a post for using Cygwin as well in the thread that I linked.
More than one way to "skin this cat", so to speak. I'm sure they'll figure it out with the information they've been provided.
Sent from my SM-S767VL using Tapatalk
i don't think so, twrp archive doesn't contain a system.img it only contains folder /system. therefore you can't extract system.img but only the files inside, which have to be extracted in the right way including metadata. the cygwin untar.exe won't handle secontext flag. besides this it is generally bad idea to extract linux files to windows file system. ntfs is case insensitive and not all ascii chars allowed in file names, you will lose all file permissions owner/group and selinux context (except you untar it directly to ext4 image like i said). This might not be important for flashable zip because everything is lost inside a zip anyway (that's why META-INF is needed) but for creating a working ext4 image you must set everything to drw(x)r-(x)r-(x) system system ubject_r:system_file:s0 (i can be wrong always double check for your ROM) things become more complicated when we talking about data.ext4.win or vendor.ext4.win
even if you compile star or gnu tar and all other binaries for windows like mke2fs chcon or so, you won't be able to mount the ext4 disk image r/w in the right way on windows..
anyway thanks for suggesting cygwin, might be a simple alternative for windows freaks. i personally prefer booting live distro from usb stick
aIecxs said:
i don't think so, twrp archive doesn't contain a system.img it only contains folder /system. therefore you can't extract system.img but only the files inside, which have to be extracted in the right way including metadata. the cygwin untar.exe won't handle secontext flag. besides this it is generally bad idea to extract linux files to windows file system. ntfs is case insensitive and not all ascii chars allowed in file names, you will lose all file permissions owner/group and selinux context (except you untar it directly to ext4 image like i said). This might not be important for flashable zip because everything is lost inside a zip anyway (that's why META-INF is needed) but for creating a working ext4 image you must set everything to drw(x)r-(x)r-(x) system system ubject_r:system_file:s0 (i can be wrong always double check for your ROM) things become more complicated when we talking about data.ext4.win or vendor.ext4.win
even if you compile star or gnu tar and all other binaries for windows like mke2fs chcon or so, you won't be able to mount the ext4 disk image r/w in the right way on windows..
anyway thanks for suggesting cygwin, might be a simple alternative for windows freaks. i personally prefer booting live distro from usb stick
Click to expand...
Click to collapse
Yeah, that is true, it should only be the system folder.
Since they must use TWRP/CWM to create the backups, maybe it would have been better to suggest that they should instead, boot into TWRP then connect to adb to use adb shell commands or to use the terminal emulator that is built into TWRP to run a system dump or dd commands to dd a copy of the system.img over to PC.
Or maybe there is a way to mount/run the extracted system folder in terminal then using terminal to dump/dd a .img from that. I don't even know if that is possible(never heard of it, but it's a thought) but it seems to me that if the system.img is what is written to the system partition when flashed and this is what creates the system folder, there "should" be a way to pack the contents of the system folder back into what was originally contained in the system.img. It might miss a few things though, like the kernel for one, the kernel is sometimes part of the system.img but I don't know if that necessarily means that the kernel will be in the system partition/folder when the system.img is flashed. Thus, making it impossible to reverse engineer back into a proper system.img using only the contents of the system folder obtained from a nandroid backup.
A system dump, dd the .img or extract the system.img from the stock firmware file are the way to go, preferably, extracting from the stock firmware file, because that is easier and less risky than using shell, terminal and Linux for the uninitiated.
Sent from my SM-S767VL using Tapatalk
---------- Post added at 03:52 PM ---------- Previous post was at 03:47 PM ----------
aIecxs said:
i don't think so, twrp archive doesn't contain a system.img it only contains folder /system. therefore you can't extract system.img but only the files inside, which have to be extracted in the right way including metadata. the cygwin untar.exe won't handle secontext flag. besides this it is generally bad idea to extract linux files to windows file system. ntfs is case insensitive and not all ascii chars allowed in file names, you will lose all file permissions owner/group and selinux context (except you untar it directly to ext4 image like i said). This might not be important for flashable zip because everything is lost inside a zip anyway (that's why META-INF is needed) but for creating a working ext4 image you must set everything to drw(x)r-(x)r-(x) system system ubject_r:system_file:s0 (i can be wrong always double check for your ROM) things become more complicated when we talking about data.ext4.win or vendor.ext4.win
even if you compile star or gnu tar and all other binaries for windows like mke2fs chcon or so, you won't be able to mount the ext4 disk image r/w in the right way on windows..
anyway thanks for suggesting cygwin, might be a simple alternative for windows freaks. i personally prefer booting live distro from usb stick
Click to expand...
Click to collapse
I use VM, Live USB and dual boot, depending on which system I'm on(I have more than one rig) and depending on what I'm doing. In some cases, using Windows running Linux in VM is handy because some things are easier in Windows and some are easier in Linux, VM allows switching back and forth between Windows and Linux "on the fly" instead of having to move back and forth between two different systems. Another advantage to VM, your actual system is effectively immune to viruses when browsing the web inside the VM, only the OS installed in the VM is vulnerable, if infected, just wipe that OS and reinstall in the VM and you're clean again, your actual system that the VM is running on, never gets effected.
Sent from my SM-S767VL using Tapatalk
yeah i wonder how did create twrp backup without actually having twrp. busybox tar isn't able to do it, at least full tar binary is required. would be better to create backup in desired format from the very beginning. easiest way is adb pull /dev/block/bootdevice/by-name/system system.img (with proper path of course)
aIecxs said:
yeah i wonder how did create twrp backup without actually having twrp. busybox tar isn't able to do it, at least full tar binary is required. would be better to create backup in desired format from the very beginning. easiest way is adb pull /dev/block/bootdevice/by-name/system system.img (with proper path of course)
Click to expand...
Click to collapse
They booted a live temporary session of TWRP without actually flashing it to the recovery partition. I've done the same on an Intel tablet and a couple of RCA tablets. Booting it directly instead of flashing it onto the device doesn't trigger the locked bootloader. The locked bootloader won't allow booting unverified software that has been installed in the device's hardware itself, but it does not block booting unverified software from an external source.
Sent from my SM-S767VL using Tapatalk
After reading other source, someone said the ext4.win are just tar. One only needs to rename them to ext4.win.tar and you uncompress to img.
I guess the truth is more complicated than that because img (from stock, ready to be ODINed/Bootloader Fastboot) are raw images, including zeros. That's the difference.
In the end, if I had to do it again, I would have to dd the whole /mmcblkxxx(system) to a microSD. Yes 16-20Gb takes a much longer time than 2-3Gb (system.ext4.win) but that what <fastboot flash system system.img> requires (raw data and zeros).
sintoo said:
After reading other source, someone said the ext4.win are just tar. One only needs to rename them to ext4.win.tar and you uncompress to img.
Click to expand...
Click to collapse
Thats exactly how it works see post #3
if you add entry with file system type "emmc" in /etc/recovery.fstab TWRP produces flashable disk image system_image.emmc.win* instead of tar archive (which you can probably concatenate into system.img)
Code:
/system_image emmc /dev/block/platform/mtk-msdc.0/by-name/system flags=display="System Image";backup=1;flashimg=1

Patching Adbd Binary

Hi everyone, I'm trying to patch the adbd binary in my phone (rooted and with Android 11) in order to run it as root.
I found out that the binary was located in /apex/com.android.adbd/bin/, which, according to this link, comes from /system/apex/com.android.adbd.apex.
The apex file can be opened like a zip, so I extracted the files and found the apex_payload.img file, which is indeed mounted in /apex/com.android.adbd/.
Now, the problem is that I have to mount the img file in order to patch it, so I tried to do it with the command "mount -t ext4 -o loop apex_payload.img apex_payload" (yes, this folder exists) but I got the error "mount: '/dev/block/loop28'->'apex_payload': Invalid argument", and if I repeat the command the number after loop increases by one every time. I thought that maybe the image file had a read-only lock, like many partitions such as system,vendor,product etc..., and in fact the image has the shared_blocks feature (checked with "tune2fs -l apex_payload.img"), and I tried to remove it with "e2fsck -y -E unshare_blocks apex_payload.img", and this is the output: e2fsck 1.45.4 (23-Sep-2019)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information
apex_payload.img: 38/48 files (2.6% non-contiguous), 1932/1939 blocks
It doesn't return errors, and the exit code is 0, but it doesn't actually remove the read-only lock on the image file (checked again with tune2fs), so now I'm stuck with that problem. Does anyone know how to solve this or if there are other ways to modify an ext4 image?
Thank you very much.
hmmm. im trying to do something similar, but i have a system shell -- you have any luck?

Categories

Resources