Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,786,599 Members 38,248 Now Online
XDA Developers Android and Mobile Development Forum

[REF] manual partition of sdcard w/parted,goto ext3/4 from adb. no liveCD req'd

Tip us?
 
51dusty
Old
(Last edited by 51dusty; 13th September 2009 at 11:48 PM.) Reason: 16gb transcend cards
#1  
51dusty's Avatar
Senior Member - OP
Thanks Meter 12
Posts: 144
Join Date: Feb 2009
Location: bville, md
Cool [REF] manual partition of sdcard w/parted,goto ext3/4 from adb. no liveCD req'd

i needed a way to format my sdcard & install swap capable rom with no card reader...grrr...my gray hair is your gain!

READ THIS FIRST: i wrote a script that automagically partitions the sdcard. get it here.

if you still want to partition manually, read on.

i did this with a BLANK 8gb card and a fresh rom install, so i had no data to lose..be careful. i take no responsibility for what happens to your phone, sdcard, data, sanity, etc if you follow these instructions. remember to backup your sdcard to your pc before you begin.

technically, you don't need adb for this, as you can partition your card in the recovery console on the g1(...not the terminal app) using the commands in this post. however, once you wipe your sdcard, you may want some way of getting a new rom onto the phone. ;p

these instructions apply to both, the windows command prompt and the mac terminal.

just about any size and/or class of sdcard will work, but you will want to use a class 6 cause it's wicked fast. 16gb transcend sdcards seem to be giving some people trouble and throwing "ERROR: input/output error during write on /dev/block/mmcblk0" when trying to partition. use them at your own peril.

the example in this thread is for MY sdcard...YOUR sdcard will be different and the partition sizes may vary. apply ur information(sdcard size, partition size) when appropriate. following the instructions in this post will erase ALL DATA on the sdcard before creating new partitions.

read the ENTIRE post VERY carefully BEFORE proceeding or asking questions...


#####

note #1: all typed commands are in bold. adb/console commands in black. windows prompt commands in green.

note #2: if all else fails...remove all partitions and create new. this seems to solve 99.9% of non-hardware related problems.

note #3: if note #2 fails...try 'mklabel msdos'. see below for more info.

note to ext3/ext4 fs users: parted does NOT support CREATING ext3/ext4 partitions..you MUST create with ext2 and upgrade. also, parted CAN RESIZE ext3 partitions, but with restrictions. check out the table on the features page, of their website. i will NOT go into resizing partitions in this post as there are many variations...


#####

need to backup your ext partition?

note: these backup commands must be run while phone is booted, not recovery.

to backup your ext partition to your current directory: adb pull /system/sd/ %CD%\sdbackup
to restore back to sdcard: adb push %CD%\sdbackup /system/sd


#####

having issues? please post the following when asking for help:

output from the following commands
parted /dev/block/mmcblk0 print
parted /dev/block/mmcblk0 check 1, if any.
parted /dev/block/mmcblk0 check 2, if any.
parted /dev/block/mmcblk0 check 3, if any.

what rom are you using?
what brand/size/class sdcard?
can you see fat32 partition on the phone? ie. through andExplorer or similar..


#####

