Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,808,106 Members 41,769 Now Online
XDA Developers Android and Mobile Development Forum

[KERNEL HACK] BigPart@Atrix, resize any user partitions@will

Tip us?
 
Zn7mkUKzN1r8aCIV
Old
(Last edited by Zn7mkUKzN1r8aCIV; 6th January 2014 at 06:27 AM.)
#1  
Senior Member - OP
Thanks Meter 1,024
Posts: 199
Join Date: Mar 2013
Default [KERNEL HACK] BigPart@Atrix, resize any user partitions@will

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://forum.xda-developers.com/sho....php?t=2506997 ] and Schischu' github code's Add bigPart support to kernel [ https://github.com/Schischu/android_...779b27d1b6c101 ]

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
The Following 25 Users Say Thank You to Zn7mkUKzN1r8aCIV For This Useful Post: [ Click to Expand ]
 
tamuin
Old
#2  
Member
Thanks Meter 18
Posts: 63
Join Date: Nov 2011
Very nice, and thanks for the info.

Too bad we have to recompile the kernel to do this.

I guess I have to take a look into howto compile the kernel, I will do a google search, but if anyone can point me to a good discussion/tutorial/howto on this I would appreciate it (sometimes I find that tracking down information on the internets is like wading through a dumpster).
 
krystianp
Old
#3  
krystianp's Avatar
Senior Member
Thanks Meter 11,729
Posts: 668
Join Date: May 2012
Location: Rzeszow

 
DONATE TO ME
I don't think there's need for that until we have working kitkat. I even think this is better solution than making it permanently changed like I planned to do.
The Following 2 Users Say Thank You to krystianp For This Useful Post: [ Click to Expand ]
 
tamuin
Old
#4  
Member
Thanks Meter 18
Posts: 63
Join Date: Nov 2011
Quote:
Originally Posted by krystianp View Post
I don't think there's need for that until we have working kitkat. I even think this is better solution than making it permanently changed like I planned to do.
Actually I am more interested in not having to use webptop2sd for 2.3.6.
 
andresrivas
Old
#5  
Senior Member
Thanks Meter 357
Posts: 1,049
Join Date: Aug 2010
Location: Córdoba
Quote:
Originally Posted by tamuin View Post
Very nice, and thanks for the info.

Too bad we have to recompile the kernel to do this.

I guess I have to take a look into howto compile the kernel, I will do a google search, but if anyone can point me to a good discussion/tutorial/howto on this I would appreciate it (sometimes I find that tracking down information on the internets is like wading through a dumpster).
search for how to compile kernel, it's on this forum, but don recall the section
Motorola Personal 501 -> Motorola StarTac -> Motorola v360 (1gb sd, iTunes, native, non-java apps) -> Motorola Rokr E2 (SDHC 8Gb, native apps, O.C., My own custom Rom, AWESOME PHONE) -> Motorola C115 (Custom Ringtones xD ) -> Motorola Milestone (A.K.A Droid) (Froyo, rooted, stolen :'( ) -> Motorola Atrix 4G (Blur ICS) -> Motorola Moto X


Yup. I've been a Motofan all my life so far...
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes