• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[REPARTITION] Nexus 5 Repartition [HAMMERHEAD] [16GB/32GB] [UA TWRP]

Search This thread

Clamor

Senior Member
Sep 4, 2013
369
673
Львів
Nexus 5 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


Installation

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

# 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 ~1G system.
# 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.
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;
- surfrock66 for his gide for Nexus 5;

As usual, feedback is appreciated :)

XDA:DevDB Information
Nexus 5 Repartition, Tool/Utility for the Google Nexus 5

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
 
Last edited:

Clamor

Senior Member
Sep 4, 2013
369
673
Львів
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. 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 shoud 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 discribe what you did and enclose partition.log to your post.

HAMMERHEAD STOCK
Code:
25      192937984B    1266679807B   1073741824B                system
26      1266679808B   1298137087B   31457280B                  crypto
27      1298137088B   2032140287B   734003200B                 cache

HAMMERHEAD MODIFIED
Code:
25      192937984B    1803551231B   1610613248B                system
26      1803551232B   2065695231B   262144000B                 vendor
27      2065695232B   2097152511B   31457280B                  crypto
28      2097152512B   2306867711B   209715200B                 cache
4. Flashable resize zip for ROMs that support addon.d (automatic resize when dirty flashing updates).

5. To backup persist partition you need PC with installed adb. Boot your hammerhead in TWRP and plug to PC. Than use next commands.
Code:
adb root
adb shell
dd if=/dev/block/mmcblk0p16 of=/sdcard/persist.img
Than copy .img file from root of internal storage to your PC. Although, script doesn't affect that area, backup of this partition may help in case of any problems with mac address etc.
 
Last edited:

getrooted0019

Member
Apr 10, 2016
10
1
Navi Mumbai
Vendor partition means support for treble.... Right?

---------- Post added at 04:11 AM ---------- Previous post was at 03:44 AM ----------

After flashing a ROM the system partition resizes back to 1009mb...
Can this be fixed?
 
Last edited:

sinkoo1979

Senior Member
@sinkoo1979 send me your partition table in bytes

Data and vendor partitions in my nexus 5 are 0mb and not present. System showing about 1028mb while cache is on 29mb.
Thank you for your help but can't change the cache storage back to stock. Can't access the internal storage in TWRP. I think I corrupted my partitions on the nexus 5. Nexus 5 boots into TWRP but can't access nothing. Tried to flash different rom with OTG but bootloops. Can't flash stock because the cache partition is too small.
 
Last edited:

typow102

Senior Member
Nov 30, 2013
153
49
Grand Rapids
This is fixable! I was a noob and didn't resize my system partition after flashing rom. Flashed the hh repartition to go back to stock in the ua twrp and got a bunch of errors. Then flashed stock recovery and tried again. This is not a Nexus 5 popped up. The backup file is inside the flashable zip. I just used adb shell and parted to execute the commands listed in backup and viola my Nexus 5 is back. So those freaking out that they messed up their phone...don't worry it's fixable just listen to Clamor. Anyone can pm me too if you need help.
 

Clamor

Senior Member
Sep 4, 2013
369
673
Львів
@typow102 if repartition pack says "It is not Nexus 5" than you shouldn't continue without asking here. Using scripts from pack on them own is dangerous as well. Currently I don't know how many types of MMC installed in our Nexus 5 and "It is not Nexus 5" on repartition or on returning to stock may indicate a new type MMC chip like it was with Nexus 7 (2013)
 
  • Like
Reactions: ze7zez

typow102

Senior Member
Nov 30, 2013
153
49
Grand Rapids
@typow102 if repartition pack says "It is not Nexus 5" than you shouldn't continue without asking here. Using scripts from pack on them own is dangerous as well. Currently I don't know how many types of MMC installed in our Nexus 5 and "It is not Nexus 5" on repartition or on returning to stock may indicate a new type MMC chip like it was with Nexus 7 (2013)

That's the thing though It worked perfectly the first time I flashed it. No errors. Luckily I have had quite a bit of experience with terminal and parted so I felt confident in what I was doing. Can I help you in any way with this? There very well maybe a different mmc chip we don't know about yet.
 
  • Like
Reactions: Clamor

Clamor

Senior Member
Sep 4, 2013
369
673
Львів
For those who downloaded repartition pack before this message is published, please redownload pack since previous version might have a problems with repartition. If repartition was already made, don't worry everything should be fine. Just use up-to-date pack.
 
Last edited:
  • Like
Reactions: ze7zez and Kotaless

froilson

