RSS

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

Tue, Sep 8, 2009 | by Andrew Kameka

Hacks, 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!

, , , ,

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

13 Comments For This Post

  1. Joshua Canfield-Schatz Says:

    I must say that using gparted on linux was nice and easy. As much as I love the terminal, gparted is the way to go.

  2. GK Says:

    GNU parted supports non-destructive resizing of partitions using the ‘resize’ command. If you start with just a FAT32 partition (as most people will rather than this example which for some reason starts with an SD card that’s already got an ext2 partition) you can very likely just resize the FAT partition instead of deleting it. Still a good idea to back it up first though.

  3. Cherice Says:

    This is an excellent tutorial! I had tried another methiod first that didn't include the linux-swap command and it simply wouldnt work. Your directions were precise and worked perfectly. Thanks so much!!

  4. bluetooth maus Says:

    Its a nice one for all who wants to try android but i want try it until I am sure about the safety of my phone because loosing warranty might cause many bucks.

  5. Susan Says:

    I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

    Susan

    http://carusbcharger.com

  6. DM2 Says:

    Awesome guide. I tried it with the stock 1GB card that came with the phone. It worked perfectly.

  7. Shane Says:

    Thank you so much! only place I have found that gave clear and to the point directions that ACTUALLY WORKED!

  8. beto Says:

    yeah gr8 job man i was looking to do this in so many places but everywhere i went i was getting confusing info thnks a lot!!!! :)

  9. gerbil21 Says:

    i need help! I have the stock 1gb sd card and i did everything but when i get to the linux part it says "error the location 1024 is outside of the device /dev/block/mmcblk0" I dont know what this means everything worked good

  10. AndrewKam Says:

    Are you sure you removed the earlier partitions and did the math right when figuring how much space you have. What does your screen say?

  11. michael Says:

    Ok… doing the math was a bit tricky remembering which was which… fats32/linux/ext2…. but it all worked in the end… like every one else stated.. this was step by step at its best!

  12. Mike Says:

    With the stock sd card your actual size is 1016 so your partitions should look something like this:

    0 484
    484 984
    984 1016

  13. Irvine Says:

    When I try to partion according to the math, it tells me that my partions are too big/small

    My setup= 16.1 gigs.

    Isn't that 16,100-32= 16,068 (linux-swap)
    16,068-1024=15,044 (ext 2)
    That's make my Fat32 15,044 leftover, no?

    I'm lost. This 16gb sdcard is throwing me for a loop here.

Leave a Reply