yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] samarium:
bauner produced a new n7000 IsoRec with TWRP + OTG which I wanted, so while I was installing I tested a few things.

I generated a block binary file with each of the 1kB blocks annotated for the 200MB n7000 cache partition, and dd'd the file to the cache partition prior to each mkfs.

$ cat blocknull.pl
#!/usr/bin/perl
use strict;

my $count = $ARGV[0];
$count = 1 if $count == 0;
$count *= 1024 if $ARGV[0] =~ /M$/;
$count *= 1024 * 1024 if $ARGV[0] =~ /G$/;

for (my $i = 1; $i <= $count; $i++)
{
printf "\nBLOCK %10d kB %6d MB %2d GB BLOCK\n", $i, $i / 1024, $i / 1024 / 1024;
print chr(0) x (1024-43);
}
$

BLOCK 1 kB 0 MB 0 GB BLOCK
...
BLOCK 204800 kB 200 MB 0 GB BLOCK

Then operated on both vfat and ext4 file systems to determine which of the 204800 block signatures where remaining after various operations.

# tr -d '\0' < /dev/block/mmcblk0p7 | grep BLOCK.*BLOCK > cache.x.y.desc
...
# wc -l cache.?.?.*
204800 cache.1.1.dd
201632 cache.1.2.mkfs.fat32
197041 cache.1.3.copyfile
204800 cache.2.1.dd
0 cache.2.2.mkfs.ext4
204800 cache.3.1.dd
197380 cache.3.2.mkfs.ext4.twrp
60 cache.3.3.fstrim
60 cache.3.4.copyfile
#

So as expected vfat format doesn't change the underlying data returned, it just gets changed as it is used, as show by the signature counts on cache.1.*

ext4 is more interesting, as I tried a manual mke2fs -t ext4 for cache.2.* and TWRP wipe ext4 for cache.3.*. The TWRP wipe is not using secure discard as can be seen from recovery.log, but things are largely back on track after the first fstrim except for a hole from 131081 kB to 131125 kB.

recovery.log:
warning: wipe_block_device: Wipe via secure discard suppressed due to bug in EMMC firmware

Maybe more interesting is that even though it seems manual mke2fs -t ext4 does a wipe, when I do a fstrim is still says 180MB trimmed, which I don't expect, some inconsistency in fs metadata setup in mkfs maybe? Doesn't matter to me, 1 or 2 wipes, but seems I will be using mke2fs -t ext4 via terminal and then using TWRP wipe/format as required.

FYI, EMMC IDs PNG attached.
[Android Software/Hacking General [Developers Only]] Lanchon:
>it seems manual mke2fs -t ext4 does a wipe

it shouldn't. mke2fs -i thought- doesn't trim unless invoked with a specific option. repit invokes with the flag:

https://github.com/Lanchon/REPIT/blob/master/repit-fs-ext4.sh#L51

as to the question of why your markers were cleared anyway, i've no answer.

>even though it seems manual mke2fs -t ext4 does a wipe, when I do a fstrim is still says 180MB trimmed

some kernels inform the newly trimmed space: if you run trim twice you'll get "0 bytes trimmed" the second time.

other kernels (like CM's i9100) always inform (and presumably trim) the full partition free space, so 180MB is ok. if you run trim twice you'll get the same number of bytes both times.

>things are largely back on track after the first fstrim except for a hole from 131081 kB to 131125 kB.

here are some candidate causes:

a) ext4 fs is based on 'blocks' with each block being a constant number of sectors. it makes sense that fstrim should work on whole blocks. also, when ext4 writes a 'short block', ie one not completely filled with data, some sectors and the end of the block might remain unused. it makes sense for ext4 not to write these sectors at all. but the complete block will be marked as used given that the block is the granularity for that, so no sector in the block will be trimmed by fstrim. so some pre-format data might survive in these short blocks after fstrim by this mechanism, which could explain what you observed.

b) another cause could be that the emmc might ignore trim requests for spans shorter than some size or for misaligned spans (remember that erases are performed in large chunks) giving rise to the observed data survival. when formatting no data survives because partitions are position- and size-aligned to 1MB or 4MB, which might be enough to guarantee trim. (i find this explanation unlikely, but who knows.)

about repit:

repit formats and trims ext4 and f2fs in a single operation.

to wipe /data a single repit should be enough:

-data=+wipe

to wipe /sdcard you can take advantage of repit's capability to convert file systems and do two repits:

-sdcard=+wipe+ext4

-sdcard=+wipe

an idea that comes out of this is that repit could temporarily format in ext4 before formatting in other modes that do not support format-time trimming, such as when wiping vfat and swap. this would make the above 2 steps unnecessary.
[Android Software/Hacking General [Developers Only]] Lanchon:
this is very interesting.

