[REPARTITION] Nexus 7 (2013) Repartition [FLO/DEB] [16GB/32GB] [UA TWRP]

Search This thread

quaxe

New member
Jun 15, 2021
3
0
To reverse it, or in other words restore stock partitions, just install sysrepart-stock.


"To recover from other repartition attempts, simply install sysrepart-ultimate if you intend to use LOS17+ or sysrepart-stock if you have other plans. If direct sysrepart installation is impossible due to TWRP or GPT issues, run the repartition.bat script."

CROSS - Custom ROM Scripted Setup
Thanks for your response. I tried sysrepart-stock, and tried flashing the full OTA image (6.0.1) and it hangs on boot at the 4 colored icons. I also tried flashing factory image using fastboot, when I do that it gets to the google screen and immediately reboots. I did the sysrepart-stock between attempts. Doing some more research I came across your post here where you suggested using fresh persist https://forum.xda-developers.com/t/bootloop-fix-for-nexus-7-2013-when-flashing-doesnt-help.3783564/ I also tried jackhill's method and tried flashing the old factory image even though you said it wasn't necessary because i wanted to exhaust all options before posting back here. Is this thing done for? or are there some other things I can try?
 

k23m

Senior Member
Jan 3, 2016
1,003
598
Thanks for your response. I tried sysrepart-stock, and tried flashing the full OTA image (6.0.1) and it hangs on boot at the 4 colored icons. I also tried flashing factory image using fastboot, when I do that it gets to the google screen and immediately reboots. I did the sysrepart-stock between attempts. Doing some more research I came across your post here where you suggested using fresh persist https://forum.xda-developers.com/t/bootloop-fix-for-nexus-7-2013-when-flashing-doesnt-help.3783564/ I also tried jackhill's method and tried flashing the old factory image even though you said it wasn't necessary because i wanted to exhaust all options before posting back here. Is this thing done for? or are there some other things I can try?

If you can use Windows, do Restock and k23m-persist-fix2.zip

"If you see errors, copy and report them... run relog.bat and attach "relog-xxxxxx.zip" to your post."​

Post your logs in the Restock's thread. If you can not use Windows, then PM me.
 

quaxe

New member
Jun 15, 2021
3
0
If you can use Windows, do Restock and k23m-persist-fix2.zip

"If you see errors, copy and report them... run relog.bat and attach "relog-xxxxxx.zip" to your post."​

Post your logs in the Restock's thread. If you can not use Windows, then PM me.
That seemed to do the trick, I ran restock.bat from Restock2 and installed k32m-persist-fix2.zip from TWRP and about 10min later it finally booted. I thought this thing was gone...Thank you!
 

olekor

Member
Aug 27, 2014
18
0
I have installed "lineage-18.1-20211008-UNOFFICIAL-flo" by using djibe Nexus 7 2013 pack using repartition "sysrepart_1280_120",
I then via TWRP("twrp-3.5.2_9-0-flo") attempt to flash gapps "MindTheGapps-11.0.0-arm-20210920_083829"- error:1,could not mount /mnt/system/aborting
also "open_gapps-arm-11.0-nano-20211007-UNOFFICIAL"- I got Error 70. Before this repartition, I have tried repartition by using "flo-deb_clamor_repartition" to flox, but again something was wrong after running the command within the ADB shell: modify.
So I was completely confused about how should be made repartition system partition.
Besides these troubles, I need to each time flash TWRP when I try to get in RECOVERY from bootloader mode.
Could be somebody who has enough experience can direct me to the right way.
 

Attachments

  • log-20211022101759.txt
    15.9 KB · Views: 7
  • open_gapps_log.txt
    4.3 KB · Views: 5

k23m

Senior Member
Jan 3, 2016
1,003
598
I got Error 70. Before this repartition, I have tried repartition by using "flo-deb_clamor_repartition" to flox, but again something was wrong after running the command within the ADB shell....
Could be somebody who has enough experience can direct me to the right way.


You need a larger 'system' partition - use CROSS' scripts:

