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
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..
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
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:
now at the # prompt enter:
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:
you may receive a message from the program:
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:
it may give you some guff about:
answerÂ yÂ to the ‘yes/no’..
confirm with:Â msdos
you should get something like:
or, if your sdcard is new/empty you’ll get:
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:
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:
output should be similar to:
to exit parted type:
after quitting you may receive a message containing:
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:
you now have journaling(aka ext3)! if ext3 is all you want, skip next two commands.
you want ext4?Â
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
inÂ originalÂ cmd prompt, enter:
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:
cyanogen-v188.8.131.52 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!Â