materials:
g1 with cm-recovery-1.4
sdcard <--class 6 recommended(adata makes good ones...they max out the g1 hw in terms of speed)
rooted rom with ext3/4 support & swap capability <--recommend CyanogenMod
adb
fingas(or toes if you're this guy)

part i - prepare the sdcard:
boot your g1 into recovery (using home + power)
drop to console (alt + x)

open windows command prompt and enter:
adb shell

now at the # prompt enter:
parted /dev/block/mmcblk0

you are now in parted...hopefully. if not, check your typing, start over, do more research, or give up.

to find out the size of your sdcard & the partitions that it contains, enter:
print

you may receive a message from the program:
Code:
"No Implementation: Partition 1 isn't aligned to cylinder boundaries. This is
still unsupported."
the error says it all.. ;P
not sure what this means exactly(besides our partitions being out of alignment), but it is not good for our purposes.

also, if your "Partition Table" is reported as being "loop", i suggest repairing with the following procedure as well since it seems to be causing some problems too.

to fix, type:
mklabel msdos

it may give you some guff about:
Code:
Warning: The existing disk label on /dev/block/mmcblk0 will be destroyed and all data on 
this disk will be lost. Do you want to continue?
parted: invalid token: msdos
answer y to the 'yes/no'..

and then:
Code:
New disk label type?
confirm with: msdos

re-enter: print

you should get something like:
Code:
print
print
Model: Unknown (unknown)
Disk /dev/block/mmcblk0: 7969MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      512B    7469MB  7469MB  primary  fat32        lba
 2      7469MB  7969MB  500MB   primary  ext2
or, if your sdcard is new/empty you'll get:

Code:
print
print
Model: Unknown (unknown)
Disk /dev/block/mmcblk0: 7969MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
if no numbered partitions come up, move onto next step. if not, delete ALL partitions that you see with the rm command. it has the format: rm <partition number>.
in this case:
rm 1
rm 2


the fourth line in the 'print' command output shows you the total size of sdcard in MB(or GB if you card is large)..mine says: Disk /dev/block/mmcblk0: 7969MB

use this number(XXXXMB) and do some simple math to get the size of your partitions.
7969MB - 32MB linux-swap = 7937MB
7937MB - 500MB ext2 = 7437MB fat32
32MB seems to be alright size for swap, though it can be lower depending on your sdcard size.
500 MB is a good round number for the ext2 partition...no need for more.
that leaves us with 7437MB for fat32 storage.

part ii - create partitions:
for a2sd & swap to work properly, partitions MUST be created in this order: fat32, ext2, linux-swap

the command to create partitions is mkpartfs...command format is:
mkpartfs <partition type> <fs type> <start> <end>

note#1: the <start>/<end> numbers in the following section correspond to the italicized numbers above. your partition information will most likely be different.

note#2: by default parted assumes ur using MB as the units in commands. say you have a card that is LARGE(like 16GB) and want a partition of 12GB...all you do is use the proper units(ie. mkpartfs primary fat32 0 12GB) and parted will oblige. you can use decimals as well...if you want a similar setup to my calculations above, you would have a fat32 partition of 15.4GB(ie. mkpartfs primary fat32 0 15.4GB), 500MB ext2, and 32MB swap

now we create the partitions:
mkpartfs primary fat32 0 7437
mkpartfs primary ext2 7437 7937
mkpartfs primary linux-swap 7937 7969


to check out our handy work, enter:
print

output should be similar to:
Code:
print
print
Model: Unknown (unknown)
Disk /dev/block/mmcblk0: 7969MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      512B    7437MB  7437MB  primary  fat32        lba
 2      7437MB  7937MB  500MB   primary  ext2
 3      7937MB  7969MB  32.2MB  primary  linux-swap(v1)
to exit parted type:
quit

after quitting you may receive a message containing:
Code:
Information: You may need to update /etc/fstab.
no need to worry. fyi, fstab is a file that keeps track of disks & partitions in *nix. more info on fstab can be found here.

part iii - convert ext2 to ext3/ext4:
parted will not create ext3/ext4 partitions...see beginning of post
to upgrade, enter:
upgrade_fs

you now have journaling(aka ext3)! if ext3 is all you want, skip next two commands.

you want ext4?
enter:
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p2
e2fsck -fpDC0 /dev/block/mmcblk0p2

part iv - copy rom to sdcard and install, enable swap:
open another win cmd prompt, enter:
adb shell mount /sdcard
adb push /update-path/update.zip /sdcard
exit


in original cmd prompt, enter:
reboot recovery

after reboot:
wipe data (alt + w) <--this one is optional, but i like fresh installs
install rom (alt + s)

to enable swap, see this page.
note: you do not need to enable swap if your rom does it automagically.
#####

all told, i end up with:
~7.5GB fat32
~500MB ext4
~32MB swap
cyanogen-v3.6.8.1 running faster than ever!

hope this wasn't too painful.

btw, you could use a live cd, but i think this is easier and maybe a little more fun!
.
my new rules for life (courtesy of Ted Nelson):
1. most people are fools
2. most authority is malignant
3. God does not exist
4. everything is wrong
####################
# phone=nexusOne
# radio=32.26.00.24u_4.04.00.03_2
# recovery=amon_ra-v1.6.0
# rom=cyanogen-v5.0.7.1
####################

if you like good music, check out my other endeavour.
.
The Following 8 Users Say Thank You to 51dusty For This Useful Post: [ Click to Expand ]
 
nephron
Old
#2  
Senior Member
Thanks Meter 63
Posts: 732
Join Date: May 2009

 
DONATE TO ME
very nice guide! I will have to test it out later on! Thanks! .
 
jay22are
Old
#3  
Senior Member
Thanks Meter 0
Posts: 129
Join Date: Jun 2009
does this damage the sd card in anyway? i was running jac hero with swapper and it killed my sd card...but nice tut..might try it
Phone: T-Mobile G1
Theme: HERO by Nabz
ROM Build: Cyanogen's Mod 3.9.7
Recovery Menu: Cyanogen's Recovery 1.4
Radio: 2.22.19.26I
SPL: Haykuro's SPL
SDCard: 4GB Class 4 500EXT3 COMPCACHE W/ BACKUP AUTO SWAP
 
h.nocturna
Old
#4  
Senior Member
Thanks Meter 46
Posts: 1,013
Join Date: Oct 2008
wow... I never knew you were allowed to partition straight from terminal or I wouldn't have wasted a CD on g-parted... =/ nice guide, next time I need to partition, I'll use this method.

jay22are, partitioning the card will not damage it, but if you use it for swap you will always run the risk of corrupting your card, however, I read that someone calculated that it would still take 2yrs for your card to start having problems using swapper. So good luck.
 
marixsmith
Old
#5  
Member
Thanks Meter 0
Posts: 32
Join Date: Jun 2009
Is their a noticeable increase in speed when running a non hero rom with swapper?
 
51dusty
Old
#6  
51dusty's Avatar
Senior Member - OP
Thanks Meter 12
Posts: 144
Join Date: Feb 2009
Location: bville, md
Quote:
Originally Posted by marixsmith View Post
Is their a noticeable increase in speed when running a non hero rom with swapper?
extremely noticeable. apps run & transition much smoother than without the swap partition. although, i must say that most of the speed & stability in my setup is cyanogen's rom...it's awesome.

now i have a question...

does anyone know if there are speed/reliability differences between using the swapfile(like with the swapper app) and the swap partition? i did the partition b/c that's how i've always configured linux installs and it let's me mount the sdcard w/o issues.
.
my new rules for life (courtesy of Ted Nelson):
1. most people are fools
2. most authority is malignant
3. God does not exist
4. everything is wrong
####################
# phone=nexusOne
# radio=32.26.00.24u_4.04.00.03_2
# recovery=amon_ra-v1.6.0
# rom=cyanogen-v5.0.7.1
####################

if you like good music, check out my other endeavour.
.
 
engagedtosmile
Old
#7  
Senior Member
Thanks Meter 8
Posts: 516
Join Date: Mar 2009
when i'm trying to do the commands I run into this:


(parted) mkpartfs fat32 0 7584
mkpartfs fat32 0 7584
mkpartfs fat32 0 7584
parted: invalid token: fat32
Partition type? primary/extended?


doesn't seem like the guide covers all of the steps.
 
ebadevil
Old
#8  
Member
Thanks Meter 0
Posts: 93
Join Date: Jun 2008
same problem as engaged...
 
cyanogen
Old
#9  
cyanogen's Avatar
Retired Recognized Developer
Thanks Meter 5,692
Posts: 2,485
Join Date: Jan 2009
Location: Seattle

 
DONATE TO ME
Was wondering when someone would write this guide!

Quote:
Originally Posted by h.nocturna View Post
wow... I never knew you were allowed to partition straight from terminal or I wouldn't have wasted a CD on g-parted... =/ nice guide, next time I need to partition, I'll use this method.
I just built and included Parted on the new recovery image (1.3.1). I was just waiting for someone to do a writeup about it because I'm lazy

Quote:
Originally Posted by engagedtosmile View Post
when i'm trying to do the commands I run into this:


(parted) mkpartfs fat32 0 7584
mkpartfs fat32 0 7584
mkpartfs fat32 0 7584
parted: invalid token: fat32
Partition type? primary/extended?


doesn't seem like the guide covers all of the steps.
Should be "mkpartfs primary fat32 0 7584".

Parted can also resize your existing partitions without erasing data.
 
lstevens86
Old
#10  
Member
Thanks Meter 1
Posts: 62
Join Date: Jun 2009
Location: Detroit, MI
Quote:
Originally Posted by cyanogen View Post
Parted can also resize your existing partitions without erasing data.
I'm gonna try when I get home always wanted to resize my partition without apps and data being loss
White T-Mobile G1 aka Dream
Switching Roms Everyday
2.22.19.26I
1.33.205 SPL aka Danger

Red MyTouch 3g Slide Rooted
SlideMe

Tags
ext4, linux-swap, parted, partition, swap
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Try to Keep Up with Just Swipe Game

Sometimes, the simplest of games are the ones that end up beingthe most addictive and end up consuming … more

MultiROM Ported to the Moto E

Few categoriesof Android development are as intrinsically interestingas the ability to boot into multiple … more

XDA Xposed Tuesday: How to Control Google Play Wake Locks – XDA Developer TV

Xposed Modules are usually pretty simple. There are a few … more

Make Text Entry More Efficient with Macro Text Expansion

One of the best things about the modern day smartphone is its ability to save us … more