the relevant lines are these:

https://github.com/Lanchon/REPIT/blob/master/repit.sh#L318-L322

if [ -f "$packageName" ]; then
if [ "$(dirname $(readlink -f "$packageName"))" != "/tmp" ]; then
info "copying package to '/tmp'"
cp -f "$packageName" "/tmp/"
hint="this package copied itself to '/tmp'; please run it again from there"

the line:

if [ -f "$packageName" ]; then

assures that the file $packageName exists.

but these logfile lines:

BusyBox v1.22.1 bionic (2016-01-10 12:49 +0530) multi-call binary.

Usage: dirname FILENAME

Strip non-directory suffix from FILENAME

are proof that 'dirname' is being invoked without argument, which means that 'readlink -f "$packageName"' produced an error!

how can 'readlink -f <file>' (which means 'canonicalize') give an error when invoked on an existing file is beyond me. it looks like your implementation of 'readlink' is broken.

what exact recovery are you using? who made it or where is it being distributed?

EDIT:

btw there is a quoting error in the code here but it shouldn't affect this. the line should be:

if [ "$(dirname "$(readlink -f "$packageName")")" != "/tmp" ]; then
[Android Software/Hacking General [Developers Only]] Lanchon:
so i committed what i think is a fix for this problem that i cant reproduce:

https://github.com/Lanchon/REPIT/commit/c7bc3655acc89ee554d1dafe09c7bb9948483c03

and attached is build for you to try.

IMPORTANT: EXTRACT THE ZIP FIRST, DONT JUST FLASH IT!
[Android Software/Hacking General [Developers Only]] chapito:
Hi Lanchon.

I'm installed this zip but i have the same problem.

I'm copy, before zipping the achive, on the \tmp directory of emmc

What have i do wrong?.

Thanks.
[Android Software/Hacking General [Developers Only]] Lanchon:
no log, no kernel info, no recovery info. cant help you.
[Android Software/Hacking General [Developers Only]] chapito:
Hi.

Forgive me for not giving more information to solve the problem.

Yesterday I could partition the memory.

I had to change the partition type of memory EMMC to vfat and the script to start.

I used the IsoRec TWRP 2.8.7.0.

I used the last script publicated "lanchon-repit-20160415-system=1.0-data=same-sdcard=max-preload=min+wipe-i9100.zip"

Thanks
[Android Software/Hacking General [Developers Only]] Lanchon:
you didn't need to change your sdcard to FAT !!!

you could have used: -sdcard=max++ext4

if only you had read the instructions! that's what they are there for lol

well, it's your data you had to format, not mine! :-p

thanks!
[Android Software/Hacking General [Developers Only]] jimbomodder:
Hello, will this be OK on stock ROM with jeboo kernel, wanting to increase both system to 1.5 GB and data to 6GB.

P.S, been a long time since I used my s2 as been on Nexus 6

Sent from my GT-I9100
[Android Software/Hacking General [Developers Only]] jimbomodder:
+Lanchon I changed zip name lanchon-repit-20170115-system=2+wipe-data=6+wipe-sdcard=max-preload=min+wipe-i9100.zip but keeps saying invalid system name, any ideas. Running 6.0.1 Bliss
[Android Software/Hacking General [Developers Only]] the.gangster:
[MENTION=6576153]jimbomodder[/MENTION]

First of all:

check the readme on the github documentation for the syntax! It changed already with builds as of 2016-09-23. Now units (like G) are mandatory for size definitions.

If it still fails, and I assume it will as you might run it from within a recovery, that doesn't have the full toolset that is needed: post the recovery.log or the repit.log (again: please read the documentation).
[Android Software/Hacking General [Developers Only]] jimbomodder:
It's ok, I ran 6gb pit via Odin and it's all sorted now, thanks anyway
[Android Software/Hacking General [Developers Only]] lolala1:
@Lanchon

Hey man! I flashed your RePit to I9305, 11GB free space up to 13GB! :) Good result. No any error.

I can't flash custom rom, system.img is small sized. (My USB port broken) How to back stock partition size? Would you make a backup for me?

*I know, my lang is bad. sorry.
[Android Software/Hacking General [Developers Only]] the.gangster:
Hi lolala1,

Nobody makes a backup for you.

But if you want to completely go back to stock sizes (and if the originally provided partition size data for that device were correct) then you can do the following:

in case you did that (and it sounds like that):

tombstones=same-cache=32M+wipe-system=1G-preload=min+wipe-data=max

now do:

