yashsingh1/xdaforums huggingface dataset:
[Miscellaneous Android Development] lebigmac:
I don't get an error when running e2fsck on the file after piping it through my script.
[Miscellaneous Android Development] munjeni:
You need lptools arm64_pie build? Lptools is able to resize e.g. system partition directly on a running android with dynamic partition?
[Miscellaneous Android Development] lebigmac:
Yes it looks like it. Ask the developer @phhusson just to make sure.

Once you figure out that dangerous issue it would make for a great friend for superrepack. Together they would be a great combo!
[Miscellaneous Android Development] munjeni:
I'm getting e2fsck errors while using my tool even without modifying anything. What I doing is repair with e2fsck, than doing unshare blocks with e2fsck, everything went ok without errors, after that I modify single file and repeat checking with e2fsck and getting errors again, that happening I'm pretty sure because of not increasing size of the partition. Definitelly need to learn how this dynamic things working on android, probably not now but when I buy device with dynamic prtition which probably will not happen soon since I not like this definitelly :)
[Miscellaneous Android Development] munjeni:
Anybody tried lptools?
[Miscellaneous Android Development] munjeni:
- version 5 (08.04.2021) implemented resize and repair partitions after switching to rw mode. Implemented build script for building resize2fs, e2fsck, simg2ims, img2simg, lptools

How to use:

-> see first post

Let me know!
[Miscellaneous Android Development] VD171:
Nice tool.

Thank you very much for contribution.
[Miscellaneous Android Development] munjeni:
Version 6 is out
[Miscellaneous Android Development] munjeni:
Version 7 is out! V6 had error detecting slinux status. I do not have device with super partition for test my tool but I have only hope that all is ok. Let me know! :)
[Miscellaneous Android Development] ITGrouch:
I have a Moto G Power and what I would like to know is which version of BusyBox did you install? Thanks!
[Miscellaneous Android Development] munjeni:
Busybox version 1.23.1 (2015-02-07 04:39:23 UTC) , but its not installed, its just helper tool for my tool
[Miscellaneous Android Development] ITGrouch:
Thanks! I will give that a shot.
[Miscellaneous Android Development] ITGrouch:
That fixed the issue. Thanks again!
[Miscellaneous Android Development] munjeni:
You must go to the /data/local/tmp !!! And you must do excatly the same as from tutorial from first post and it will work than!

How to use superrepack:

adb push superrepack.arm64_pie /data/local/tmp

adb shell

cd /data/local/tmp

mv superrepack.arm64_pie superrepack

chmod 755 superrepack

stop

./superrepack /dev/block/bootdevice/by-name/super system_a rw

sync

reboot
[Miscellaneous Android Development] PEACH-PIT:
The moto g 5g is almost the same smartphone as the Motorola One 5G Ace.

I think you have to specify /dev/block/sde26 because super.img does not exist.
[Miscellaneous Android Development] PEACH-PIT:
In the case of moto g 5g, if you specify anything other than "/dev/block/sde26", the program will not start.

If "/dev/block/sde26" is specified, the program will start but will not function.
[Miscellaneous Android Development] munjeni:
sh: ./busybox: inaccessible or not found

Today or tommorow I will try fix isue!
[Miscellaneous Android Development] munjeni:
Updated version 7, let me know!
[Miscellaneous Android Development] deltaquarti:
I had the error "sh: ./busybox: inaccessible or not found" with the previous version. Tried the new one, but it didn't change a lot.
[Miscellaneous Android Development] munjeni:
Sorry guys got it, updated version, hope now all ok
[Miscellaneous Android Development] deltaquarti:
It looks like system_b is RW but there are still errors for the other partitions
[Miscellaneous Android Development] PEACH-PIT:
I tried the new version.

It didn't work.

There is an error.

The r/o was not canceled.

It looked like I could mount it with r/w. But I can't write to it.
[Miscellaneous Android Development] PEACH-PIT:
I tried again.

When I created /dev/loop0, the error disappeared.

Could not write a new empty folder.

I get an error that there is no free space on the device.

Writing, deleting, and renaming files is working.
[Miscellaneous Android Development] munjeni:
Mate forget old versions, its dangerous because it didn't reize p[artitions needed for unsharing blocks than it didn't repair partitions. New version version 7 will work but first when I solve problem with busybox it will be working finally
[Miscellaneous Android Development] munjeni:
It not going to work correctly because your first step (first log) showed that there is unrecognised option:

