[HOW-TO] Custom MTD Partitions [12/30/2010]

HebrewToYou

Senior Member
Feb 9, 2010
702
66
0
DISCLAIMER: Nobody -- and I do mean nobody -- is responsible for a bricked device except for the person attempting this modification. Do not contact me, Firerat, Cyanogen or anyone else to complain that you borked your Slide by not following instructions.


ORIGINAL THREAD
All credit for this work goes to Firerat and lbcoder -- especially to Firerat for making this so darn easy!

This post will provide instructions for resizing your device's MTD partitions.

PREREQUISITES:
  1. An understanding of basic arithmetic
  2. Familiarity with disk partitioning
  3. S-OFF

The Espresso has 465.1 MB to play around with and it ships with the following partition layout:

System: 240 MB
Data: 145.1 MB
Cache: 80 MB

You can check your current layout by launching an ADB SHELL and entering the following command:
Code:
busybox df -h
You will likely notice that the system partition has a *lot* of free space, likely well over 100 MB available! The instructions in this post will walk you through requisitioning that available space and putting it into the data partition, avoiding the need to ever use Apps2SD or Apps2EXT.

So let's get started...

Step 1: Downloading the necessary files

Firerat's Mediafire repository can be found here... You will need two files from it:
Download those files and place them on your sdcard.

Step 2: Configuring your partition scheme

As I mentioned earlier, by executing the busybox command you'll get an idea of how much empty space you have on your system partition. Your choices in the section depend entirely on the rom you are using -- for the sake of simplicity I will be assuming the use of a CM6-based rom.

So, once again, launch an ADB SHELL...

You're going to be executing an echo command to create a text file on the root of your sdcard -- this text file will contain the information needed to re-partition your internal memory. This is where you have to make your own choice about sizing -- here is the format of the command you must enter:
Code:
echo "mtd [SYSTEM SIZE IN MB] [CACHE SIZE IN MB]" > /sdcard/mtdpartmap.txt
For my partition scheme on an Espresso running CM6.1.1 I executed the following:
Code:
echo "mtd 140 1.5" > /sdcard/mtdpartmap.txt
NOTES:
  • If you're using a CM6-based rom you do not need a large cache partition as a script will bind-mount cache -- the smallest size you can set is 1.5 MB -- other roms have their own cache size requirements, so do your research before setting this to a low value.
  • All partition sizes must be rounded up to the nearest 0.125 MB, but I recommend using increments of 0.5 MB.

All the excess storage not set aside for system and cache will be used for the data partition.

Step 3: Getting your hands dirty

NOTE: If you had previously configured your device to use apps2ext you will need to perform one additional restoration in step 7. See below for more details...

So assuming you've now downloaded the two zip files (step 1) and added the mtdpartmap.txt file to the root of your sdcard (step 2), you're ready to proceed with the nitty-gritty work. For the sake of simplicity I'm assuming that during the S-OFF procedure you opted to [permanently] flash ClockworkMod Recovery 2.5.0.1 on your device.

  1. Boot your Slide into recovery -- my preferred method is to use ADB REBOOT RECOVERY.
  2. Execute a Nandroid Backup -- within recovery: nandroid->Backup
  3. Wipe your data and cache partitions -- within recovery: wipe data/factory reset
  4. Flash the recovery patcher -- within recovery: install zip from sdcard->choose zip from sdcard->recovery-v1.5.8-Beta-CustomMTD_S.zip
  5. Format the system, data and cache partitions -- within recovery: partitions menu->format [system/data/cache]
  6. Reboot into recovery -- within recovery: advanced->Reboot Recovery
  7. Execute an advanced Nandroid restore of system and data* -- within recovery: nandroid->Advanced Restore->[CHOOSE THE BACKUP]->Restore [system/data]
  8. Flash the boot patcher -- within recovery: install zip from sdcard->choose zip from sdcard->boot-v1.5.8-Beta-CustomMTD_S.zip
  9. Reboot -- within recovery: reboot system now

* Devices with apps2ext configurations must remember to nandroid restore the sd-ext partition as well.

And that should do it. Be patient on first boot as it may take a little longer than expected. To verify that your changes have worked you can repeat the busybox command I listed earlier:
Code:
busybox df -h
Moving forward, let's say you want to flash the latest CM6 nightly -- simply flash the nightly zip (and gapps if necessary) and, immediately after that, flash the boot patcher (boot-v1.5.8-Beta-CustomMTD_S.zip).

I do not plan to field questions in this thread, so if you're looking for support I suggest that you visit the #mytouchslide channel on Freenode IRC.

And, once again, ALL CREDIT goes to Firerat and lbcoder.
 
Last edited:

HebrewToYou

Senior Member
Feb 9, 2010
702
66
0
Additional Notes (provided by Firerat)​

Removal
There are two ways to remove customMTD ( to return to stock layout ):

  1. Flash an unmodified recovery.img (NOTE: You must format system, cache and data)
  2. Edit the mtdpartmap.txt to have a system size of 0 -- e.g. echo "mtd 0" > /sdcard/mtdpartmap.txt -- and flash the recovery patcher (NOTE: You must format system, cache and data)

Resizing
If you wish to resize, change the mtdpartmap.txt and flash recovery patcher (NOTE: You must format system, cache and data)

