[Atrix 4G Android Development] Zn7mkUKzN1r8aCIV:
This thread explains HOW TO RESIZE ANY USER PARTITIONs by hacking the kernel code. It uses the 3.1.10 kernel code as the base, but could be applies in any kernel code and any ROM (not jut Atrix alone). An example code will be given.

Backgorund:

I am indebted to the insight of Moto Xoom developer: Schischu. Schishu succeeded in cheating the official partition table by altering the partition layout at will during kernel booting. plz. refer to BigPart Repartition Upgrade and Resource Center [ https://xdaforums.com/showthread.php?t=2506997 ] and Schischu' github code's Add bigPart support to kernel [ https://github.com/Schischu/android...mmit/6b3d70fff905b7395fd15992c3779b27d1b6c101 ]

Okay, let's talk about the flow of patching

First, inspect your ram partition (use Atrix as example) by

fdisk -u -l /dev/block/mmcblk0

you should get:

Disk /dev/block/mmcblk0: 15.9 GB, 15916859392 bytes

1 heads, 16 sectors/track, 1942976 cylinders, total 31087616 sectors

Units = sectors of 1 * 512 = 512 bytes

Device Boot Start End Blocks Id System

/dev/block/mmcblk0p1 1024 8191 3584 83 Linux

Partition 1 does not end on cylinder boundary

/dev/block/mmcblk0p2 8192 9215 512 83 Linux

Partition 2 does not end on cylinder boundary

/dev/block/mmcblk0p3 9216 13311 2048 83 Linux

Partition 3 does not end on cylinder boundary

/dev/block/mmcblk0p4 13312 31005695 15496192 5 Extended

Partition 4 does not end on cylinder boundary

/dev/block/mmcblk0p5 14336 16383 1024 83 Linux

/dev/block/mmcblk0p6 16384 17407 512 83 Linux

/dev/block/mmcblk0p7 17408 18431 512 83 Linux

/dev/block/mmcblk0p8 18432 20479 1024 83 Linux

/dev/block/mmcblk0p9 20480 24575 2048 83 Linux

/dev/block/mmcblk0p10 24576 40959 8192 83 Linux

/dev/block/mmcblk0p11 40960 57343 8192 83 Linux

/dev/block/mmcblk0p12 57344 712703 327680 83 Linux

/dev/block/mmcblk0p13 712704 2285567 786432 83 Linux

/dev/block/mmcblk0p14 2285568 2326527 20480 83 Linux

/dev/block/mmcblk0p15 2326528 3637247 655360 83 Linux

/dev/block/mmcblk0p16 3637248 7831551 2097152 83 Linux

/dev/block/mmcblk0p17 7831552 8538111 353280 83 Linux

/dev/block/mmcblk0p18 8538112 31005695 11233792 83 Linux

1) Pay attention to /dev/block/mmcblk0p4, it states it is Extended, not Linux!

2) Read carefully the start and end of /dev/block/mmcblk0p4 are 13312, 31005695.

3) Note the start of /dev/block/mmcblk0p5 is 14336 and the end of /dev/block/mmcblk0p18 is 31005695

So it concludes /dev/block/mmcblk0p5 -> /dev/block/mmcblk0p18 are JUST LOGIC extended partition of /dev/block/mmcblk0p4 !!!

This differs from Xoom's case that all those partitions are efi based, Atrix;s hack must apply to MSDOS extended partitions instead, i.e. fs/partitions/msdos.c !

Now, it's time to map those /dev/block/mmcblk0p??? to your user partitions:

Boot to CWM, mount at your partitions, then adb shell, type: df, you will get:

Filesystem 1K-blocks Used Available Use% Mounted on

tmpfs 402980 52 402928 0% /dev

/dev/block/mmcblk0p15

645056 58244 586812 9% /cache

/dev/block/mmcblk0p16

2064192 1627072 437120 79% /data

/dev/block/mmcblk1p1 31105180 6583120 24522060 21% /sdcard

/dev/block/mmcblk0p18

11211876 2661568 8550308 24% /emmc

/dev/block/mmcblk0p12

322516 286872 35644 89% /system

/dev/block/mmcblk0p13

774064 17180 717564 2% /osh

/dev/block/mmcblk0p17

342123 10287 314172 3% /preinstall

You see /system is residing in /dev/block/mmcblk0p12 and /osh (webtop) is residing in /dev/block/mmcblk0p13. they are adjacent !

In my example, I want to expand /system to accommodate KitKat and don't need webtop excatly, so I can just alter these 2 partitions layout :)

Go back to 'fdisk' data and note:

/dev/block/mmcblk0p12 57344 ...

/dev/block/mmcblk0p13 712704 2285567

We must preserve the partition boundaries such that other logical partitons are not affected

Note: the start of /system is 57344 or HEX E000, the start of /osh is 712704 or HEX AE000 and the end of /OSH is 2285567 or HEX 22DFFF. we are going to play with these numbers :)

the sketched patch is

#define MB002 0x001000

#define OLYMPUS_SYSTEM_START 0x00E000

#define OLYMPUS_OSH_START 0x0AE000

#define OLYMPUS_OSH_END 0x22DFFF

if (next == OLYMPUS_SYSTEM_START*sector_size)

{

printk("Fixing up system part\n");

size = (OLYMPUS_OSH_END-MB002-OLYMPUS_SYSTEM_START+1ULL)*sector_size;

}

else if (next == OLYMPUS_OSH_START*sector_size)

{

printk("Fixing up osh part\n");

next = (OLYMPUS_OSH_END-MB002+1ULL)*sector_size;

size = MB002*sector_size;

}

Our goal is to shrink /osh to 2M and expand /system to its largest possible size, and is accomplished in above patch.

There are only 2 variables, NEXT and SIZE, to play with the parition layout, ALWAYS remember START-END+1ULL = SIZE and NEXT=START Then you can play with /system at the expense of /emmc instead, of course you must take care of the partitions from 12 up to 18 making sure those START and END do not overlap :)

The real patch for kernel 3.1.10 applied to /fs/partitions/msdos.c is here :

link : http://www.sendspace.com/file/6ztz3y

name : kernel_3.1.10.bigpart.diff

size : 1024

md5sum : 0cfc1f99dcf4520a57ede36adfd07e1f

------------------------------------------------

Once compiled the patch 3.1.10 kernel, you get replace the kernel (zImage) in both recovery.img and boot.img of your favortie ROM (unpack, then repack). Flash the recovery-bigpart.img and boot-bigpart.img to your phone, Boot immediately to RECOVERY, format /system and /osh (all the partitions modified, you will lose the data!)

After formatting, mount /system and /osh, use adb shell, type "df -h" and check your 1G /system

Reinstall your ROM (or just /system). Your favorite Atrix ROM now runs with a ~1G /system. :)

THIS METHOD IS GENERIC TO ALL KERNEL AND ROM

YOU ARE WELCOME TO POST YOUR CUSTOM PATCH CODES HERE! with the new partition configuration tables :)