Update: You might also want to check out the Amon_RA recovery image which will automatically partition your SD card.
This article is for people with rooted Android phones. Everyone else please ignore. There are dozens of ways to partition your SD card and I would like to share the one that has worked for me every time. I prefer to manually partition my SD card because it gives me complete control.
Requirements before getting started:
- Cyanogen Recovery Image v1.4 or greater (Easy to install with the 1-click hack)
- SD Card (Class 6 suggested): A-DATA has good prices on Amazon (4GB
, 8GB
, 16GB
)
- Android Device Bridge(ADB): Comes with the Android SDK.
- Android build that supports Apps2SD: I suggest Cyanogen’s latest stable release (Does Apps2SD automatically)
These instructions apply to both the Windows command prompt and the Mac terminal. As you can see from my screens, I was using Windows Vista. You can partition your SD card at any time, but you might as well do it before you flash a new build of Android. As always, back up your data when performing any hacks. Partitioning your SD card will erase all data on it. I split this guide into 9 steps, but it is not as difficult as it looks. Read the whole thing before starting.
All commands you need to type are in bold (my comments are in parenthesis). If you do not know how to use ADB, leave a comment for help or read ADB for Dummies over at XDA.
Step 1: Connect your phone to your computer via USB. Reboot into recovery mode.
- Command: adb shell reboot recovery (this will reboot your phone into Cyanogen’s recovery image. Or power on phone when holding home button)
- Command: adb shell (type this after your phone has booted and on the recovery screen. it should take you to a # prompt)
Step 2: Open parted to partition your SD card.
- Command: parted /dev/block/mmcblk0 (opens parted and mounts your SD card)
Step 3: Check the size and partitions of your SD card. The print command will display this info. You can see the size of my SD card is 7969 MB (8 GB). I have 1 partition which is fat32. If your SD card is blank and no partitions are listed, you can skip to Step 5.
- Command: print (displays SD card information)
Step 4: Remove all existing partitions. If you have multiple partitions, remove each one at a time.
- Command: rm 1 (deletes partition number 1)
- Command: rm 2 (if needed. keep going till all partitions are removed)
- Command: print (check when you are done to make sure all partitions are removed)
Step 5: Create your new partitions. You can make these any size, but the most common setup is 32 MB linux-swap partition, 512 MB ext2 partition, and remaining free space as a fat32 partition. In order to work properly, the partitions must be created in this order: fat32, ext2, linux-swap.
The linux-swap partition is used for a swap file on some builds. Not all builds use linux-swap, but I create one just in case I ever need it.
The ext2 partition is where your apps will be installed. I use 512 MB which gives me plenty of room but you can go larger like 1024 MB if you want. Parted only creates ext2 partitions and we can convert them to ext3 or ext4 later.
When using the Linux command mkpartfs, you must tell it where to start and and end each partition. This can be done by taking the total SD card size and subtracting the linux-swap then ext2 partition sizes. See the following example for my 8 GB card.
- Command: mkpartfs primary fat32 0 7425 (start is 0 and end is Total C)
- Command: mkpartfs primary ext2 7425 7937 (start is Total C and end is Total B)
- Command: mkpartfs primary linux-swap 7937 7969 (start is Total B and end is Total A)
Step 6: Check the sizes of your partitions. Use the command print again to display the partition sizes. If you made any mistakes you can return to Step 4 and remove them.
- command: print (displays your partition information)
Step 7: Exit parted and upgrade your ext2 file system to ext3. For most users this is the final step. We suggest all users upgrade to ext3. Its main advantage over ext2 is journaling which improves reliability and eliminates the need to check the file system after an unclean shutdown.
- command: quit (exit parted and return to # prompt)
- command: upgrade_fs (script to upgrade from ext2 to ext3)
Step 8 (Optional): If you wish, you can upgrade your ext3 partition to ext4. Skip to Step 9 is you wish to use ext3. I asked Cyanogen what file system he uses and he tweeted ext4. The file system offers enhancements like delayed allocation. See Wikipedia for more info on ext4.
- command: tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p2 (enter this command from the # prompt)
- command: e2fsck -fpDC0 /dev/block/mmcblk0p2 (run e2fsck after tune2fs. wait for the file check to finish)
Step 9: Finished. Check your work with print.
- command: parted /dev/block/mmcblk0 (open parted again)
- command: print (check all your system partitions and their sizes)
- command: quit (exit parted)
- command: reboot (reboot your system to the operating system)
Need more help?: Visit our forums or leave a comment.
[I used the guide from 51dusty to write this tutorial. He also has a utility for SD card partitioning]











82 Comments
You know, you could just use a GUI program, such as GParted. It’s always a good thing to know how to do it via command line though! Thanks for the guide!
Yes, there are easier options but I think more people should become familiar with the command line. I think it helps in the long run if you have a rooted phone.
I agree completely! Considering some people get confused when they have to pop open a terminal — it’s a great thing to have a basic idea of what you’re up against if the situation ever arises.
I also agree. Knowledge of ADB commands helps in a lot with a rooted phone, especially when you need to install APKs in emails or in links or whatnot. a simple “adb install file.apk” with the phone connected via USBis much easier than any of the alternatives
Thank you very much for the guide.
For anyone who needs to know how to run ADB, go to this thread over at XDA:
http://forum.xda-developers.com/showthread.php?t=532719
This thread is explained much better than the other one. Especially at the step if Windows doesn’t ask you to install new drivers. Also, it links you to 1.5 SDK version.
Thanks again Taylor for this post and last weeks 1-click root.
For whatever reason it is not deleting my single partition (the only one i have). I type rm1, a lot of gobbledygook follows, then i type print, and again the only partition shows up
Found the solution. Type rm instead of rm1. Then it asks for partition no. Enter 1.
the syntax is supposed to have a space in it “rm #”
adb is nice because it actually kicks out all the commands when you mess one up. “rm NUMBER” is there.
Thanks. Can this be done in Linux as well? Or is there a Linux equivalent?
“These instructions apply to both the Windows command prompt and the Mac terminal.”
Um… works in Linux too.
I’m having some problems getting ADB set up in Ubuntu 9.04
I’ve used the guide here: http://forum.xda-developers.com/showthread.php?t=537508
after following all instructions, i just get “command not found” when trying to run “adb shell”.
Sorry, nevermind I didn’t use the same paths for my Android SDK as the tutorial I followed, so I had to edit the .bashrc file to reflect it. Thanks anyway
One Request.
“The linux-swap partition is used for a swap file on some builds. Not all builds use linux-swap, but I create one just in case I ever need it.”
Not really sure if CM ROM has built-in linux-swap enabled. I tried everywhere.. couldn’t find it. Does anyone know?
If not, can you please tell how to enable linux-swap? The above steps help us create it.. but not sure how to enable it. I tried many forums.. couldn’t find any info.
Please Help.
It uses something else, where it is able to swap within the internal memory…I can’t remember what its called because I’ve never fully tried to use it, but you shouldn’t have to worry about linux-swap in the CM ROMs
Traditionally, Linux uses the swapon and swapoff commands, passing the name of the file or device.
A partition isn’t even really required, it’s just common practice.
well if you dont have it already dont use cyanogens mod, use amons recoveery OR cyanogens pimped out recovery.
So im guessing its not recommended for the stock 1gb sd?
Why not? I used the stock 1gb sd card with no probs. Ofcourse, you are not left with much space for data though
Can you do this on the phone itself by dropping to the shell from recovery mode?
Yes, you can
Nice guide. I ended up doing it with Gparted in Ubuntu about 5 hours before this article came out. I have 6.5 gb FAT32, 997 mb EXT2, and a 32 mb linux-swap. Moved my apps over to sd on Cyanogenmod 4.0.1 automatically.
just quick question if u partitioned to ext3 and then decided to later go through ext4 does that erase the whole memory? or u can just go do the upgrade thing and nothing happens??
It should upgrade, but backup first, just incase. As you can expect, those things can go to the deep end quite quickly.
Hey Taylor,
Thanks for throwing together this tutorial. Eeesh, it was a pain getting my myTouch interfaced with Windows 7 x64 but after a couple of hours I got things working smoothly.
Thanks again!
do you have to partition the sd card first, then flash cyogenmod 4.0.1 in order to automatically install apps to sd or can i just mount a new partition sd the the installed rom and use it ??
^this. In each of the articles about rooting your android phone, there’s often a note about formatting the microSD card then backing up and then flashing a new ROM. In the 6-minute video though, you say you already downloaded the flash recovery pack and the ROM. Does that mean that you already formatted the microSD to include the ext2 and linus-swap partitions, or is the partitioning process built into the automation in the video? Is it necessary to copy the microSD contents to a PC (for conservation purposes), then format, then back up the recovery image, then flash the new recovery image and finally unzip the ROM?
Thanks, very helpful!!! My G1 runs much faster with Cyanogen rom and apps2sd.
Anybody know why my internal memory still decreased with Apps2SD (from 67MB to 55MB) after I installed about 20 more apps. My used space on ext3 stayed the same before and after those installs. Did several reboots, no changes. I was expecting them to fill up the ext3 instead of internal mem.
5 Stars to u guyz!!!! *****!!!
yeah i do have the same problem after a few apps it keeps decreasing and i havent checked into like the browser cache but i wasnt online at the time and ie keeps decreasing..by not a lot but i still wanna save as much space as possible to make the phone run faster lol
Please could you put a tutorial for just doing it directly from your phone? I realise this would be very similar but Im a noob and I wanna be 100% sure about every step I make!
The day somebody creates a simple app specifically designed for doing this (much like recovery flasher did for rooting) the better imho!
Thanks!
I have rooted and use Cyanogen 4.02. I am using stock SD card and will get a class 6 SD card. What is the easiest way to get apps2sd working?
I presume:
1. partition new card
2. copy old card contents to new card
2a. place old contents whewre?
3. insert new card…
Let me know if I am correct
Thanks,
Same here. Just ordered a new card and was wondering the same.
Aite!!! i got a prob here, i entered the parted /dev/block/mmcblk0 command at the # prompt in my phone, it was ok. now as instructed, when i enter print, i get error: /dev/block/mmcblk0: unrecognized disk label…..
i did rebooting for three times, ejected my sd card from fone n re entered it, still same prob. HELP!!!
Sounds like your SD card has a problem. The original guide I used has the commands to create a new disk label. This might help your problem. I would also suggest trying another SD card if all else fails.
http://forum.xda-developers.com/showthread.php?t=534714
i tried what u said doing the mklabel, then i got this error: input/output error during write on /dev/block/mmcblk
retry/ignore/cancel?
i did cancel, then quit, then i got this”Information: you may need to update /etc/fstab.”
I found this on the site linked above. You should be able to ignore the warning.
_____________________________________
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.
WOW… i did nothing n its working again this morning. lol. but under the flags, it is only boot. not lba. thanks a lot man, i appreciate that.
i’ve done the partitioning but do i have to install apps2sd? im on cyanogen 4.02 on a HTC magic. I just dont know if i have to delete or move the apps from the phone to the sd card. Also if i upgrade to a new sd card is there anyway of transferring all the information on the SD card? e.g the apps
I successfully flashed Cyanogen’s new ROM using your 6-minute video… thanks for that first
I used my stock G1 card to do it, and I see that as I install a new application, the internal memory available decreases, as it should since I haven’t yet partitioned my SD card.
I’m getting a new microSD today (8GB class 6 from Transcend on Amazon) and I’d like to switch that over to use as my daily card with all the apps and everything on there, holding the stock G1 card as a standby, or to use to reflash a ROM if needed.
My question then is how to easily partition the new SD card. This walkthrough requires pieces of the Android SDK (and Eclipse to run it) but is there a simple way to do it using the phone alone? Could I run these same commands through the Android Command Prompt (not sure what its technically called sorry) and accomplish the same thing? I always have my current card with everything still on it if I mess it up.
It’s really easy. Once you unzip the Android SDK, there’s a tool that you can use in the command prompt called adb.exe. The above tutorial steps through every step you need to go through to repartition in.
There are, of course, more simple methods to re-partition it, but as Taylor mentioned, the method described above is a great introduction to ADB.
So, yeah. All you have to do is load up cmd.exe, navigate to the Android SDK\tools folder and use the same commands.
If you have trouble connecting your G1, let me know and I can walk you through some of the steps in getting it properly connected. (It was kind of a bitch to do on Windows 7 x64.)
Thanks Stefan! I was just hesitant on a few pieces of this. After downloading the 1.5 SDK from Google, I had trouble getting the new driver installed. Vista32 on my computer has some access protection (click OK to acknowledge you opened this program etc) and ultimately I had to open up the Device Manager and find the device there, double click to open it up, and manually search for the new drivers within the SDK. (For whatever reason, trying to manually update drivers after double-clicking on the “Safely Remove Hardware” icon in the taskbar would only yield the “Windows thinks the drivers installed are best suited for Mass Storage Device” message… this was remedied by using Device Manager, if that helps anyone). From there, I opened up the Command Prompt, directed it to the location of my SDK (which was different from Users->Taylor above because I downloaded it to a different location) and used the exact sequence of commands that Taylor laid out above.
On that note, thanks so much for taking the time to very explicitly lay these instructions out. This is one of my first forays into Command besides IPconfig lawl so my hesitance made it go slowly. In the end though, totally worth, and @Jeremiah et al from the start, I agree that using Command to do this brings a good level of familiarity for the user that is invaluable if you really expect to mess around with the best parts of Android. Thanks, grazie, obrigado!
Thanks again for the guide. I used the stockk sd card with my g1 and got the apps installed on the partitioned ext3 on the sd card successfully. Now, I’m starting to realize that 1gb card is simply not enough and planning to get a 8gb card. Now, I reallize that I’ll need to reinstall all the apps after going throu the same above steps. However, doesn’t the ROM already has the knowledge of apps installed (apps shortcuts)? Would this be a problem?
Also, is there a simple way to to have the apps when switching sd cards?
Great article and love your Blog – many thanks! With your help I made it thru, successfully making 1024MB ext2/3/finally ext4 partition on a 16GB class 6 SD (otherwise “print” shows results same as your example). Cyanogen’s 4.0.2 ROM FAQs show at
“4. How do I set up apps-to-sd? You need to create a second partition on your SD card in the ext2/ext3/ext4 format. Search the forums if you don’t know how to do this. Once created, the ROM will move your apps automatically and new apps will be installed to the SD by default.”
However, I have a problem …. none of my apps moved to the SD !! Am I missing a step or is something wrong? Using the Cyanogen 1.4 recovery image I performed a wipe (of same Cyanogen 4.0.2 working prior to SD partition) then re-flashed same ROM. I was surprised old programs still installed, uninstalled them using “manage applications” then reinstalled from Market – result was no programs on the SD. Any ideas? Thanks.
Great tutorial – thank you.
My only feedback is to do with ext4.
I’m using MoDaCo’s custom Hero ROM v1.1 – and after partitioning and using ext4, then flashing that ROM, it would go into an endless reboot.
Redid the SD card, leaving it as ext3 – and it works fine.
So I’m guessing the initial boot isn’t compatible with ext4.
I would like to use ext4 though – but I’m too scared to convert it now the ROM is up and running, in case I have to scratch it all and start again…
But just a pointer to any Hero / MoDaCo ROM testers out there – DON’T GO TO EXT4!! It’ll have to be EXT3 for now.
I’m wondering if any one can tell me “if all my apps were to be transfered to my SD card how much internal memory should I have”…512MB I’m guessing. I rooted mytouch and I’m running CM-4.0.4 still using the stock 4 GB SD. I partition my SD up ext4 at 512MB to ext2. My internal memory started at 291MB, now its at 288MB and still droping.
Where am I going wrong?
Am I suppose to raise the linux-swap higher then the 32MB when I partition the SD
HELP ME!!! – answer here or email me PLEASE…abreuw83@gmail.com
hmmm.. I must be doing something wrong? Brand new card, (bricked the other one) and got to the step of parted but failed to get past that. Here’s what happened to me:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Owner.qbert>adb shell
* daemon not running. starting it now *
* daemon started successfully *
# ls
ls
cache init.goldfish.rc root
data init.rc sbin
default.prop init.sapphire.rc sdcard
dev init.trout.rc sqlite_stmt_journals
etc lib sys
init proc system
# adb shell reboot recovery
adb shell reboot recovery
adb: not found
# reboot recovery
reboot recovery
C:\Documents and Settings\Owner.qbert>adb shell
error: device not found
C:\Documents and Settings\Owner.qbert>adb shell
error: device not found
C:\Documents and Settings\Owner.qbert>adb shell
/ # parted /dev/block/mmcblk0
parted /dev/block/mmcblk0
/sbin/sh: parted: not found
/ # parted /dev/block/mmcblk0
parted /dev/block/mmcblk0
/sbin/sh: parted: not found
/ #
Do you have CyanogenMod recovery image v1.4? If the command parted is not found, I don’t think you do.
you’re right! I have cyangenmod-4.0.4.
Is there no other way to partition the sd card? The release notes say app2sd would be automatic if I just partitioned the sd card.
partition your sd-card from the recovery image, not from windows, that’s much easier (try google)
Wow thanks! You’re right, way easier from the recovery image than from Windows… Thank you. AWESOME tutorial btw.. Many thanks and props to all the peeps that make it easy for me to pimp out and hack my Handheld..
I did everything as instructed and when i print to check all the partitions are there. After rebooting phone does not see the sd card.
Taylor Wimberly: And the rest of your crew thank you all for this most helpful site!!!
I am looking for a “total” backup solution. I am rooted running Cyanogen 4.0.4. (thanks to this site) I have searched everywhere and always come back here. You have the best tutorials as they are made for noobs like me. I need to have a backup in the event my phone is destroyed, lost and or stolen. I believe Nandroid v2.2 will do the trick. However, I’m having a hard time loading adb on my PC and I their are SO many questions that other sites don’t answer. Your step by steps are the best. I’m sure other people need a “Ghost” type back up as well. When we load other programs and they mess up our phones we all would like to get back to working. I just redid my phone from scratch so I will wait on your tutorial before i load anything else. Thank you and your mates
cant get past part 2 i type parted/dev/block/mmcblk0 then get “not found” wont let me relabel either as it says the same thing stuck ..
figured it out i dindt put a space between parted and /dev haha
Cant find the answer anywhere. I am running Cyanogen 4.0.4, and i have my sd card partitioned into the three parts, fat32, ext3, and linux-swap. What i am curious about is using 4.0.4, do i need the linux-swap, or do i need something eles. It says that Cyanogen Rom comes with compchace .6, but how to i set that up, and how do i tell that its running, becasue my phone seems to be most of the time unless i use taskiller to kill all running apps.
sorry meant that becuase my phone seems to be Laggy most of the time, unless i use taskiller to kill all running apps. Even if i am only running one or two apps.
So i can do ALL this on the Console of my phone?
* Joseph on September 5th, 2009 “So i can do ALL this on the Console of my phone”
Did anyone answer you? Answer is no you can’t do this from your phone terminal.
You need phone USD drivers on your PC, installed and running. Have drivers downloaded and ready for ‘have disk’ before you connect the phone via USB.
You need Cyanogen recovery image 1.4 installed and booted to the recovery screen (after installing, hold home while powering on phone)
Run commands above a command link opened up to the c:\ drive you installed either the adb tools to.
(hint search for Proxoid adb if you don’t want whole SDK)
hey is there a way to unpartition ur sd card to make it the full 8 gigs? i have an 8gb card and my ext3 is 512 so no matter what i do its still missing that chunk reason i asked is becuz i think it may be corrupted and i would like to format back to the full 8gb and partition again..
Hey thanks…
Did not work at first as I had not updated my recovery to1.4.
Later it worked in one go…
Thanks a lot
i managed to partition my 8GB SD Card and i guess everything is fine because i checked my App2SD and my 3rd party apps are on the card
However what i dont understand is why my card is showing a total memory of 8169 MB before & after formatting and partitioning
accordingly my card is partitioned as follows:
Disk /dev/block/mmcblk0: 8169 mb
Number Start End Size File System
1 32.3 kb 7625 mb 7625 mb Fat 32
2 7625 mb 8137 mb 512 mb ext 3
3 8137 mb 8169 mb 31.9 mb linux-swap(v1)
great guide, used it today and work perfectly!
Hey It worked great! Thanx!!!!
What would be the settings for a 16gb card. Im having a hard time figuring the numbers out for that. Someone also said you have to put GB after the numbers. True? Thanks.
I can’t remember what its called because I’ve never fully tried to use it, but you shouldn’t have to worry about linux-swap in the CM ROMs.
Hello. This tutorial is really great, thanks a lot.
However, for my phone it doesn’t work…
I have CyanogenMod 4.1.11.1 + the recovery image 1.4. This is what I do:
- I boot my phone in fastboot, then hit back to be in fastboot+usb
- on the computer, I launch “fastboot boot “, which loads up and boot the recovery image
- then on the computer, adb shell puts “error: device not found”
- I tried to launch the console on the phone (last menu item in the recovery image), but as I have an HTC Magic I don’t have a hardware keyboard so I can’t type anything…
I tried a trick : install a terminal application, su and telnetd, and then connect to it via wifi. It works fine, I can cd everywhere and I am root. However, I coulnd’t find the parted executable, I looked in /system/bin, /system/xbin, tried with toolbox and busybox, nothing is working.
Any clue?
The previous post was unexpectedly interpreted as HTML so my inferior and superior symbols were interpreted as HTML tags.
I actually meant that I launched on the computer “fastboot boot d:\android\firmwares\cyanogen\cm-recovery-1.4.img” to boot on the recovery image.
I’m having trouble finding the device with ADB after rebooting… I’m using the 1.4 image… any help will be appreciated. (ADB is running from a Mac, so drivers shouldn’t be a problem, right?)
——————
binkley:tools jennix$ adb devices
List of devices attached
HT94GLDXXXXX device
binkley:tools jennix$ adb shell reboot recovery
binkley:tools jennix$ adb devices
List of devices attached
binkley:tools jennix$ adb shell
error: device not found
———————————–
Really easy to follow directions. Thank you, God bless!
I just got my g1 not so long ago and decided to start rooting. I’ve gone so far as installing cyanogens newest rom. and i just finished partitioning my sd card to ext2/3 successfully. but when i flashed the rom again all my apps were gone. on the market it says i have them but i cant uninstall or open them because they’re not installed on the phone. any help on how to get my apps working again?
I am running into the exact same problem. All existing apps cannot be used, but new apps are installed on SD Card and are usable.
thanks for this great how to… this helped so much i was clueless before i came across this.. thank you again!!
Not for me. All this sdk and downloading drivers to my computer and whatnot is just over my head. At least I read the post through and I understand what goes into it now.
Hi I have done everything here phone is faster it shows second SD car but I can’t download and install anything from market PLS help