losetup: unrecognized option '--offset=11270062080'

but thats mandatory and very important! So it failed but made your partitions rw, but since it failed on losetup it also failed to resize, repair and unshare blocks, so you will need to reinstall your rom and wait next version. You can't repeat flashing since your blocks is allready rw but with errors, my tool will not make it rw again and will not do the rest of things because partitions is allready rw. Wait new version! I will try carefully check whats going on with losetup and make version which I'm believing will finally work. I'm realy bussy these days and was so fast programing it with trials and errors since had not much free time for it to make it carefully programed, my hope next version will finaly start working.

Edit:

On short checkup found that losetup tool from busybox and also builtin android have missing needed parameters like --offset and --sizelimit !!! I will need to build compatible losetup tool from util-linux 2.27.1
[Miscellaneous Android Development] PEACH-PIT:
I re-flashed the stock ROM again and rooted it.

I'm back to r/o. I'm going to wait.

But does this mean it will revert to r/o every time I update the ROM?
[Miscellaneous Android Development] munjeni:
You will try that e.g. if it is RO and not allowing you RW than you will need to run our tool
[Miscellaneous Android Development] munjeni:
Version 8 is out!

- version 8 (15.04.2021) fix loop device setup in superrepack

Let me know! :)
[Miscellaneous Android Development] PEACH-PIT:
v8 did not work either.

I got an error message as per the first log.

In this state, I can create, delete, and rename new files.

I cannot create, delete, or rename a new folder.

When I ran it again, the error disappeared.

However, it did not solve any of the problems I encountered.
[Miscellaneous Android Development] munjeni:
Error:

c: /dev/loop9: failed to set up loop device: No such file or directory

Thats crazy! What is c: I realy have no idea, why it is apended to the dev/loop I will need to know.

Can you show me contents of the /data/local/tmp/run.sh and also of the /data/local/tmp/script.log ?

And also can you check that /dev/loop9 exist? Or it need to be /dev/block/loop9 probably?
[Miscellaneous Android Development] PEACH-PIT:
loop* is located in /dev/block.

The location of loop9 is /dev/block.

/dev/loop9 does not exist.

For some reason, loop9 cannot be copied.
[Miscellaneous Android Development] munjeni:
Version 9 is out

- version 9 (16.04.2021) make losetup android compatible

Losetup tool compiled from linux utils use /dev/ path for searching for loop device, its simply by default not designed for android. Now I have made it android compatible, tested it on my device with "losetup -f" and it now print correct path e.g. /dev/block/loop9 , also tried to mount something and I can confirm its ok now, so version 9 I'm realy believing will do the right. Let me know! :)
[Miscellaneous Android Development] PEACH-PIT:
v9 did not work either.

A large number of errors have occurred.

I am attaching the log.

The problem is the same as before.

Cannot add, rename, or delete folders.
[Miscellaneous Android Development] munjeni:
Thanks for your time testing it! Well, losetup is ok now, resize2fs ok too, but e2fsck (the last one to try fix) have trouble, giving error: "Couldn't clone file: Could not allocate block in ext2 filesystem", I will try to investigate it! Can you tell me can you upload your super partition for download? It would be great if I do simulation on my own phone using your super partition

edit:

can you do this commands via adb and see if you getting error lake above?

/data/local/tmp/losetup --offset=1648361472 --sizelimit=2895020032 /dev/block/loop9 /dev/block/sde26
e2fsck -fy /dev/block/loop9
sync
e2fsck -fy -E unshare_blocks /dev/block/loop9
sync
/data/local/tmp/losetup -d /dev/block/loop9

Need to know if problem is my e2fsck or something diferent

Edit:

I'm analysed your log, partition is sucesfully resized to the maximum size, almost 13mb is free space inside resized partition so I do not see reason why we have error: "Couldn't clone file: Could not allocate block in ext2 filesystem" when we have enought free blocks for it, it might be e2fsck isue, so please try commands above trought adb or trought terminal emulator
[Miscellaneous Android Development] munjeni:
I'm just compiled e2fsprogs excatly the same source code used in my tool, definitelly its not a source of problem. This is result:

root@dm920 /media/hdd/sony/rom # ../android_external_e2fsprogs/e2fsck/e2fsck -fy -E unshare_blocks /dev/loop0
e2fsck 1.45.4 (23-Sep-2019)
Pass 1: Checking inodes, blocks, and sizes
Inode 3728 extent tree (at level 2) could be narrower. Optimize? yes