cache=1G+wipe-system=1.5G-preload=560M+wipe-data=max

In case you also changed tombstones size, also revert that to stock by using tombstones=256M.

So you should end up with something like that:

lanchon-repit-20170115-cache=1G+wipe-system=1.5G-preload=560M+wipe-data=max-i9305.zip

or

lanchon-repit-20170115-tombstones=256M-cache=1G+wipe-system=1.5G-preload=560M+wipe-data=max-i9305.zip

Good luck.
[Android Software/Hacking General [Developers Only]] lolala1:
Thanks man! Successfully RePit! :highfive: My stock partition get back! :good:

lanchon-repit-20170115-tombstones=256M-cache=1G+wipe-system=1.5G-preload=560M+wipe-data=max-i9305
[Android Software/Hacking General [Developers Only]] evilvoice:
I see you support the galaxy s5 (klte). I would like to help in porting to the Note 3 (hlte).

I've checked the scripts and it looks like some simple editing but you also include identifiers. Is there some commands I need to run from terminal to get all the pertinent information? df dh mount. Would probably need to find all the models for the device too in order to make it universal for the phone. I know a few, but not all.

Thanks
[Android Software/Hacking General [Developers Only]] the.gangster:
[MENTION=965544]evilvoice[/MENTION]

as I understand it:

Just like for other newer devices, klte support was withdrawn for safety-reasons after the S5 was suspected to have signed GPTs. Although that decision has been made based upon a search method that could also reveal false positives, no one prooved the opposite yet.

For port requests of new models (or for checking what information is collected for that) you can run (or look at) this tool. device-dump. Can be run by flashing a zip, or adb methods as described there. So if you want to port it yourself it should still deliver all information needed, if you are still on stock partition layout.
[Android Software/Hacking General [Developers Only]] evilvoice:
[MENTION=6560258]the.gangster[/MENTION] I'll check it out. It may be a while, but anything I find out, I'll post here and let you know progress. I may be the only one who wants it for the phone lol.

I'll check on some of this stuff you posted. It seems it'll have to be trial and error. I do have a pit file just in case
[Android Software/Hacking General [Developers Only]] the.gangster:
[MENTION=965544]evilvoice[/MENTION]

sadly it won't tell you. AFAIK [MENTION=4141005]Lanchon[/MENTION] hasn't found a clear proof yet. Otherwise all the devices wouldn't be "suspected" any more.

In (at least) one of the links you can see him grep the combination of strings like 'GPT' and 'sign' successfully on a device that obviously doesn't enforce GPT signatures and runs fine.

But I remember he once described a way to kind of test it with only reducing one of the partitions for only the minimum (granularity) size, explaining in theory (!!!) a way to recover after a brick. But can't remember the exact device any more. And nevertheless this was still kind of risky.

So if it is not already well-known in your device forums whether the hlte has signed GPTs, it might be safer to wait for Lanchon to respond to an official port request. Even if this might take quite a long time, as he's been very busy recently.
[Android Software/Hacking General [Developers Only]] kopitalk:
Firstly thank you for the awesome tool :good:

I successfully repit my N7000 and at first with DiskInfo it showed correct information. But I don't know how later on the sdcard mount point changes to something weird. Iirc the only thing I did was to install ES Explorer. Any idea?

Update: I resolved this by explicitly specify sdcard partition size instead of just putting "max".
[Android Software/Hacking General [Developers Only]] Nobby1960:
This issue happens sometimes randomly, with my i9100 too - whether with Repit or a pit file via Odin. No idea why.
[Android Software/Hacking General [Developers Only]] JaLoou:
Hello.

Thanks also for the good tool, I already used it successfully for increase the data partition on my old SGS2 with Android 4.1.2.

Now I want yet to switch off journaling on ext4 for make the old SGS2 runs more faster.

Please, answer to me: Can I switch off journaling by using Lanchon repit tool?
[Android Software/Hacking General [Developers Only]] Lanchon:
this is caused by your ROM. it has nothing to do with REPIT.

explicitly specifying sdcard partition size has absolutely no effect on this.
[Android Software/Hacking General [Developers Only]] Lanchon:
no you can't.

you also can't fry eggs with REPIT.

if you want a faster phone, first switch to a TRIM-enabled OS, such as CM or lineage.

then do a manual fstrim or wait 48 hours with the phone turned on.

if that is not enough, switch /data to f2fs.

this is the REPIT thread: do not ask **ANY** questions about any of this here.

NO EXCEPTIONS.

really... NO EXCEPTIONS!!!