Senior Member
Dec 14, 2007
59
157
OnePlus 7 Pro
When I install the ROM (crDroid 4.6) after change the partitions, when I go to TWRP, Wipe > Advanced Wipe, selecting system and pushing over Repair or Change File System button and then over Resize File System, this message was shown:
Repairing system before resizing.
Repairing system using e2fsck...
Done.
Resizing...
/sbin/resize2fs /dev/block/mmcblk0p25 process ended with ERROR: 1
Unable to resize system.
So no resizing is made.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    How u fix? Plz share
    I followed the instructions in OP. Apparently I misunderstood them. Instead of booting into whatever Recovery is installed on the Nexus 5, boot into the Recovery on the Github page. Then follow the rest of the instructions.
  • 53
    Nexus 5 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


    Installation

    HTML:
    # Before processing further we highly recommend you backup persist using terminal and dd comand and EFS
    # Or you might lose your IMEI/WIFI + BT mac addresses
    
    # 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 ~1G system.
    # 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.
    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;
    - surfrock66 for his gide for Nexus 5;

    As usual, feedback is appreciated :)

    XDA:DevDB Information
    Nexus 5 Repartition, Tool/Utility for the Google Nexus 5

    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
    13
    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. 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 shoud 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 discribe what you did and enclose partition.log to your post.

    HAMMERHEAD STOCK
    Code:
    25      192937984B    1266679807B   1073741824B                system
    26      1266679808B   1298137087B   31457280B                  crypto
    27      1298137088B   2032140287B   734003200B                 cache

    HAMMERHEAD MODIFIED
    Code:
    25      192937984B    1803551231B   1610613248B                system
    26      1803551232B   2065695231B   262144000B                 vendor
    27      2065695232B   2097152511B   31457280B                  crypto
    28      2097152512B   2306867711B   209715200B                 cache
    4. Flashable resize zip for ROMs that support addon.d (automatic resize when dirty flashing updates).

    5. To backup persist partition you need PC with installed adb. Boot your hammerhead in TWRP and plug to PC. Than use next commands.
    Code:
    adb root
    adb shell
    dd if=/dev/block/mmcblk0p16 of=/sdcard/persist.img
    Than copy .img file from root of internal storage to your PC. Although, script doesn't affect that area, backup of this partition may help in case of any problems with mac address etc.
    12
    3.3.1-1 UA TWRP is already available in download section.
    10
    thanks this really work

    thanks Clamor you are a life saver
    This solves my TWRP Error 70: Insufficient storage space available in the system partition when installing custom ROM

    i think direction is not so clear for people who hasn't done many custom rom flash
    WARNING: I did a clean install and WIPE ALL DATA.

    a bit details here
    1. download hh_clamor_repartition.zip & twrp-3.2.3-1_UA-hh.img. In addition, download the Open GAPP ARM PICO .zip from Open GAPP (depend on which android os version). Nexus 5 is an ARM.
    2. go to Recovery via either custom rom restart that can select Recovery, or after shutdown the phone, hold both volume up & down, then power button to force to Recovery.
    3. backup data from your phone to PC. copy the hh_clamor_repartition.zip to phone
    4. In Recovery, select Install, pick hh_clamor_repartition.zip UNCHECK "reboot after installation is complete". if you don't do this, then you wouldn't see the msg tell you to go to Advanced > Terminal and type "modify"
    5. once the repartition is done. it will reboot to Recovery, here go to Reboot to Bootloader
    6. on your PC, open command prompt in the adb folder. type Fastboot flash recovery twrp-3.2.3-1_UA-hh.img. once it is successful. on your phone, the bootloader screen, use volume up or down to find Recovery, and use power button to select it.
    7. in Recovery, select Wipe > Format Data > type YES. no need to reboot
    8. go back to Wipe > Advanced Wipe > CHECK all boxes, then Swipe to Wipe
    9. connect phone to PC (you should already have ADB). make sure you are in TWRP and Mount your phone.
    10. copy Custom ROM & Open GAPP ARM PICO .zip to phone
    11. in Recovery, select Install. Pick the Custom ROM that you want to flash. UNCHECK "reboot after installation is complete" before installation. do not reboot
    12. use back arrow, select your OPENGAPP .zip file and install. after this, you can reboot

    the initial boot will take a while, but it works.
    i flashed RR-P-v7.0.2-20190505-hammerhead-Official.zip & open_gapps-arm-9.0-pico-20190522.zip on my Nexus 5 16GB

    Once again, i need to thank Clamor for providing this wonderful tool.
    4
    I do hope someone can still help me. I have installed android 10 to my nexus 5 but I can't install the latest gapps (even the pico version) due to lack of space in the partition.

    Assuming you followed the steps and actually completed the (re)partition part.

    You now have an 1.5G system partition and this will never change unless you manually partition the device again.

    This is different than resizing an image.

    If the rom installer does not include automatic resizing, you will be left with only the size the rom was built for. If it was built for a 1G system then, you will only have 1G available to use, .

    Do a complete clean flash. (This will erase everything on the device.)
    TWRP-> Advanced-> Wipe-> Format (Type Yes) enter.
    TWRP-> Advanced-> Wipe-> Check all and Swipe to wipe
    Reboot Recovery


    Then install the rom
    Mount system (either using TWRP or the command below.)
    Check the size (use th df command below.)
    - If you have 1.5G system then you are maxed out on space do to the rom.
    - If you show 1G system size, then you need to expand the image to fill the partition.

    To expand the system image, you can try using TWRP
    Wipe-> Advanced Wipe-> (select System) Repair or Change File System-> Resize File System

    This never worked well for me on hammerhead so, I also included the command below
    System needs to be unmounted to run resize2fs

    Good luck.

    Can someone please help this member writing about lack of space in a repartition thread?
    Edit: Apparently not...
    So, the first and most obvious glaring question - have you repartitioned your Nexus 5?
    Edit: After four days, nothing. Yet again. Yet another occasion where I try to help a junior member, to receive only silence. I am disinclined to bother any more.

    Sorry, some of us do not follow older/onetime use threads that well. :(
    Just a suggestion, you could have mentioned 2020suite in your edit just incase he/she gave up on a repose from this thread and wasn't watching it.

    No criticism.
    As a community (we could do better) should still try to help others.

    We were all juniors once. Thankfully it was a little different when I was and when I used the search function, I did not get overwhelmed by the same question being asked and repeated responses of use search. Either it was ignored, answered or pointed to a post the guided to the answer. (Now I hate searching on xda, the results in some threads are highly polluted.)

    Please do not give up on helping, even if it's a little bit when you can.
    Keep up the good fight :D

    Can you please help me? i repartitioned but it broke my partition table i suppose because everything showed 0MB in TWRP and when wiping it said "failed to mount '/everything' (Invalid argument)" when i tried to partition it to stock it spilled out some errors and when i tried again it said "This is not Nexus 5"

    Did you format the partitions ?

    TWRP-> Wipe-> Format Data (type yes) and tap enter
    TWRP-> Wipe-> Advanced Wipe (Select all) Swipe to Wipe
    TWRP-> Reboot-> Recovery


    This is for someone who flash factory image and get stuck.

    I did flashing factory image, and I got stuck on the boot.
    I could still get into bootloader, so flashed twrp and install other roms but still stuck.

    after that, I found this thread and... I found way to recover it.

    Have to go through repartition again. this time, it asks revert back to stock.
    and then, do it again to modify partition.
    after flash twrp, it shows vendor partition error. dont worry. after wipe(format) it, it will be gone.

    then, you can install any rom you like, and.. my ancient N5 is back!

    If you use fastboot to flash the images manually (boot, system, recovery) you can along as you wipe everything first and then wipe cache and data/factory reset in recovery and reboot.

    It will not change anything as far as partitions but, you can run the last factory image this way if you want.

    Hello, hope there are still some active members who can help someone like me.

    I followed the instruction strictly but when I execute the zip I get the output:
    Can not extract updater-script. Do you have it in package?
    Updating partition details...
    Failed to mount '/vendor' (Invalid argument)
    ...done


    I never reach the "Type something into your terminal part" .

    Now I get the mount error every time I try to do something in recovery but that doesn't seem to have any effect I was able to get my system back running by loading a backup. I tried to fix the mount error by "formatting data" and wiping everything. Didn't work.

    I am just copying the files from my PC to my phone and execute them with TWRP. So I don't get why a file should be missing. My Google/XDA search wasn't really successful so maybe someone of you encountered similar problems and can help with the mount error or the missing updater-script. Thanks.

    I assume you are using twrp-3.3.1-1_UA-hh
    The vendor mount error is because without running the script to actually partition the device, you do not have a separate vendor partition.

    If you use the regular TWRP and Format then wipe everything, do you still get an error?

    I've done it three times now.
    Factory to modified | Modified back to stock | Stock back to modified

    I do not remember how I did it originally.
    Might have pushed the zip to /tmp or /sideload and then used TWRP to install from there.

    The last two times I just used adb sideload to run the zip and then TWRP-> Advanced-> Terminal (type the key word) to continue the dark magic.

    I did it with the regular TWRP.
    Don't need the vendor partition yet so, I'm not that worried about formatting and mounting it.


    --------

    A few commands.
    Noted using adb shell.
    If used in TWRP Terminal, ignore the adb shell part.


    Mount system
    adb shell sbin/mount system

    Display file size (a=all mounted h=human readable)
    adb shell df -ah

    Unmount system
    adb shell umount system

    Resize system image on Nexus 5 Hammerhead
    adb shell resize2fs -f /dev/block/mmcblk0p25

    A few links that may help/explain.

    The regular official TWRP.
    Nexus 5 (Hammerhead) twrp.me - Link

    adb/fastboot [Part of platform-tool]
    SDK Platform Tools developer.android - Link

    Post I made in a different thread that includes a quick explanation of partitioning and resizing images.
    xdaThread [ROM][flo|deb][UNOFFICIAL][AospExtended-v7.0] - Link

    Cheers all. :cowboy: