Tips

How to create a 2nd partition to install Android apps on an SD card

September 8, 2009 | by Andrew Kameka

Android Hacks, Android Tutorials

How to create a 2nd partition to install Android apps on an SD card

If you’ve rooted your Android phone, it may have been because you wanted to free up space and install apps on your SD card. Certain ROM’s have this feature built into, so all a user has to do is create a second partition on his or her SD card. This tutorial will show how to partition an SD card without installing any programs or SDK’s.

Before we go any further, you will need to root your phone for this to work. For the 1,000th time, THIS IS RISKY, CAN DESTORY YOUR PHONE, AND CAN VOID YOUR WARRANTY. Androinica.com accepts absolutely no responsibility if problems arise from rooting your phone; you root at your own risk. If you need instructions on how to root, AndroidAndMe has an excellent explanation.

Now onto the partition. Some like to use a Linux live CD, the Android SDK, or programs like Paragon Partition Manager. Or you can just do it manually through Android like I’ll show here. To give credit where’s it’s due, this tutorial is directly based on this great explanation available at XDA.

How to create a second partition directly from your G1

Make sure that you have the following:

  • A T-Mobile G1/HTC Dream (use the AndroidAndMe SDK tutorial if you don’t have a physical keyboard on your phone)
  • cm-recovery-1.4 (Recovery image that came with the one-click root method)
  • SD card, preferably class 6. SD cards are labeled according to speed. Class 6 [6 MB/s - 40x] cards are great to have but not required. I highly advise upgrading to an 8GB SD card if you haven’t already.
  • A ROM that supports ext3/4 and swap (your ROM will tell you. If you have CyanogenMod, its’ there)

Warning: Copy the SD card to your computer if there’s anything you want to save. This will wipe everything off your card.

If you make a mistake while in parted mode, you can typically follow prompts to get help or you can enter “quit” to return to the console and start over.

1. Turn off your phone and then enter recovery mode

Power off, and then hold the Home and Power buttons at the same time

2. Go to the console and then press enter

  • Scroll to and select [Alt+X Go to Console]
  • Once in console, you should see a command telling you to “Press <enter>” Do it and you’ll see this screen

02_enter

3. Type “parted /dev/block/mmcblk0″ (Note: That’s a zero, not the letter ‘O’)

You should then see a screen welcoming you to parted.

  • Type “print” and press enter

Numbers will vary depending on the size of your SD card, but you should see a screen like this:

03_parted

4. Delete existing partitions

The rows labeled “Number 1″ and “Number 2″ must be deleted before proceeding.

  • Type “rm 1″ and press enter.
  • Type “rm 2″ and press enter.

5. Do the math for each partition

Look on the fourth row and note the exact size of your SD card. The example used for this tutorial is 2033 MB. You will need to break this number into three sections:

  • fat32 (VARIES) – This will be the remaining space where you store music, photos, etc.
  • ext 2 (500 MB) – This is the partition where apps will install. 500MB should typically be enough space to store every app that you desire.
  • Linux swap (32 MB) – It’s generally recommended to set aside 32 MB for a linux swap. You may find that a ROM requires a different number. Always read and follow what your ROM developer recommends.

So if we have a 2033 MB card, we perform these basic equations

2033 – 32 = 2001 (linux-swap)

2001 – 500 = 1501 (ext2)

Remember these numbers for the next step.

6. Create partitions

You MUST create partitions in this order: fat32, ext2, and then linux-swap. Type in the command for each one at a time. The commands should look like this:

  • mkpartfs primary fat32 0 1501
  • mkpartfs primary ext2 1501 2001
  • mkpartfs primary linux-swap 2001 2033

Need more explanation? Did you run into a problem?

7. Confirm that everything went according to plan

Enter “print” and you should now see something like this:

07_printconfirm

8. Close parted by typing “quit”

You need to exit parted in order to upgrade the SD Card. Don’t worry if a message about updating fstab appears.

9.a Convert ext2 to ext3

You’ll probably need to upgrade to ext3 or ext4 for your ROM to install apps to the SD card. What’s the difference? They perform the same basic functions and you can easily get by on ext3 without any problems; ext4 is just the next version that includes improved performance. More info available here.

  • Convert to ext3
    Type “upgrade_fs” and press enter.
    You are now DONE! You can re-enter parted and enter “print” to confirm the change took place or proceed to step 10 to exit.

9.b. Upgrade to ext4

This is an OPTIONAL step. After you have upgraded to ext3, you can choose to go to ext4 by typing the following commands. They are case sensitive, so make sure that you type upper-case letters when necessary. Remember that typing in console is different from what you normally do in a G1. Rather than pressing the up arrow button once and then a letter to capitalize, you must hold down the arrow button and then press the letter.

  • tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p2
  • e2fsck -fpDC0 /dev/block/mmcblk0p2

Once file check is done, you can re-enter parted and enter “print” to confirm the change took place or proceed to step 10 to exit.

09b_success

10. Exit and return to recovery screen

If you followed all the instructions, your SD card should know have an SD partition. As you start installing apps, you’ll notice that those pesky running out of space errors will be a distant memory.

  • If you’re in parted still, enter “quit”
  • Enter “recovery” and you’ll be returned to the recovery screen.
  • Reboot your Android phone by selecting “[Home + Back”

Be sure to read our introductory article for more tips!