thanks!
[Android Software/Hacking General [Developers Only]] GizmoTheGreen:
hey, I have a galaxy s2, i9100, I got twrp 3.1 on it, but I can't install roms or run repit cause for some odd reason it crashes/reboots after a few minutes in recovery :(

I don't know why, battery is over 60%.

I have no OS now. trying to repit and then I want to install xenonhd and gapps + magisk.
[Android Software/Hacking General [Developers Only]] challenger07:
I have a Samsung S2 i777 just tried to install the lanchon-repit-20170115-system=1G-data=same-sdcard=max-preload=min+wipe-i777. The phone is rooted and I have ODIN installed and stock recovery. When I boot into recovery I get an error saying failed to mount /system (Invalid argument) I had this since I tried to use ODIN to resize using a PIT file; I would like to install a new ROM. I hope the lanchon would be able to fix this but although I can wipe data and cache in recovery when I tried to apply update from SD card I get installing update and then E:error in /tmp/sideload/package.zip (Status 255) E:Failed to mount /system (Invalid Argument) Installation aborted. Any ideas how to resolve this?

One step forward and one step backwards. I found a tar file for the i777 and flashed (ODIN) that at the same time as the pit file. Now the phone will boot and it does have the new larger storage. However the tar file was the original Android 2.3. I rooted the phone again and went into recovery but when you select the external SD card it shows an empty folder and so the 7..1.2 Rom that is ZIP'd on there I cannot flash. I need to do some more reading how to move forward from there. Any quick hints welcome, at least I've got rooting and resizing completed.
[Android Software/Hacking General [Developers Only]] challenger07:
I am still stuck. Does anyone have a link to a valid i777 tar file? The stock recovery won't see any files on the SD card. I tried internal storage but then it says there is an error checking the ZIP. I tried a few alternative ZIP files so I think the recovery is the issue. I can still get to ODIN so if I could find a more up to date tar file I can flash that way. ANYONE?
[Android Software/Hacking General [Developers Only]] Lanchon:
READ THE DOCS!!!! i will not cut and paste the docs here, read them where they are published.