Inode 6180 extent tree (at level 2) could be narrower. Optimize? yes

Inode 6203 extent tree (at level 1) could be narrower. Optimize? yes

Pass 1E: Optimizing extent trees
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/: ***** FILE SYSTEM WAS MODIFIED *****
/: 6478/7168 files (10.0% non-contiguous), 477547/494679 blocks
root@dm920 /media/hdd/sony/rom # ../android_external_e2fsprogs/e2fsck/e2fsck -fy -E unshare_blocks /dev/loop0
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
/: 6478/7168 files (10.0% non-contiguous), 477547/494679 blocks
root@dm920 /media/hdd/sony/rom # ../android_external_e2fsprogs/e2fsck/e2fsck -fy /dev/loop0
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
/: 6478/7168 files (10.0% non-contiguous), 477547/494679 blocks
root@dm920 /media/hdd/sony/rom #

As you can see its clean. I have no idea right now why you getting that error, it might be your kernel related thing. Did you tried @lebigmac script -> https://xdaforums.com/t/script-android-10-universal-mount-system-read-write-r-w.4247311/ ?
[Miscellaneous Android Development] munjeni:
Can you please dump sustem partition this way and upload somewhere?

/data/local/tmp/losetup --offset=1648361472 --sizelimit=2895020032 /dev/block/loop9 /dev/block/sde26
dd if=/dev/block/loop9 of=/data/local/tmp/system.bin conv=notrunc
/data/local/tmp/losetup -d /dev/block/loop9

Give me please /data/local/tmp/system.bin dump file and I will check all the things localy and try find whats going on with it detaily
[Miscellaneous Android Development] PEACH-PIT:
I'll upload it.

I will contact you directly through "Conversations" as soon as the upload is complete.

Uploaded system.bin.

Please check it.
[Miscellaneous Android Development] munjeni:
Hi, I have checked your system dump using excatly the same tools, it succed without any single error, see log! I realy have no idea why it fail on your device, I'm believing thats kernel related thing, did you see something about it inside dmesg? It might be other restrictions enabled on device! Try research about error "Could not allocate block in ext2 filesystem"! It can be that something need to be enabled in proc or sys entries, for idea look here https://01.org/linuxgraphics/gfx-docs/drm/admin-guide/ext4.html
[Miscellaneous Android Development] PEACH-PIT:
Can I just dump the kernel log?

I looked it up but couldn't figure it out.

Unfortunately, I can't get this script to work on my device.
[Miscellaneous Android Development] f1^ter:
The device Xperia 1 II, I can't get the system_a section to write, I attach the log.

The mistake was mine, wrongly pointed out the path!

./superrepack /dev/block/bootdevice/by-name/super system_a rw
./superrepack /dev/block/bootdevice/by-name/super product_a rw

Everything works! Thanks!
[Miscellaneous Android Development] munjeni:
Hi, thanks but unfortunatelly you have the same error as @PEACH-PIT , things is not done right!

clone_file: Could not allocate block in ext2 filesystem returned from clone_file_block

I'm curently without idea since I do not have device with super partition to do the true test. I'm tested things on my local linux machine, I'm used super partition from xperia 1 II rom version XQ-AT51 58.1.A.5.55-R15B and it succed, I have no idea why it fail on phone. I'm using excatly the same e2fsprogs version as in this tool, I'm believing that there need to be done something to the /proc/sys/.... or probably some more protections need to be disabled. Did anybody tried my tool in recovery mode?

It can be truly tested on dumped system image! E.g:

adb shell
su
stop
cd /data/local/tmp
dd if=/dev/block/bootdevice/by-name/super of=/data/local/tmp/super.bin conv=notrunc
/data/local/tmp/superrepack /data/local/tmp/super.bin system_a rw
sync

If it succed without errors than you probably can write it back it to the block device:

dd if=/data/local/tmp/super.img of=/dev/block/bootdevice/by-name/super conv=notrunc
sync
[Miscellaneous Android Development] munjeni:
if you do dmesg right now it will not contain the possible things, It must be done in the moment till after my tool
[Miscellaneous Android Development] PEACH-PIT:
Probably some kind of protection function is working.

I think you can only disable it from the twrp terminal.

There is no twrp in moto g 5g.
[Miscellaneous Android Development] munjeni:
Tried right now latest rom from xperia 1 II, rom vesion XQ-AT52_Customized SEA_58.1.A.5.159-R2B, apsolutly no errors. So definitelly something inside phone need to be done to allow clone blocks. Did you guys doing "adb shell stop"? That command is important to stop all the activity on the phone before use our tool! I can suggest you try this first and let me know:

adb shell
su
stop
cd /data/local/tmp
dd if=/dev/block/bootdevice/by-name/super of=/data/local/tmp/super.bin conv=notrunc
/data/local/tmp/superrepack /data/local/tmp/super.bin system_a rw
sync

change /dev/block/bootdevice/by-name/super to your super partition location
[Miscellaneous Android Development] PEACH-PIT:
Where is the super.bin?

It's not in the official stock rom.

Just renaming the dumped system.bin did not work.
[Miscellaneous Android Development] munjeni:
Super.bin? Its created trought commands above, see post 130
[Miscellaneous Android Development] PEACH-PIT:
I understood.

I tried.

The result was the same as before.
[Miscellaneous Android Development] f1^ter:
Unfortunately, it did not give the result, I attach the log.

But, if I enter the commands:

./superrepack /dev/block/bootdevice/by-name/super system_a rw
./superrepack /dev/block/bootdevice/by-name/super product_a rw

then it works. And you can delete folders (applications) from the product section. It turns out there is write access.
[Miscellaneous Android Development] munjeni:
So this is definitelly something on phone side preventing clonning blocks. Can you repeat it and after it catch dmesg and post it here?
[Miscellaneous Android Development] munjeni:
You have the same problem like PEACH-PIT , reparation is not done right because clone blocks didn't suced, and filesystem have ton of problems, for example if you delete some file which use shared blocks you will delete a ton of files without knowing that! So wait until we figure out problem.
[Miscellaneous Android Development] PEACH-PIT:
How about this?
[Miscellaneous Android Development] munjeni:
I realy want to help and make it fully working for everybody, but your dmesg didn't help since its probably dmesg long time ago after you executed my tool. You must catch dmesg in moment till after you use my tool e.g. in next 10 - 20 secconds after my tool finish! You can do booth dmesg and logcat e.g.

dmesg > /data/local/tmp/dmesg.log

logcat > /data/local/tmp/logcat.log
[Miscellaneous Android Development] PEACH-PIT:
Logged again.

logcat.log did not complete successfully.
[Miscellaneous Android Development] f1^ter:
I attach it the log during the operation https://yadi.sk/d/UnDWaw50aA7-eg .
[Miscellaneous Android Development] bobbyp1086:
I'll run dmesg continually until after script is ran, what it sounds like to me is adb either 1 not updated or 2 terminal on cpu end needs admin rights. Just a thought give me 15 I'll have everything for you.

Update. The script says everything is already able to mount as rw, dmesg, logcat and system trace all blank out as soon as it's ran.... In 1st post you should definitely mention running as su and enforcing to 0 as well.

Nothing is mounting as rw, but I'm willing to help anyways I can.

At my disposal

Moto G Stylus 2020 edition 4gb ram 128 int

Moto One 5G Ace

And for poops and giggles a moto E Plus

As well a few that don't need this note 4, j7, actually a lot of samsung.

Just let me know what to dump, cmds to run and I'm on it, I'm setting notifications on for this thread so I'll be more responsive, let's get this working.

I did however see something about loop8 in dmesg. I'll screen shot
[Miscellaneous Android Development] bobbyp1086:
Hey so thought at wee early morning, the device is still encrypted, wouldn't that affect it?
[Miscellaneous Android Development] munjeni:
Its allready inside 1.st post!

Yes thats definitelly a one of the possible reasons! But PITCH-PIT gaved me system partition dump and it is not encrypted! But he getting error mentioned few posts back! I'm still believing that something need to be enabled in /proc/sys/.... to allow cloning blocks
[Miscellaneous Android Development] munjeni:
Sorry guys but it looks like you do not getting me what I need, there is absolutly nothing inside your logs and you didn't gaved me dmesg, in logcal log nothing about superrepack, thats indication for bad timing. It must be done in the right timing, almost in the same time or 5-10 secconds max after you run my tool !
[Miscellaneous Android Development] f1^ter:
I ran 1in1 your tool and the command:

/data/local/tmp/superrepack /data/local/tmp/super.bin system_a rw

maybe this will help!
[Miscellaneous Android Development] bobbyp1086:
I ran advanced tools pro dmesg tool before the cmd for your tool, It runs continuously until I say stop, but something happens that interfere with It logging. the stop command puts my phone in a state like it's off just a black screen until the shell cmd start is sent) this stop is why I think nothing logs correctly, it stops the process. What I can do tho is try it running the script without stop being issued. I'll post the findings. My dmesg only had info about my wifi being interupted lol
[Miscellaneous Android Development] munjeni:
Sorry I have no idea, if you find in your logs what prevent clonning blocks let me know!
[Miscellaneous Android Development] bobbyp1086:
Nothing that I can see. I ran a system trace logging everything I could in dev options from seconds before to seconds after.... No clue what I would be looking for. mprotectcode (maybe wrong words but along those lines) popped out at me but I can send to you if you want it's a long long list a scrambled words until I can get to np++ I can't tell if it's in order, it makes no sense as it's, logcat and dmesg logged nothing. Can this be ran from stock recovery? Bootloader? Fastbootd? Fastboot?

I remember back in the Android 5,6 and 7 days I had a zte government free phone, obama phone, there was a cmd that you would run that without running it first kingoroot wouldn't work, it was sorta to break the defense of the phone.

But I'm starting to think it's the fact that it's encrypted, I have a few things to try to get twrp up and going, that may be the only way. I don't think any thing we can do well work. Oh when I do run your tool, all say they are rw allready and unshared or something to that nature. I remember because the "allready"
[Miscellaneous Android Development] bobbyp1086:
Did you use the correct super image? Like I ran

/data/local/tmp/superrepack /dev/block/sde26
[Miscellaneous Android Development] bobbyp1086:
After hours of digging aimlessly thru system folders, I found an item that jumped out when I read it. Attached is that file.
[Miscellaneous Android Development] bobbyp1086:
@munjeni Do you still have version 2 laying around? I am willing to risk it to see the difference in scripts, see what was changed then to now. I understand version 2 worked on my phone, it's what brought me here
[Miscellaneous Android Development] munjeni:
All versions work but it not work correct! It make your partitions rw indeed but what fail is e2fsck unable to repair filesystem because of error mentioned in few my posts back! So when you see error for the first time running my tool it will give you error, but if you run my tool seccond time it will do nothing and you will not see any error because RW is happened allready, but since my tool failed when you run it for the first time on the fresh partition your partitions is still bad and contain ton of errors! If you try to delete some files from damaged partitions you will delete ton of files without knowing that you have deleted them because super partition contain shared blocks so if you delete an file you will delete all the other files from the shared block! I recommend everybody to reinstall super partition in case you have error while running my tool for the first time! You not need to run my tool seccond time if it failed first time, just execute run.sh located inside /data/local/tmp ! You should try run my tool trought recovery maybe it will work I don't know. Or you can dump super partition and do the things on your local linux machine, my tool is confirmed working on linux, even I have done the things sucesfully on my xperia 10. I realy have no idea why it fail on recent phones, in most case there is some protections active and I'm unable to figure out without phone. Also you should modify run.sh and do the things to super.dump on linux machine and than write back modified super dumped partition to phone using DD command:

dd if=super.dump of=/dev/block/sde26 conv=notrunc

Edit:

Here is some information which probably have relation to protection in memory so it might maybe reason why clone blocks don't work, see https://source.android.com/setup/start/android-10-release (Execute-only memory, Scudo, ShadowCallStack, LLVM instrumentation) it might be all realated, I realy don't know whats going on on recent androids
[Miscellaneous Android Development] finadil:
I finally upgraded from my trusty old v20 to a Moto One 5G Ace and am experiencing the same errors as bobbyp. They partitions end up r/w but get the same clone errors. We don't have a custom recovery yet which makes everything a pain. I'll fastboot flash rooted stock when I get home and try dumping my super partition to my linux box and trying it that way. Just keep in mind we appreciate you munjeni, there's more of us out there following your work!!
[Miscellaneous Android Development] bobbyp1086:
That file never attached...
[Miscellaneous Android Development] bobbyp1086:
Man I can't do Linux, got a used hp probook, my luck it's bios is admin password locked, my destiny... The only version that can't bypass the admin bios password... No Linux..