Lanchon / REPIT

A Device-Only Data-Sparing Repartitioning Tool For Android
159 stars 25 forks source link

Nook HD+ (ovation) #57

Closed 149113 closed 7 years ago

149113 commented 7 years ago

Hi - here is my device information for the Nook HD+ (Ovation). I am trying to increase the System partition to 2GB so I can install the gapps package. Per the request I have attached my log file repit-dump.log

Device Name: BN Nook HD+ (bntv600) Code Name: Ovation Recovery Version: twrp-3.0.2-0-ovation Kernel Version: 3.0.101 CyanogenMod Version: 13.0.2016820 Build Number: 6.0.1

Current layout is: \data - 12977MB with 214MB used \system 661MB with 521MB used \cache 456MB with 7MB used

I believe the partition is stock. I did have a previous version of android 4.4.4 installed

repit-dump.zip

Lanchon commented 7 years ago

hi,

recommended /system partition size, if you want to resize, is 1G. please read issues #56 and #55, decide whether you want to continue, and get back to me here.

(if something needs clarification on those issues, please post in the right issue, not here.)

Lanchon commented 7 years ago

repit-dump.txt

Lanchon commented 7 years ago
sgdisk /dev/block/mmcblk0 --set-alignment 1 --print
----------------------------------------------------------------------------------------------------------
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.

Warning! One or more CRCs don't match. You should repair the disk!

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

have you done any repartitioning on the phone already?

149113 commented 7 years ago

I did attempt to resize using twrp's advanced tools but nothing resized. I'm OK with the 1G partition for system.

Lanchon commented 7 years ago

do you understand the implications of resizing system? and the bricking risks?

Lanchon commented 7 years ago

i think this device might work with repit, should i give it a try? btw, there 's a new twrp for your device, install it.

149113 commented 7 years ago

I'm good with changing it and understand the risks so go ahead. Do you have a link for the new twrp? Can't seem to locate that.

Edit: I found it on the twrp site.

149113 commented 7 years ago

I have tried every method out there to install gapps and nothing is working so I think this is the only option and I assume the risks.

Lanchon commented 7 years ago

ok, ill make the port then ASAP

Lanchon commented 7 years ago

i'm trying to find out information about the 'factory' partition to no avail. do you have any info on this partition?

149113 commented 7 years ago

The only partition info is what I was able to get in twrp that is in the first post. I'll look around to see if there is anything out there...

Lanchon commented 7 years ago

ok, ready for test. get this file, UNZIP IT, then flash the NESTED zip file.

ovation_UNTESTED.zip

it will grow /system to over 1G and reduce /cache to 32M. rest of partitions remain exactly the same.

those two sizes are calculated so that the remaining partitions dont need to be moved. this means less risk and less processing time.

but... your device also has a 0.5GB partition called 'factory' and i'm guessing it goes unused in custom roms. it would be nice to recover that space. could you please take a look inside and tell me what files are there?

awaiting for your test results.

thanks!

149113 commented 7 years ago

Sounds great. I'll give it a shot. What is the easiest way to check the \factory partition?

Lanchon commented 7 years ago

well, you can mount it if you like the shell :)

otherwise you can pull it... boot twrp then pull the complete partition via adb. on the PC type: adb pull /dev/block/mmcblk0p7 factory.img

after some time (be patient) you will have a factory.img file on your PC.

if you use linux you can right click it and mount it using image mounter. otherwise, just zip it and post it here or anywhere for me to see it.

149113 commented 7 years ago

It worked here is the new layout:

/system = 1088MB total and 614MB used /data = 12977MB total and 1546 used /cache = 31MB total and 4MB used

TWRP also lists /Dalvik, /Internal Storage as partitions but you can't view the properties

Lanchon commented 7 years ago

cool! now if you could look into /factory (post above)... i'll sleep now and look for your post or file tomorrow. later!

149113 commented 7 years ago

Sounds good. Thanks again!

Edit: Just a side note... I had issues before getting adb to recognize the device before. I'll do a little more research on that

149113 commented 7 years ago

OK... I got adb to work over IP and was able to capture that partition using the command you listed above. It's about 468MB in total. It's unreadable in Windows but I'm sure it's fine to mount and read in Linux. I did some searching found this [http://forum.xda-developers.com/showthread.php?p=34168454#post34168454] . Looking at the bottom of the first post it appears the /factory partition is critical to the device as it contains "vital device specific information that was created at manufacture". So we probably need to leave that alone. They also show the default settings for the partitions for the HD+.

P# Name Size Type 1 xloader 128K Fastboot Image 2 bootloader 256K Fastboot Image 3 recovery 15MB Fastboot Image 4 boot 16MB Fastboot Image 5 rom 48MB vfat 6 bootdata 48MB vfat 7 factory 448MB ext4 8 system 672MB ext4 9 cache 464MB ext4 10 data varies ext4

Lanchon commented 7 years ago

thanks for the research. well i've never seen an 'ID/EFS'-style partition of this size. typically they are around 20MB; 500MB is way too large for this function. it is more likely that the partition i just an extension to stock /system of some sort, just like /preload or HIDDEN on samsung devices of that time.

if it is an ID partition, typically nobody else can use it cause its encrypted against that particular serial number of your processor.

so the problem is you don't want to publish potentially sensitive info? could you upload it to dropbox and send me a link on a private message then?

Lanchon commented 7 years ago

so i am downloading a flashable zip of HD+ stock 2.2.1 to take a look at whats inside. the 417MB total size is not very promising...

Lanchon commented 7 years ago

http://forum.xda-developers.com/showthread.php?p=69585287

Lanchon commented 7 years ago

i downloaded the flashable stock zip. it has files instead of partition images. for /factory it does this:

mount("ext4", "EMMC", "/dev/block/platform/omap/omap_hsmmc.1/by-name/factory", "/factory");
assert(package_extract_file("fsck.zip", "/factory/fsck.zip"));
assert(package_extract_file("romrestore.zip", "/factory/romrestore.zip"));

mounts /factory and extracts these two zips: fsck.zip romrestore.zip

fsck.zip just packs a disk check tool and runs it on partitions.

romrestore.zip does this (my comments in ## lines):

assert((getprop("ro.product.device") == "ovation" ||
        getprop("ro.build.product") == "ovation"));
ui_print("Restoring ROM tokens from backup");
show_progress(1.0,1);

## extract a bundled unzip tool to /tmp
package_extract_file("system/bin/miniunz","/tmp/miniunz");
set_perm(0, 0, 0755, "/tmp/miniunz");

## format /bootdata
unmount("/bootdata");
format("vfat", "EMMC", "/dev/block/platform/omap/omap_hsmmc.1/by-name/bootdata", 0);
assert(mount("vfat", "EMMC", "/dev/block/platform/omap/omap_hsmmc.1/by-name/bootdata", "/bootdata") == "/bootdata");

## extract two small bundled files into /bootdata
package_extract_dir("system/bootdata","/bootdata");
# Don't unmount /bootdata since recovery mode needs to write the BCB there

## mount /factory
ifelse(is_mounted("/factory"),0,assert(mount("ext4", "EMMC", "/dev/block/platform/omap/omap_hsmmc.1/by-name/factory", "/factory") == "/factory"));

## format /rom
unmount("/rom");
format("vfat", "EMMC", "/dev/block/platform/omap/omap_hsmmc.1/by-name/rom", 0);
assert(mount("vfat", "EMMC", "/dev/block/platform/omap/omap_hsmmc.1/by-name/rom", "/rom") == "/rom");

## unzip a file already present in '/factory/rombackup.zip'
assert(run_program("/tmp/miniunz","-o","/factory/rombackup.zip") == "0");

## final cleanup
unmount("/rom");
# This will fail if romrestore.zip is on /factory, but that's OK
unmount("/factory");
ui_print("Completed restoring ROM tokens");

aha! the romrestore.zip unzips a mystery file already present in '/factory/rombackup.zip'. the destination of the unzip is unknown because it is encoded in '/factory/rombackup.zip' itself, which i don't have. but because the unzip is surrounded by mount/unmount /rom and because of the zip name ('rombackup.zip'), i'm willing to bet that '/factory/rombackup.zip' harbors the content of the complete /rom partition and nothing else.

now... the /rom parition is 48 MiB in size, and yes, it makes total sense for this partition to actually have the important info about the device. i recommend you pull an image of that partition (as you did before) and store it somewhere safe.

but what's in /factory so far? modders placed a fsck.zip to repair filesystems. also placed a romrestore.zip to restore a backup of the /rom. also, some earlier process created a backup of /rom and called it rombackup.zip inside /factory.

/rom is 48 MiB. so rombackup.zip is probably under 10 MiB. the other two zips are less than 1 MiB combined. so what else is in /factory? is it using half a gigabyte to store a 10 MiB backup?

my advice:

upload and send me your partition image. in all probability i'll find it empty with a couple of files. of those only rombackup.zip is important. then...

you can store rombackup on you PC (you should), or a pulled image of the /rom partition itself, or both. after that what would i do?

well i could format /factory and shrink it completely. if you ever need to restore /rom you can do it from the PC. but i'd rather just shrink it to something reasonable. 64 MiB is probably huge but ok. (32 MiB is probably ok too.) 90% of it will remain unused but you will be able to use all the tools already out there if you keep a small /factory, i'd recommend that.

anyway... so i'll be waiting for your response. i need to look at that partition to continue. thanks!

149113 commented 7 years ago

OK, I'll find a spot to upload it and advise. Appreciate the explanation.

Lanchon commented 7 years ago

on xda, they confirmed the contents of rombackup.zip

waiting for you info to finish and publish the port. thanks!

149113 commented 7 years ago

OK... I will need an email so I can share the Dropbox link with the .img file

Lanchon commented 7 years ago

thanks! my github username at gmail dot com

149113 commented 7 years ago

Sent the Dropbox link...

Lanchon commented 7 years ago

thanks! lol you could have zipped that :) the download will take 24 hours apparently...

149113 commented 7 years ago

I did a rar with the heaviest compression and it only reduce by about 80MB so it really wasn't worth it. It shouldn't take 24 hours to copy. More like 2 min tops.

Lanchon commented 7 years ago

well it took! not my fault. ok you can wipe the file now.

rod@rod-latitude /media/rod/factory $ sudo ls -laR 
.:
total 346968
drwxr-xr-x  3 root root      4096 Dec 31  1999 .
drwxr-x---+ 3 root root      4096 Nov 13 19:32 ..
-rwxrwxrwx  1 root root 354675032 Dec 22  2012 factory.zip
-rw-rw-rw-  1 root root    360562 Jun 26  2013 fsck.zip
drwx------  2 root root      4096 Dec 31  1999 lost+found
-rw-r--r--  1 root root      3742 Dec 31  1999 rombackup.zip
-rw-rw-rw-  1 root root    229717 Jun 26  2013 romrestore.zip

./lost+found:
total 8
drwx------ 2 root root 4096 Dec 31  1999 .
drwxr-xr-x 3 root root 4096 Dec 31  1999 ..

rod@rod-latitude /media/rod/factory $ df .
Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/loop0        444360 347340     87848  80% /media/rod/factory

rod@rod-latitude /media/rod/factory $

ok, so as you can see there's only 4 files there. 3 files we already knew. the fourth is factory.zip, which is the same file you can download from the web: a useless backup of a stock rom you are not using. and rombackup.zip is a huge 3.7 KB. so a half gigabyte partition just to store a useful 3.7KB.

lol

i got all the info i needed, thanks! i'll work on this ASAP

Lanchon commented 7 years ago

ok could you run one last test?

flash this zip: [delete-backup-of-stock-rom-ovation.zip]

if it works without error, rename your REPIT copy like this and flash it: lanchon-repit-20161112-factory=32M-system=1G-cache=32M+wipe-data=max-ovation_UNTESTED.zip

the first flash deletes only the stock rom backup of /factory.

the second flash repartitions /cache and /factory to 32MB (only wiping /cache), /system to the very typical 1G, and the rest goes to enlarge /data. this would be my recommended configuration for this device, btw.

thanks!

NOTE: the important backup file, the one that is different for each device, is rombackup.zip. and i am NOT deleting that one.

149113 commented 7 years ago

So I encrypted the \data partition so I could install work email (requirement for mobile devices). Now TWRP can't see the \data partion in recovery and I ca't run the script. Suggestions?

Lanchon commented 7 years ago

repit does not work with encrypted devices. i say keep your device as it is.

149113 commented 7 years ago

It seems that TWRP doesn't even see the \data partition as available either. I thought it had the ability to mount those with the appropriate pass-code?

Lanchon commented 7 years ago

your twrp build has to be compatible with the encryption scheme used by your rom. there's software only encryption and hardware-accelerated encryption of many types for different hardware. the on-disk formats are incompatible. you need to find a twrp build that is compatible with your rom. obviously official twrp isnt.

149113 commented 7 years ago

I wanted to run your second script because you had put some effort into it, so I backed up data and settings and did a complete factory reset and wipe. The script throws an error. The exact syntax is: The updater process ended with ERROR: 6

Lanchon commented 7 years ago

it didnt output anything else?

149113 commented 7 years ago

There was some syntax ahead of that error but it ends pretty quickly compared to the other one. Does it create a log I can send?

Lanchon commented 7 years ago

there was a syntax error. try this one: [delete-backup-of-stock-rom-ovation.zip]

149113 commented 7 years ago

Ran it again with the new file. Different error:

Could not find 'META-INF/com/google/android/update-binary' in file. Error installing zip file '/external_sd/lanchon-repit-20161112-factory=32M-system=1G-cache=32M+wipe-data=max-ovation_UNTESTED.zip

Lanchon commented 7 years ago

thanks!

in this post: https://github.com/Lanchon/REPIT/issues/57#issuecomment-260106746

you forgot to extract the zip on the PC, and THEN rename it. (i double-zipped it because github messes with the symbols (=, -, etc) in the filename.)

Lanchon commented 7 years ago

btw, if your device is wiped, you might want to use -data=max+wipe to wipe data and make repit much, much faster.

and given that this is an old device, you might want to use -data=max+wipe+f2fs to wipe data and change to f2fs (if your rom supports it). you can't resize f2fs (without wiping) but it seems to be a lot faster for old devices. (there have been some incidents of data loss in f2fs, but some commercial devices (motorola) come configured with it.)

149113 commented 7 years ago

I extracted delete-backup-of-stock-rom-ovation.zip and it's just single zipped with the Meta folder at the first level.

Lanchon commented 7 years ago

lol, ok here we go again:

1) flash this file just the way you download it: https://github.com/Lanchon/REPIT/issues/57#issuecomment-261621206 (i think you already did this.)

2) download this zip file: https://github.com/Lanchon/REPIT/issues/57#issuecomment-260106746

3) extract that zip file on the PC: a lanchon-repit-2016....zip file will be extracted.

4) rename THE EXTRACTED file to: lanchon-repit-20161112-factory=32M-system=1G-cache=32M+wipe-data=max-ovation_UNTESTED.zip (or change the -data part according to your liking.)

5) flash it

149113 commented 7 years ago

Initially I thought that second zip file was nothing more than an update of the initial file, hence the confusion. So the first zip file runs fine with no errors. The second one throws an error when I modify the data= part. The error is toward the end of the script:

**FATAL: the new partition size is estimated to be too small to hold the current contents of the file system by 319 MiB.

Updated process ended with ERROR: 1**

Just for reference the new .zip name is: lanchon-repit-20161112-factory=32M-system=1G-cache=32M+wipe-data=max+wipe+f2fs-ovation_UNTESTED.zip. I've tried with both suggested data=parts and the result is the same error. Also the script throws an error being run from an external SD card. It copies itself to the \tmp and runs from there.

Edit: I've changed it back to the original data= syntax and it gives the same error

Log file attached

lanchon-repit.txt

Lanchon commented 7 years ago

lol, ok, sorry.

i don't know, it must have been late, i coded the script to delete the wrong file: rombackup.zip instead of factory.zip

rombackup.zip is where your valuable data backup is, or rather was. but not to worry: i will extract the file from the backup you sent me and email it back to you for sake keeping. if you ever need to repair your device, you will have the file in your email account.

now back on track... i fixed the script, published repit for ovation, and added a short how-to about gaining the extra 0.5G on /data.

if you want you can follow the how-to, it's here: https://github.com/Lanchon/REPIT/issues/59

i will close this issue now but you can continue to post here.

sorry and thanks for everything!

wojtasys commented 7 years ago

Hi I have a problem with HD+ described here: https://forum.xda-developers.com/showthread.php?t=2062613&page=142 "Post-Trimmer bootloop". Seems like either the eMMc is borked or the partitions are corrupt: Were the former the case, would it be possible to recreate the partitions? I'd appreciate any ideas, thanks. W.

wojtasys commented 7 years ago

Sorry, were the latter the case...ie if the partitions were corrupt..

Reckless71 commented 4 years ago

Hello @Lanchon

I messed my Nook HD+ partitions by wrongly configure your script by omitting some values which was worked for me perfectly earlier.

Please help me to recover / rebuild the partitions. Thanking you in advance.