[GUIDE] SD card partitioning for rooted phones

Search This thread

osamahindi

Member
Nov 15, 2009
31
2
guys please help me! after done all the steps my phone still shows me 104MB free!!!
i tried to enable data2ext on adb shell through "data2ext --enable" it gives me: Data2EXT is already enabled but not active...
i tried to disable data2ext then re-enable it but with no luck i get the same result Data2EXT is already enabled but not active...
i'm on Blay0-07
 

ikdegek

Senior Member
Aug 31, 2010
132
4
houten
BlaYo,

Maybe you can help. I am using your 0.7 and CM7 on my legend (not at the same time of course..), and used partitioning with Rom manager, 512MB on a 8GB Sandisk.
Now 2 SD cards are corrupt, damaged and cannot be used again.
On the second I did NOT use a2sd and NOT data2sd,, but still damaged.
Could that be caused by the Rom manager method or something else?? I am stuck.

Thanks, Ik.
 

dangal

Senior Member
Feb 24, 2009
94
13
montevideo
Google Pixel 6
Hello i have a question,i wanna make a sd card partition to install data2ext to send /data to the sdcard,i dont understand what is the sense in make a ex3 or ex4,with one ext only is not enough?
ext3 and ext4 for what?
Thanks a lot and sorry with me English!!!!
 
  • Like
Reactions: LunaSin

BlaY0

Retired Recognized Developer
Sep 15, 2007
1,553
566
Medvode
Could that be caused by the Rom manager method or something else?? I am stuck.
No. RomManager also uses parted underneath so principle is the same.

Hello i have a question,i wanna make a sd card partition to install data2ext to send /data to the sdcard,i dont understand what is the sense in make a ex3 or ex4,with one ext only is not enough?
ext3 and ext4 for what?
If you don't understand, don't bother trying anything from this guide.
 

andrekua

Senior Member
Oct 25, 2010
110
9
guys please help me! after done all the steps my phone still shows me 104MB free!!!
i tried to enable data2ext on adb shell through "data2ext --enable" it gives me: Data2EXT is already enabled but not active...
i tried to disable data2ext then re-enable it but with no luck i get the same result Data2EXT is already enabled but not active...
i'm on Blay0-07

I also had this problem before. Partition the card and data2ext dont work. It did start to work after I got into CWM and did something. Cant remember whether it was to clear SD Ext or re-format it.
 

BlaY0

Retired Recognized Developer
Sep 15, 2007
1,553
566
Medvode
Sorry m8. It's too much to explain here... you first need to figure out what is the difference between ext2, ext3 and ext4, why do we use and what are pros/cons of using either of them. Consult Google and Wikipedia to master this knowledge. Sorry again.

I also had this problem before. Partition the card and data2ext dont work. It did start to work after I got into CWM and did something. Cant remember whether it was to clear SD Ext or re-format it.
You obviously forgot something. Partitioning using CWM is no different than following this guide except it lacks partition alignment... other than that it's the same.
 
Last edited:

andrekua

Senior Member
Oct 25, 2010
110
9
You obviously forgot something. Partitioning using CWM is no different than following this guide except it lacks partition alignment... other than that it's the same.

No, I did not redo partitioning under CWM. Im still following your method to get the better speed. If I remembered correctly, I reformat the EXT partition and on the next reboot, data2ext is working all of a sudden. Maybe I had a bad format on the EXT partition.
 

ijama

Senior Member
Oct 30, 2010
421
30
Johor Bahru
Sorry for asking help..i have a problem in 2nd step..parted not found..so i cant continue to make partition..and the point is how to set parted in my dell..

Htc Legend/CyanogenMod7 S ON
 

BlaY0

Retired Recognized Developer
Sep 15, 2007
1,553
566
Medvode
You have to find it on the internetz, copy it to your phone and make it executable. ClockworkMod should have it I guess.

Sent from my HTC Legend
 

BlaY0

Retired Recognized Developer
Sep 15, 2007
1,553
566
Medvode
As I said, find CWM fake-flash here in dev sub-forum, download it and extract parted from downloaded zip...

Sent from my HTC Legend
 

marginean.m

Senior Member
Oct 16, 2008
106
3
Cluj Napoca
may I use GParted??

Hi.
Thanks for the great tutorial. Just have a quick question: do you think that instead of some CLI commands I may use GParted? (for those that are not familiar with this app: it'a a partitioning tool for Linux but also has a liveCD so you don't really need a Linux box)

Later edit: Never mind....figured it out myself...GParted not very good for this job
 
Last edited:

vortex-

Member
Aug 5, 2008
23
7
Hi.
Thanks for the great tutorial. Just have a quick question: do you think that instead of some CLI commands I may use GParted? (for those that are not familiar with this app: it'a a partitioning tool for Linux but also has a liveCD so you don't really need a Linux box)