Recovery Upgrade
The easiest way to upgrade recovery is to flash manually in recovery via an ADB SHELL while booted into recovery:
Code:
mount /sdcard
flash_image recovery /sdcard/RECOVERY_VERSION#.img
NOTE: You do not need to format system, cache and data in this case as you are not resizing.

Again, thanks go out to Firerat for these additional notes.
 
Last edited:
  • Like
Reactions: Ccming

sleepykit

Senior Member
Sep 7, 2009
54
1
0
Denver
www.sleepykit.com
Many thanks for the clear instructions that were surprisingly easy to follow and the phone did boot up again just fine (as noted in the OP, the boot up took longer the first time around, but there is always
Code:
adb logcat
for anyone worried about what the phone is doing when it looks bored). Total data space is now 320 MB (and sleepykit is one happy kitten).
 

Firerat

Senior Member
Feb 24, 2009
3,848
185
0
@HebrewToYou

very good post

I think it's the clearest I have seen to date

just couple of points which I think would prove useful

Removal
there are two ways to remove customMTD ( to return to stock layout )

the first is to simply flash an unmodified recovery.img
Note You *must* format system, cache and data with clockwork or use
fastboot erase system -w

the second is to edit the mtdpartmap.txt to have a system size of 0
e.g.
  1. echo "mtd 0" > /sdcard/mtdpartmap.txt
  2. flash the recovery patcher
  3. again you must format system, cache and data

Resizing
if you wish to resize
  1. change the mtdpartmap.txt
  2. flash recovery patcher
  3. format system, cache and data

Recovery Upgrade
the easiest way to upgrade recovery is to flash manually
in recovery ( adb shell )
  • mount /sdcard
  • flash_image recovery /sdcard/recovery<version>.img
via running recovery ui
  • flash recovery patcher
Note, you don't need to format system, cache and data, as you are not resizing
 

Ace42

Senior Member
Jul 20, 2009
11,314
2,033
253
New York
On Cm based roms you should be able to shrink system to atleast 100, mines is currently 100MB, but actual usage is 89MB(I removed some stuff)
 

HebrewToYou

Senior Member
Feb 9, 2010
702
66
0
On Cm based roms you should be able to shrink system to atleast 100, mines is currently 100MB, but actual usage is 89MB(I removed some stuff)
You're free to make system whatever size you like -- my recommendations are just that: recommendations. The size I suggested will likely be large enough to accommodate CM7 when it is released -- I cannot say the same about 100 MB...
 

lilshortwun

Senior Member
Aug 29, 2010
146
3
0
nice tutorial. too bad im using cr-mod and current system usage is at 204. does this ever change or does it only change with different roms because I want to shrink it to about 210 but i dont want any hidden surprises
 

Ace42

Senior Member
Jul 20, 2009
11,314
2,033
253
New York
nice tutorial. too bad im using cr-mod and current system usage is at 204. does this ever change or does it only change with different roms because I want to shrink it to about 210 but i dont want any hidden surprises
Sense roms always have large system sizes, vanilla ones are normally under 100~. You can always delete some apps from sys that you dont want to shrink it even more, but there should be no hidden traps if you make it 210. I am so happy that we finally have mtd cause i dont use ext anymore and i dont like apps2sd either. On Cm I have 372 in total for data, which is more than enough for me.
 

HebrewToYou

Senior Member
Feb 9, 2010
702
66
0
does it make the phone faster or just more space to install the app?
It doesn't make the phone faster... It gives you fine control over how your phone's internal memory is allocated. If you're running a non-stock rom, there's no reason to have such a huge /system partition. This will allow you to remedy that.
 

guitarist5122

Senior Member
May 25, 2010
606
59
0
Delaware
thank you for this. didnt even know we had all the extra space on our phones

only thing is i didnt understand what was said about the cache. i noticed my phone was using >60MB so i gave it 80. wish i could have gotten it down to 1.5 like you did
 
Last edited:

HebrewToYou

Senior Member
Feb 9, 2010
702
66
0
thank you for this. didnt even know we had all the extra space on our phones

only thing is i didnt understand what was said about the cache. i noticed my phone was using >60MB so i gave it 80. wish i could have gotten it down to 1.5 like you did
Cache is not permanently stored data -- it's just a temporary repository. CM6-based roms will bind-mount /cache to /data if the size is too small, which it will be if you set it to 1.5 MB. That way you can repurpose the 80 MB of /cache and put it directly towards /data -- then /data becomes a shared space /data and /cache which is much better (IMHO).
 

guitarist5122

Senior Member
May 25, 2010
606
59
0
Delaware
Cache is not permanently stored data -- it's just a temporary repository. CM6-based roms will bind-mount /cache to /data if the size is too small, which it will be if you set it to 1.5 MB. That way you can repurpose the 80 MB of /cache and put it directly towards /data -- then /data becomes a shared space /data and /cache which is much better (IMHO).
ahhhhh, now i get it. thx for breaking it down
 

pettigrew95

Senior Member
Nov 26, 2006
1,649
141
93
New Jersey
Does this make the phone think that space on an SD card is in /data? So if lets say I have a 4GB partition on my sd card I can make the phone think that partition is /data?