[EVO 4G Android Development] fldash:
In case anyone want's to resize their System, Cache, and Userdata partitions on their EVO. This may be useful for some of the newer ROMs that require a larger system partition.

Default partition sizes for EVO are 350MB for System, 160MB for Cache, and 427.625MB for Userdata.

I did not create this. It was developed by FireRat who's account is now inactive on XDA. I started looking into it because I wanted to resize my Boot partition from 2.5M to 3M because I have bad NAND blocks in my Boot partition and can't flash ANY Sense-based Gingerbread ROM, even the leaked official one from HTC. I get the following error when debugging by flashing the boot.img using Fastboot:

FAILED (remote: image update error) ...

With all that said, it doesn't work to resize your Boot partition. I modified the source to make it resize Boot partition as well, it passes the parameters to the kernel correctly, but the system does NOT like it and gives a bunch of errors about unsupported block addresses. If you want to read more about this issue, see my post: here

How This Works

This is simple a shell script that extracts the recovery and/or boot images and modified the commandline passed to the kernel so that it recognizes different partition mappings for the NAND partitions.

Warnings

First of all, there is no brick risk if you have Fastboot access (.76 ENG HBOOT). That said, I'm not in anyway responsible if something happens and your device gets bricked. Two things could potentially go wrong:

* Recovery Flash Corrupt - This happened to me a few times when I was playing with trying to get the Boot partition to change sizes, but never when I was just attempted to resize System, Cache, and Userdata.

Easiest way to fix is to re-flash the recovery.img from Fastboot. You may also be able to re-flash the recovery via your ROM using ROMManager.

* Corrupt System, Cache, and Userdata partitions - This will happen if you don't wipe the three partitions after you do the resizing. You need everything removed from them because their start points are being remapped.

To fix this, you can use Fastboot:

fastboot erase system -w

You can also use your recovery (advanced menu) and manually wipe System, Cache, and Userdata.

I Understand What Has Been Said, Let's Get Started

1. Before you begin, you need to create a file on the root of your sdcard called mtdpartmap.txt. This file is where we set the partition sizes we want. To create this file, you can use adb shell or a terminal program on your phone. Simply type:

echo "mtd 350 160" > /sdcard/mtdpartmap.txt

Replace 350 and 160 with the sizes you want your System and Cache partitions. Your Userdata partition is automatically given the remained. For example, if I used "mtd 300 100" I would be gaining 110MB on my Userdata partition ((350-300)+(160-100) = 110). Your sizes must be divisible by .125.

2. Make a nandroid backup. After we modify the partition sizes for the recovery, you can restore it, or you can flash a whole new ROM.

3. The next step is to Flash a file in recovery. I recommend you Flash the recovery-v1.5.9-Alpha3-CustomMTD_TESTRUN.zip. This will NOT perform any changes, only make sure everything looks good. If you get no errors here, you can then proceed.

4. Wipe System, Cache, and Userdata. This is very important. You have a nandroid backup.

5. Flash recovery-v1.5.9-Alpha3-CustomMTD_R.zip, This will make the changes to your recovery.img and re-flash it to your phone. All it's doing is adding kernel commandline parameters so that the recovery knows where your System, Cache, and Userdata partitions start.

6. Reboot recovery. This is easier in CWM than RA. CWM offers a menu option for it. In RA, I normally just select the menu item to power off. Then restart the phone and hold volume down, then select Recovery from the Bootloader menu.

7. Nandroid restore or flash a new ROM.

8. Very important! Flash boot-v1.5.9-Alpha3-CustomMTD_S.zip. This does basically the same thing as in Step 5 but instead of changing the kernel commandline for recovery, it does it for your boot.img.

9. Reboot.

Important Notes

If you ever flash your recovery to a new version, or change recoveries, you must redo step #5 so that your new recovery has the partition sizes and start points passed to it.

If you ever flash a new ROM, you must perform step #8 again so that the ROMs kernel has the partition sizes and start points passed to it.

Reverting/Backing Out

1. Make a nandroid backup if you want to keep your current ROM. If not, or you will be restoring a previous nandroid backup, you can skip this step.

2. Wipe System, Cache, Userdata. This is very important.

3. Flash recovery-v1.5.9-Alpha3-CustomMTD_REMOVE.zip. This will remove the kernal commandline from the recovery and boot partitions.

4. Reboot recovery.

5. Nandroid restore or flash a new ROM.

6. If you restored a nandroid backup that had custom partitions mapped to it, you must re-flash recovery-v1.5.9-Alpha3-CustomMTD_REMOVE.zip at this point so the restored boot.img has the kernal commandline removed.

6. Reboot.

Other Thoughts

If anyone has any ideas on how to resize the Boot partition, let me know.