you just wasted my time (and other's too), so i have no desire to help you.

good luck
[Android Software/Hacking General [Developers Only]] pappt:
hi! can't get work on maguro:

error message:

blockdev: /dev/block/mmcblk0: devic or resource busy

.
[Android Software/Hacking General [Developers Only]] guest4711:
Looks like system or cache is mounted. Try to unmount /system in TWRP before flashing repit...
[Android Software/Hacking General [Developers Only]] siealex:
I also can't get it work on Maguro with the same error, even if I run it from /tmp and even if I unmount all partitions in the mount menu.

PS, my data partition is f²fs, can this be the cause?
[Android Software/Hacking General [Developers Only]] pappt:
i am on EXT, and also tried every possible combination.
[Android Software/Hacking General [Developers Only]] the.gangster:
Did you read and try already, what was discussed/done from #42 down?
[Android Software/Hacking General [Developers Only]] siealex:
I tried everything except this:

How to flash directly from /tmp? Pressing "install" in TWRP throws me to /sdcard, automatically mounting it. Is it possible via ADB or terminal commands?
[Android Software/Hacking General [Developers Only]] siealex:
I tried all possibilities, exactly the same error always...
[Android Software/Hacking General [Developers Only]] the.gangster:
In Mount-menu:

- you could select the (external) Micro SDCard as storage after pressing the "Select Storage" button. (This location will be used when you press "install" the first time after booting to recovery.)

- you could unmount all partitions after having changed to /tmp in the Install menu first. Returning to the Install menu after that will then kick you directly to /tmp again.

You could also use adb to copy the script to /tmp directly. But then you should prevent your computer to mount the partitions in the background or better disconnect it again after copying. You can also check, if partitions are still mounted using 'adb shell df -hP'.

Make sure no partitions are encrypted, otherwise it will also continue to fail. Did you also use the other TWRP recovery already?
[Android Software/Hacking General [Developers Only]] John-Roy:
hi i just wanted to ask if can use the repit file also on the stock rom, i still have to root my note gt-n7000. But i like the stock rom so can also just flash the repit file and keep stock rom without flashing custom rom. Btw i downloaded the (anchon-repit-20170115-system=same+keep-data=6G+keep-sdcard=max+keep-preload=same+keep-n7000), this is the correct one for my phone right? I just want to be sure i do nothing wrong.
[Android Software/Hacking General [Developers Only]] epaminonda27:
hello,

I would like to partition my samsung s2 gt-I9100 with 1.5 GB of system and 6GB of date, which zip file should I use?

could this be good?

lanchon-repit-20170115-system=1G-data=same-sdcard=max-preload=min+wipe-i9100.zip

otherwise how should I do?

I thank
[Android Software/Hacking General [Developers Only]] the.gangster:
[MENTION=8982819]epaminonda27[/MENTION]

Yes, right zip file.

You just have to rename it like described in the readme to fit your needs.
[Android Software/Hacking General [Developers Only]] epaminonda27:
lanchon-repit-20170115-system=1.5G-data=6G-sdcard=max-preload=512MB+wipe-i9100.zip

renamed so okay?

I would like to have a partition like the one you recommend.

after partition can I restart my smartphone normally or do I have to format sdcard0 first and then install the Lineage 14.1 rom?

I'm not clear how to proceed after the breakdown, can you help me?
[Android Software/Hacking General [Developers Only]] the.gangster:
As you don't reveal what you actually want to do it is hard to guide you best.

e.g. depending on if you made a backup OR if you want to install a new ROM anyway wiping data (=formatting!!) would dramatically shorten the time needed (and the load on your emmc).

e.g. assuming you are not on Lineage14.1 yet you should even wipe system, data and set preload to min+wipe (only needed on stock ROM so you gain ~504 MB in the sdcard0 area).

and now the mathematics part:

e.g. if you use 1.5G + 6G you cannot preserve sdcard0 if that is currently filled with more than 7GB (with preload=min+wipe) or 6.5GB (with preload=512M)

btw: in case you want that: it is M not MB in the syntax for the file name! But if you currently have a stock preload partition of that size, and if you really want to waste that space: simply use preload=same+wipe (equals preload=+wipe) or drop the preload completely from the name (which equals preload=same+keep+ext4).

Now pick from these choices or create a new variant that fits best. Or read the docs....
[Android Software/Hacking General [Developers Only]] epaminonda27:
first of all thank you.

I want to install Lineage 14.1.2

I have a samsung s2 clean with Rom stock, I have already backed up the efs folder, I have no other important data to keep.
[Android Software/Hacking General [Developers Only]] PackElend:
This process didn't get along smooth at all but I'm quite happy that latest LOS 14.1 runs on my S II. There were some events during this process which haven't been answered yet. May some of you can answer some of them, e.g. why repit has never succeed to mount /sdcard.

-----

I case the quote don't gets you to the referenced post: 22th July 2018, 09:34 PM |#92
[Android Software/Hacking General [Developers Only]] D@rekills4:
Is there a way to create my own partition table for my N7000.
[Android Software/Hacking General [Developers Only]] the.gangster:
At least you can use the respective zip to resize the partitions 9-12:

System, data, sdcard, preload

Links to download and documentation are in the OP.

(Description for S2 also applies to N7000)
[Android Software/Hacking General [Developers Only]] The_Pacific_gamer:
Coming from leaked soak test and December 9th arrowOS pie ROM for athene and I'll give you the results
[Android Software/Hacking General [Developers Only]] HyperCriSiS:
Anybody did this on S5 with Linage?
[Android Software/Hacking General [Developers Only]] the.gangster:
There was a version for the S5 once.

But:

Searching this thread would also have informed you on a critical topic re the S5:

post #195

And this is independent of the actual installed ROM.
[Android Software/Hacking General [Developers Only]] rexsllemel:
Edit:

I'll reedit this soon on browser.

Currently on XDA app but I have a damn fone
[Android Software/Hacking General [Developers Only]] Lanchon:
im on the phone travelling. i cant really look. but there seem to be many.

for starters, you declare fota as raw, which means it cant be resized nor wiped (read the docs) but u declare its default as wipe!

more importantly, you are not grasping the concept of heaps in repit. i also dont know the details of the partitions being non adjacent and thus dont know which method to use to solve that in repit, nor what is fota used for and why you want to resize it and declare it raw.

have you provided a port request on github?
[Android Software/Hacking General [Developers Only]] Teracotta:
Fixed, thanks.

FOTA is our equivalent to OTA, but it is only 10 MB big.

I don't understand how heaps work and wasn't able to find any guidance from your finished examples or the documentation. Most of your devices have heapStart=$ on the radio partition, with janice starting on kernel2.

As for the details, the major difference is there is a "persist" partition in the middle of the resizable block:

# 14 221184 3293183 1.5 GiB 8300 system
# 15 3293184 59252735 26.7 GiB 8300 userdata
# 16 59252736 59269119 8.0 MiB 8300 persist
# 17 59269120 60989439 840.0 MiB 8300 cache
# 18 60989440 61009919 10.0 MiB FFFF recovery
# 19 61009920 61030399 10.0 MiB FFFF fota

If cache can't be resized, what I really want is to move userdata into system.

My device is already on there in the request of the T999, we share partition tables.