Later edit: Never mind....figured it out myself...GParted not very good for this job

Why shouldn't gparted be good for the job? It has the option to align partitions at MB boundaries.
 

nicksoph

Member
Dec 11, 2006
27
3
Is there a right EXT file system to use on phones sd card?

I can remember something about EXT3 and up being "logging" file systems and EXT2 not being so but Im sure there are lots of other factors too.
 

Reza_Sadeghi

Member
May 8, 2008
32
1
but.....
"mkfs.vfat" is not availabe in my Busybox in CWM.
so i think i can't format "mmcblk0p1"
i dont know what exactly to do.
for now i just can format "mmcblk0p2" using "mkfs.ext2" because "mkfs.ext2" was available.
but as mentioned "mkfs.vfat" is not and i missed up.
please help me what should i do in this step ?
---------------------
of course please help if "mmcblk0p1" not be formatted by "mkfs.vfat", can we install clean ROM anyways?
 
Last edited:

Reza_Sadeghi

Member
May 8, 2008
32
1
Unknown value(s) for: cylinders (settable in the extra functions menu)

about the post #57 above...
until now nobody answers...
anyway i found the solution for "mkfs.vfat" applet in busybox.
i installed another kernel including busybox+mkfs.vfat+mkfs.ext2 applet inside.
-------------------------------
but for now this is new problem : (please help me to solve it)

"Unknown value(s) for: cylinders (settable in the extra functions menu)"

Cylinders = 0

Code:
~ # dd if=/dev/zero of=/dev/block/mmcblk0 bs=131072 count=16
16+0 records in
16+0 records out
2097152 bytes (2.0MB) copied, 0.009936 seconds, 201.3MB/s

~ # fdisk /dev/block/mmcblk0
fdisk /dev/block/mmcblk0
Device contains neither a valid DOS partition table, nor Sun, SGI, OSF
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.

Unknown value(s) for: cylinders (settable in the extra functions menu)

Command (m for help): u
u
Changing display/entry units to sectors

Command (m for help): p
p

Disk /dev/block/mmcblk0: 2 MB, 2097152 bytes
255 heads, 63 sectors/track, 0 cylinders, total 4096 sectors
Units = sectors of 1 * 512 = 512 bytes

              Device Boot      Start         End      Blocks  Id System

Command (m for help): n
n
Unknown value(s) for: cylinders (settable in the extra functions menu)
what should i do now?
 
Last edited:

Reza_Sadeghi

Member
May 8, 2008
32
1
Skip all this lengthy and difficult process, and partition your sd card via customized cwm 3.0.1.3 available in this thread:
http://xdaforums.com/showthread.php?t=969076

Blay0 initially wrote this guide, but later he provided the customized cwm which includes automatic block alignment. so you do not need to do manual work ;)
I love all this lengthy and difficult process because we know what exactly we're doing step by step and i prefer to know what things are happening.

thanks for link but sorry, i'm using Samsung Galaxy that must Re-Partition it.
this solution can help us too and i think it is a general partitioning for any android devices based on Linux.
and i tried it without any problem on my External SD card re-partitioning.
and now i need to repartition Internal SD via CWM and shell using busybox commands here mentioned.

of course in link you suggested there is a customized CWM just for Legend & didn't work on Galaxy.
please anybody help to Re-Partition Internal SD and solution for 0 Cylinders appeared in shell when using "n" command to add a new partition.

---------- Post added at 01:12 AM ---------- Previous post was at 12:34 AM ----------

& for now...
I used "C" switch in "Fdisk" to set Cylinders.
then it tells me "Device contains neither a valid DOS partition table, nor SUN, OSF or GPT disklabel"
Building a new DOS disklabel. changes will remain in memory only, until you decide to write them."

& then....
i used "O" switch to create a new empty DOS partition table.

& then....
by "n" creating 2 new primary partitions by defining first and last cylinders.
and then "t" by "mkfs.vfat" make it "win 95 FAT32 <LBA>

& at last....
by "w" the partition table has been alerted.

