Gmail 5.0: Material Design and Multiple Account Support

Google started to materialize many of its applications right after announcing the … more

Some of Our Favorite Features in Android 5.0 Lollipop

Android 5.0 Lollipop is the latest major revision to Google’s mobile operating … more

Sony SmartEyeglass SDK Developer Preview Released

A little over a month ago in Tokyo, Japan, Sony unveiled its new SmartEyeglasstechnology. … more

XDA and Leaseweb: Server Trial/Moto 360 Contest (Winners!)

About a month ago, we held a contest along with XDA’s host, Leaseweb, to … more
Post Reply

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

OP 51dusty

8th July 2009, 08:35 PM   |  #1  
51dusty's Avatar
OP Senior Member
Flag bville, md
Thanks Meter: 12
 
144 posts
Join Date:Joined: Feb 2009
More
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!
Last edited by 51dusty; 13th September 2009 at 11:48 PM. Reason: 16gb transcend cards
The Following 8 Users Say Thank You to 51dusty For This Useful Post: [ View ]
8th July 2009, 09:07 PM   |  #2  
Senior Member
Thanks Meter: 63
 
732 posts
Join Date:Joined: May 2009
Donate to Me
More
very nice guide! I will have to test it out later on! Thanks! .
8th July 2009, 09:09 PM   |  #3  
Senior Member
Thanks Meter: 0
 
129 posts
Join Date:Joined: 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
8th July 2009, 09:16 PM   |  #4  
Senior Member
Thanks Meter: 51
 
1,016 posts
Join Date:Joined: 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.
8th July 2009, 10:14 PM   |  #5  
Member
Thanks Meter: 0
 
32 posts
Join Date:Joined: Jun 2009
Is their a noticeable increase in speed when running a non hero rom with swapper?
8th July 2009, 11:29 PM   |  #6  
51dusty's Avatar
OP Senior Member
Flag bville, md
Thanks Meter: 12
 
144 posts
Join Date:Joined: Feb 2009
More
Question
Quote:
Originally Posted by marixsmith

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.
9th July 2009, 12:47 AM   |  #7  
Senior Member
Thanks Meter: 8
 
516 posts
Join Date:Joined: 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.
9th July 2009, 01:42 AM   |  #8  
Member
Thanks Meter: 0
 
93 posts
Join Date:Joined: Jun 2008
More
same problem as engaged...
9th July 2009, 01:48 AM   |  #9  
cyanogen's Avatar
Retired Recognized Developer
Flag Seattle
Thanks Meter: 5,708
 
2,485 posts
Join Date:Joined: Jan 2009
Donate to Me
More
Was wondering when someone would write this guide!

Quote:
Originally Posted by h.nocturna

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

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.
9th July 2009, 02:01 AM   |  #10  
Member
Detroit, MI
Thanks Meter: 1
 
62 posts
Join Date:Joined: Jun 2009
More
Quote:
Originally Posted by cyanogen

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

Post Reply Subscribe to Thread

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

Advanced Search
Display Modes