sysrepart-ultimate.zip - 4GB system, data is wiped, 'vendor' partition is added, 'recovery' is enlarged to 64MB in-place and your current TWRP continues to function, flox compatible, automatically downloaded by LOS 18.1-flox script

sysrepart-stock.zip - data is wiped, original partitions are restored

  • reboot immediately after repartition!
  • sysrepart-ultimate/stock work on any previous repartitions
  • sysrepart/max/flox work reliably only on original partitions
  • to install GApps larger than pico/nano you need sysrepart-ultimate
  • sysrepart-ultimate supports custom, oversized TWRP builds
To recover from other repartition attempts, simply install sysrepart-ultimate if you intend to use LOS17+ or sysrepart-stock if you have other plans. If direct sysrepart installation is impossible due to TWRP or GPT issues, run the repartition.bat script. On rare occasions you may have to run RESTOCK and "Restore original partitions" with it.

:coffee:
 

olekor

Member
Aug 27, 2014
18
0
You need a larger 'system' partition - use CROSS' scripts:



:coffee:
following your advice, but I don't blame you, my N7 become bricked-continuous boot GOOGLE, tried "Nexus 7 2013 Unbricking Guide for Windows 10 x64 - revised and simplified", but MiFlash doesn't recognize N7, very regret, would be better to remain, as was-in previous condition-without repartition.
Update: I have recovered by Restock to the latest stock image, but can't connect wi-fi, as I don't use a password, it's a really stupid situation.
 
Last edited:

lostdistance

Member
Nov 26, 2011
5
0
I wanted to install LineageOS 18.1 and followed their wiki (https://wiki.lineageos.org/devices/flox/install) but the repartitioning was unsuccessful.

I landed on this page because I encountered the same "mke2fs" command failures. In case it may be of help to others, this is how I fixed it.

I was installing lineage-18.1-20211206 on my Nexus 7 (2013), which previously had Google's stock Android 6.0.1 (MOB30X). My host was a Linux PC.

The installation instructions proceeded smoothly until I loaded the flo-deb_clamor_repartition_20201203.zip repartition scripts and ran the "modify" command (output attached). The "modify" command reported some progress, some errors, and then seemed to hang.

Eventually I decided to terminate adb by hitting Control-C. To my surprise this did not terminate adb, as I expected, but instead terminated the "modify" command (or whatever followed), returning me to the adb shell prompt. This then provided the opportunity to complete the "modify" command by hand.

After reviewing the repartition scripts within the ZIP file, I was able to determine that it was flo-deb_kingston_repartition_32GB.sh which failed. Specifically, the four "mkfs.ext4" commands:

Code:
mkfs.ext4 /dev/block/mmcblk0p22
mkfs.ext4 /dev/block/mmcblk0p23
mkfs.ext4 /dev/block/mmcblk0p30
mkfs.ext4 /dev/block/mmcblk0p31

When I ran these directly from the adb shell they succeeded. I then resumed the installation instructions by rebooting the device. Eventually I finished the installation successfully. My Nexus 7 is now running LineageOS 18.1, seemingly without any problems.

If I were to guess as to what went wrong with the repartition script, I would suspect a race condition between the "parted" command and the subsequent "mkfs.ext4" commands. The repartition script made no attempt to ensure that the partition table changes had propagated throughout the system before attempting to use them. This is achieved in Linux, for example, by using the "blockdev", "partx", "hdparm", or "partprobe" commands. I would presume that adb shell has something similar available to it.
 

Attachments

  • modify.txt
    2.5 KB · Views: 51

jhford

Senior Member
I landed on this page because I encountered the same "mke2fs" command failures. In case it may be of help to others, this is how I fixed it.

I was installing lineage-18.1-20211206 on my Nexus 7 (2013), which previously had Google's stock Android 6.0.1 (MOB30X). My host was a Linux PC.

The installation instructions proceeded smoothly until I loaded the flo-deb_clamor_repartition_20201203.zip repartition scripts and ran the "modify" command (output attached). The "modify" command reported some progress, some errors, and then seemed to hang.

Eventually I decided to terminate adb by hitting Control-C. To my surprise this did not terminate adb, as I expected, but instead terminated the "modify" command (or whatever followed), returning me to the adb shell prompt. This then provided the opportunity to complete the "modify" command by hand.

After reviewing the repartition scripts within the ZIP file, I was able to determine that it was flo-deb_kingston_repartition_32GB.sh which failed. Specifically, the four "mkfs.ext4" commands:

Code:
mkfs.ext4 /dev/block/mmcblk0p22
mkfs.ext4 /dev/block/mmcblk0p23
mkfs.ext4 /dev/block/mmcblk0p30
mkfs.ext4 /dev/block/mmcblk0p31

When I ran these directly from the adb shell they succeeded. I then resumed the installation instructions by rebooting the device. Eventually I finished the installation successfully. My Nexus 7 is now running LineageOS 18.1, seemingly without any problems.

If I were to guess as to what went wrong with the repartition script, I would suspect a race condition between the "parted" command and the subsequent "mkfs.ext4" commands. The repartition script made no attempt to ensure that the partition table changes had propagated throughout the system before attempting to use them. This is achieved in Linux, for example, by using the "blockdev", "partx", "hdparm", or "partprobe" commands. I would presume that adb shell has something similar available to it.
Is your device a Flo or a Deb and does it have16GB or 32GB of storage?
 

extremko

Member
Nov 16, 2012
22
1
5
I think I have a big problem. Let me try to describe what I did and hopefully someone can help me out of a bricked Nexus.

This is what happened, to the best of my recollection:

I followed the "Install LineageOS on flox" tutorial - https://wiki.lineageos.org/devices/flox/install
Got to the Repartition section, step 4. I started the adb shell and executed "modify".

The command seems to have been running fine, but at some point just stopped. No changes or updates on either the terminal or the Nexus.
This is a paste from the terminal: https://justpaste.it/84c0f

At that point, I suspected my USB cable got disconnected so I didn't get the update. I replugged the cable and continued. If there was an error, further steps would fail, right?

Rebooted to recovery because the device didn't reboot itself automatically. I probably should have started freaking out here. I continued with steps 6 and 7. Wipe data and flash new Lineage recovery over TWRP
Code:
> fastboot -w

> fastboot flash recovery lineage-18.1-20211227-recovery-flox.img

Well, ****. My new Lineage recovery started reporting issues with file system mount points.

Image: Text at the bottom:
Code:
E:Failed to bind mount /mnt/staging/emulated/media/0 to /storage/emulated: No such file or directory
E:emulated failed to bind mount /mnt/staging/emulated/media/0 to /storage/emulated: No such file or directory

NOW I started freaking out.

OK, OK... I will just sideload Clamor Repartition zip again, like in the step 3.

Code:
> adb sideload flo-deb_clamor_repartition_20201203.zip
adb: sideload connection failed: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.
adb: trying pre-KitKat sideload method...
adb: pre-KitKat sideload connection failed: device unauthorized.
This adb server's $ADB_VENDOR_KEYS is not set
Try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.

What?

Code:
> adb devices
List of devices attached
090a26b7        unauthorized

No!!!

I checked "C:\Users\username\.android" and it has keys. Three files are present:
- adb_usb.ini
- adbkey
- adbkey.pub

adb_use.ini looks weird, a bunch of "0x####" which is probably normal
adbkey is a standard-looking private key
adbkey.pub looks like a public key, but ends with "unknown@unknown". Not sure if it did before. Had no reason to look :|

So now Nexus won't boot. And recovery doesn't work. I tried wiping and factory resetting. Nothing worked.



I can now throw away by dear old Nexus 7 now, right? :'(
 

extremko

Member
Nov 16, 2012
22
1
5
Hm. I managed to get recovery to "Apply update". Command 'adb devices' then shows
Code:
> adb devices
List of devices attached
090a26b7        sideload

I tried sideloading Clamor again, but that doesn't help, even though the result is "Install completed with status 0."

I still cannot get adb shell to work because device is still unauthorized.

Code:
> adb devices
List of devices attached
090a26b7        unauthorized

I think I probably deleted by computer key from Nexus when I wiped all the storages and need to bring it back in. Is there a way to use Sideload to push my key in somehow so the tablet trusts me again?

Then I can probably do all the other steps to recover from failed repartitioning... :/
 

extremko

Member
Nov 16, 2012
22
1
5
Thank you! I think I'm in a much better place now, although still having issues. I've posted a new comment in the CROSS thread.
 

NightLord

Senior Member
Sep 8, 2007
93
42
What is the point in adding a vendor partition for the N7? To my understanding having a vendor partition could provide for compatibility with GSI's, but I havent seen any vendor images for N7 floating around. If there is nothing to flash onto it, it is just a waste of space.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 80
    Nexus 7 (2013) Repartition​

    No one is responsible for your actions except yourself. Everything written further may potentially brick your device, although risk is reduced to minimum.

    This repartition package offers 1.5G /system; a /vendor partition and it is fully backward compatible with any ROM (including stock system.img).

    Known-issues
    HTML:
    - If repartition pack says that device isn't correct,
    than, if partition table wasn't modified before,
    congrats! your device has different memory chip
    that those I worked with. No worry, PM me and
    I'll add support for it.

    DO THE BACKUPs. Repartition will erase all your data
    USB connection to PC is MANDATORY else you will not have opportunity to push ROM to your device


    Backup


    # Before processing further we highly recommend you backup persist and EFS using adb
    # Or you might lose your IMEI/WIFI + BT mac addresses

    Code:
    adb root
    adb shell
    dd if=/dev/block/mmcblk0p2 of=/sdcard/modemst1.img
    dd if=/dev/block/mmcblk0p3 of=/sdcard/modemst2.img
    dd if=/dev/block/mmcblk0p4 of=/sdcard/persist.img

    Now you can find 3 *.img files at path /sdcard. Copy them to your PC since internal memory will be erased.


    Installation
    HTML:
    # This mod is backwards compatible with any ROM so we highly recommend NOT to reverse it if repartition went well.
    # You should use ONLY recovery from this thread since other don't support all benefits of this mod.
    # When installing ROM just after you flashed zip and before installing GAPPs you MUST make a resize in TWRP since all roms are build for ~800M system.
    # Package is unified for flo and deb. To restore stock layout use same zip and steps as for repartition.
    
    1. Boot into recovery (You need to allow system partition modification to be able resize /system in recovery).
    2. Backup your data & Move your files from flash to your PC.
    3. Flash repartition pack zip.
    4. Do the actions asked by repartition pack (go to Terminal in ordinary recovery and input word that pack will tell you. Everything else will be done automatically).
    5. Phone will reboot into recovery.
    6. Install TWRP from below (it is build with support of new partitions layout and sizes. It can be differed from official TWRP by next format 3.x.x-1 UA).
    7. Format everything. (mount errors will not affect formatting!)
        - In TWRP: Wipe > Format data
        - Type yes
        - Once this completes go to: Wipe > Advanced Wipe
        - Tick all the boxes and wipe. There should be no further mount errors. (Thanks [user=7694808]@mr_rubbish[/user] for corrections in formatting).
    8. Install ROM which you like.
    9. Enjoy better flash partition layout.

    If something gone wrong - we recommend you NOT to do anything by yourself. Write here for help, else you may do only worse.

    Downloads:
    Repartitioning package
    : GitHub

    Credits:
    Special thanks to
    - Unlegacy-Android team;
    - Sudokamikaze;
    - rlw6534 for Kingston MMC layout;
    - surfrock66 for his gide for Nexus 5;

    As usual, feedback is appreciated :)

    XDA:DevDB Information
    Nexus 7 (2013) Repartition, Tool/Utility for the Nexus 7 (2013)

    Contributors
    Clamor
    Source Code: https://github.com/clamor95/android_device_unlegacy_recovery


    Version Information
    Status:
    Stable

    Created 2018-09-19
    Last Updated 2019-01-18
    17
    Common issues and F. A. Q.

    Repartition pack should be safe for most devices. Common mistakes, issues and their solution will be published here.

    1. You shouldn't flash any internal parts of repartition pack (*.sh files) only flash whole zip using TWRP. You may use my scripts for personal use or projects but authorship should to be kept.

    2. If something isn't mounting after repartition try to format partitions that don't mount using Wipe -> Advanced Wipe in TWPR. Ideally you should format in that way all partitions in Advanced Wipe menu (see 5-th step of installation guide).

    3. If you want to be sure that repartition went well I enclose loging zip. Flash it after repartition (when device reboots into TWRP). It won't modify anything only generates a partition.log in root of internal storage and outputs your current partition layout to screen. You should check if your layout is same as those fragments I provide under spoiler (file systems doesn't matter). If there are any differences you have to describe what you did and enclose partition.log to your post.


    FLO/DEB STOCK
    Code:
    22      671088640B   1551892479B   880803840B                 system
    23      1551892480B  2139095039B   587202560B                 cache

    FLO/DEB MODIFIED
    Code:
    22      614429696B   2187293695B   1572864000B                system
    23      2187293696B  2270167039B   82873344B                  cache
    ...
    30      2348843008B  2610987007B   262144000B                 vendor
    4. After flashing most ROMs system size will reduce to stock, you need to resize /system in TWRP or use flashable resize zip for ROMs that support addon.d (automatic resize when dirty flashing updates).

    5. After returning to stock partition table you won't be able to get into the Recovery from the bootloader anymore, but when you start the tablet normally it goes straight in the Recovery. It is normal state. New partition table proposes larger /recovery size (16MB) while stock gives only 10MB. During restoring stock process, it is impossible to restore larger recovery backup into new smaller partition. Whether not to leave user without recovery excess, recovery backup restores into /boot partition. Just flash ordinary TWRP and install ROMs from it.

    6. Don't install the zip file from the USB OTG. Copy them into the /sdcard. Else you will get message after flashing repartition pack.
    Code:
    "Can not extract updater-script. Do you have it in package?
    Updating partition details...
    ...done"
    15
    Flashable /system resize with addon.d support

    Here is a flashable zip that will resize the filesystem on /system back to the full partition size after a ROM install. It also includes an addon.d script that will allow upgrades/dirty flashes with persistent GAPPS and Magisk for ROMs with addon.d support (not UA). The addon.d simply resizes the filesystem before the other persistence scripts run. Note that this zip does not change or otherwise mess with the actual partition size - that needs to be performed prior to ROM installation with Clamor's script or other method.

    Simply flash after initial ROM installation. For ROMs without addon.d support (like UA), this script needs to be flashed every time before GAPPS reinstall. For ROMs with addon.d support, you only have to flash once. If you already have a ROM with addon.d support installed, flash this zip before the upgrade/dirty flash to add the addon.d script to /system.

    Thanks to Clamor for support and building the flashable zip!

    Tested on UA and AICP with multiple size GAPPS and Magisk but should work with any ROM...
    7
    Wiping partitions after resize.

    In case someone else gets the same problem as me, I thought I'd share what I did to complete the process successfully.

    -I pushed the repartition.zip file to the device and executed it with TWRP.
    -It completed and rebooted.
    -When i tried to wipe the partitions they all failed with a mount error. Tried multiple times, identical results.
    -Pushed LineageOS zip to device and attempted install. It finished with an Error 7. Essentially a complete failure to install. I think it was something about being unable to mount one of the partitions.

    How I fixed it
    - In TWRP: Wipe > Format data
    - Type yes
    - Once this completes go to: Wipe > Advanced Wipe
    - Tick all the boxes and wipe. There should be no further mount errors.


    However, I wonder if things might have been smoother if the instructions recommended installing the custom TWRP image as step 3, instead of towards the end of the process?
    Anyway, I hope that someone finds these instructions useful!
    4
    @L.F.B. that script is much simplier and offers less opportunities. For some device models (nexus 7 2013 for example) advanced solution is needed. Second is that I can't republish other devs work. Third is that repartition schemes are incompatible with each other and variety of them actually slows down further development. My current repartition for nexus 5 should have no problems.

    @lollyjay UA TWRP is needed to support /vendor partition. Sizes aren't that important for recovery, like for system image, although sizes of partitions are published in my device trees and can be cherry-picked.