but...
but...
fdisk: WARNING: rereading partition table failed, kernel still uses old table: NOT a typewriter.
~ #
-------------------
now i don't know what to do?
what is your suggestion?
I'm trying re-partition Internal SD.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 33
    Behold... a long awaited partitioning guide ;)

    WARNING! This GUIDE is to actually learn something not just to copy/paste commands!

    Requirements
    • rooted phone
    • busybox installed
    • parted (optional)
    • backup your SD card (optional)
    • calculator
    Background

    Before we begin partitioning, we need to elaborate some key points:
    1. block storage units are divided into logical blocks known as sectors
    2. sector has a size of 512 bytes
    3. NAND flash chips are divided into blocks known as erase blocks
    4. our SD cards consist of those NAND flash chips and controller
    5. erase block on our SD cards has a size of 128 kB, that's 256 sectors
    6. CHS (cylinder, head, sector) alignment has an insignificant importance here
    7. 1st sector is sector 0 (not 1) and is used as MBR (master boot record)
    8. 1st partition begins at cylinder boundary to maintain MS-DOS compatibility
    9. raw access to block storage units is done via special block device files under /dev/block directory
    10. our SD card is represented by block device file /dev/block/mmcblk0
    Instructions

    Here I will provide you with two methods of partitioning. For 1st method you will be using fdisk utility which is part of busybox and for 2nd a standalone utility called parted will be used. Both methods can be used in normal mode via adb shell or some terminal app. I will explain both methods using adb shell as it is more convenient and handy than typing commands via touch keyboard on your phone.

    1st thing to do before you begin is to unmount your SD card via "Settings->SD & phone storage" and then you issue "adb shell" command ony your PC. 2nd thing you will do is erasing of your SD card (actually you will erase just first few erase blocks of your SD card) using dd utility:
    Code:
    dd if=/dev/zero of=/dev/block/mmcblk0 bs=131072 count=16
    ...that will overwrite 1st 2 MB of your SD card with null characters. Next you may begin with partitioning.
    fdisk
    As I already stated, fdisk is a (interactive) utility that is part of busybox so I will assume it is available under /system/xbin directory. Now you can run fdisk with device file of your SD card as parameter/argument:
    Code:
    fdisk /dev/block/mmcblk0
    ...this will bring you some notes on your screen you should not worry about and a command prompt:
    Code:
    Command (m for help):
    ...which you can leave at any time by pressing CTRL+C. Next you will change unit display type to sectors:
    Code:
    Command (m for help): [B]u[/B]
    Changing display/entry units to sectors
    ...and print your SD's current info (this is info of my SD card actually, yours may vary):
    Code:
    Command (m for help): [B]p[/B]
    
    Disk /dev/block/mmcblk0: 8018 MB, 8018460672 bytes
    4 heads, 16 sectors/track, 244704 cylinders, total 15661056 sectors
    Units = sectors of 1 * 512 = 512 bytes
    
                  Device Boot      Start         End      Blocks  Id System
    ...and you write down the number of sectors. In my case it is 15661056 sectors of 512 bytes which is exactly 7647 MB if we divide them by 2048. For example you would take 7000 MB for fat32 1st partition and 647 MB for ext 2nd partition. and it is handy that way coz megabytes are divisible by our SD card's erase block size which is 128 kB as stated before. Calculation would give you start sector for 2nd partition and this would be 14336000 (7000*2048).

    Now you need to create 2 primary partitions:
    Code:
    Command (m for help): [B]n[/B]
    Command action
       e   extended
       p   primary partition (1-4)
    [B]p[/B]
    Partition number (1-4): [B]1[/B]
    ...now there's a catch. You will be offeread a start of 1st partition at 1st to 2nd cylinder boundary which is sector 16 in my case and you push it to SD card's erase block boundary (256):
    Code:
    First sector (16-15661055, default 16): [B]256[/B]
    Last sector or +size or +sizeM or +sizeK (256-15661055, default 15661055): [B]14335999[/B]
    ...and continue to the next partition which should also be primary:
    Code:
    Command (m for help): [B]n[/B]
    Command action
       e   extended
       p   primary partition (1-4)
    [B]p[/B]
    Partition number (1-4): [B]2[/B]
    First sector (16-15661055, default 16): [B]14336000[/B]
    Last sector or +size or +sizeM or +sizeK (14336000-15661055, default 15661055): [B]15661055[/B]
    ...now print what you have just done:
    Code:
    Command (m for help): [B]p[/B]
    
    Disk /dev/block/mmcblk0: 8018 MB, 8018460672 bytes
    4 heads, 16 sectors/track, 244704 cylinders, total 15661056 sectors
    Units = sectors of 1 * 512 = 512 bytes
    
                  Device Boot      Start         End      Blocks  Id System
    /dev/block/mmcblk0p1             256    14335999     7167872  83 Linux
    /dev/block/mmcblk0p2        14336000    15661055      662528  83 Linux
    ...it looks OK but you need to change 1st partition's hex id which needs to be fat32 (c):
    Code:
    Command (m for help): [B]t[/B]
    Partition number (1-4): [B]1[/B]
    Hex code (type L to list codes): [B]c[/B]
    Changed system type of partition 1 to c (Win95 FAT32 (LBA))
    ...now you're am set, print again your configuration and write changes to SD card:
    Code:
    Command (m for help): [B]p[/B]
    
    Disk /dev/block/mmcblk0: 8018 MB, 8018460672 bytes
    4 heads, 16 sectors/track, 244704 cylinders, total 15661056 sectors
    Units = sectors of 1 * 512 = 512 bytes
    
                  Device Boot      Start         End      Blocks  Id System
    /dev/block/mmcblk0p1             256    14335999     7167872   c Win95 FAT32 (LBA)
    /dev/block/mmcblk0p2        14336000    15661055      662528  83 Linux
    
    Command (m for help): [B]w[/B]
    The partition table has been altered!
    There's a possibility you would need to shutdown and power on again your phone at this point. Do not reboot via adb or some 3rd party app!
    parted
    Parted is one of interactive partitioning utilities that can also use external formatting utilities. It can be found in some recovery images but can be copied to your internal phone storage and run from there in normal mode too. To run it you have to use your SD card's device file as a parameter/argument:
    Code:
    parted /dev/block/mmcblk0
    ...and you will be presented with an interactive shell:
    Code:
    GNU Parted 1.8.8.1.179-aef3
    Using /dev/block/mmcblk0
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted)
    I probably shouldn't mention that there's an interactive help available and that it is invoked by issuing "help" into shell's command prompt. Next thing to do is making a MS-DOS disklabel:
    Code:
    (parted) [B]mklabel msdos[/B]
    ...and switch to display sector as a unit:
    Code:
    (parted) [B]unit s[/B]
    Now you can print some useful info:
    Code:
    (parted) [B]print all[/B]
    Model: SD USD (sd/mmc)
    Disk /dev/block/mmcblk0: 15661056s
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    
    Number  Start      End        Size       Type     File system  Flags
    Mind and write down the size in sectors (15661056 in my case).If you divide number of sectors by 2048, you get how big in MB is actually your SD card (7647 in my case).You should mind that erase block of your SD card is 128 kB and all of your partitions should start at the beginnings of those erase blocks. It is safe to say that 1st partition should begin at sector 256 and 2nd at any MB boundary. Let say you want 512 MB big ext partition and the rest for fat32 one. Mind tho that 1st partition is to be fat32! So we say 7135 MB for fat32 1st partition and 512 MB for ext 2nd partition. Now you calculate the start sector of 2nd partition... number of MB for 1st partition multiplied by 2048 should give you the number (14612480). And you are set for partitioning:
    Code:
    (parted) [B]mkpart primary fat32 256 14612479[/B]
    (parted) [B]mkpart primary ext2 14612480 15661055[/B]
    ...and print result:
    Code:
    (parted) [B]print all[/B]
    Model: SD USD (sd/mmc)
    Disk /dev/block/mmcblk0: 15661056s
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    
    Number  Start      End        Size       Type     File system  Flags
     1      256s       14612479s  14612224s  primary  fat32        lba
     2      14612480s  15661055s  1048576s   primary  ext2
    ...and quit:
    Code:
    (parted) [B]quit[/B]
    At this point you have partitioned your SD card but not yet formatted it. Format fat32 partition with mkfs.vfat and ext partition with mkfs.ext2:
    Code:
    mkfs.vfat /dev/block/mmcblk0p1
    ...and:
    Code:
    mkfs.ext2 -m0 -b4096 /dev/block/mmcblk0p2
    If there is a mke2fs utility on your phone system (standalone - not part of busybox), you may use it to format second partition as ext3:
    Code:
    mke2fs -j -m0 -b4096 /dev/block/mmcblk0p2
    ...or even as ext4 (if your mke2fs supports that):
    Code:
    mke2fs -j -m0 -b4096  -Oextents,uninit_bg,dir_index /dev/block/mmcblk0p2
    1
    Did you change units display to sectors?
    1
    Thanks, with the "u" option comes later in your manual ;)
    Thanx, I have changed that.
    A last newbie question: i have now 2 part. and formated the FAT, but i dont know, how to get the "mke2fs" on the phone to format the Linux part.?
    Sorry Blay0 but Linux is another Word for me...
    If you have busybox on your phone you also have mke2fs or mkfs.ext2 as these two are part of it. If you have CM based ROM there should already be standalone e2fsprogs in /system/bin directory and if you have a stock based one, you can find mke2fs_recvy + e2fsck_recvy in /system/bin directory. In B ROM you have all e2fsprogs available in /system/xbin directory.
    1
    Need some help.
    Code:
    Command (m for help): p
    p
    
    Disk /dev/block/mmcblk0: 7973 MB, 7973371904 bytes
    4 heads, 16 sectors/track, 243328 cylinders
    Units = cylinders of 64 * 512 = 32768 bytes
    
                  Device Boot      Start         End      Blocks  Id System
    What is my mistake?

    I got this too... seems I forgot to enter the "w" command to write the partitions. :p
    1
    Absolutely. You neet to write the partition table exiting fdisk. And you can't execute mkfs.vfat and mke2fs inside fdisk shell! It's the same as you would try to microwave your sandwich in the fridge... it won't work that way...