Partitioning the SD card for app2ext with adb shell

My Motorola Milestone kept nagging me with “Not enough free disk space”. As I am running the latest FroyoMOD, I started investigating the built in app2sd / app2sd+ / app2ext. Unfortunately, I did not have an SD card reader at hand and tried to use an adb shell to set up the needed partitions while the card was in the phone. Following these steps I soon ran into problems. Nevertheless, it put me on the right track to free some of that precious space on the internal flash and this is what worked for me:

  1. Connect your mobile phone in USB debugging mode and enable “mass storage share”.
  2. Backup your SD card with rsyncI recommend rsync becaus the USB link may not be very stable and copying 16GB of data might need several runs of rsync.
  3. No, seriously! Backup the complete SD card with hidden folders and everything, or else the apps you already moved to the SD card with app2sd will break in this process and leave you with half dead apps that need to be shot.
  4. After the backup, disable “mass storage share”.
  5. adb shell to your device.
  6. Unmount the SD card partitions with umount /mnt/sdcard/.android_secure and umount /mnt/sdcard
  7. Use fdisk /dev/block/mmcblk0 to repartition the SD card to your liking (recommended: 512MB Linux partition for app2ext, rest of SD card for FAT)
    1. Delete the old partition table: d Beware! This is where you wipe the SD card. You did make a backup, right?
    2. Create new primary partition: n p 1 enter +15500M Adjust the value to the size of your SD minus ~512MB.
    3. Mark it as FAT: t b  This will be the new partition visible as „mass storage share“.
    4. Create new primary partition: n p 2 enter enter This will use up the available space of your SD card for the app2ext Linux partition.
    5. Print the new partition table: p
    6. Check that you now have a WIN95 FAT32 partition /dev/block/mmcblk0p1 and a Linux partition /dev/block/mmcblk0p2 If not, read up on fdisk and go back to step a.
    7. Write the new partition table with w.
  8. Format the FAT partition with newfs_msdos -F 32 /dev/block/mmcblk0p1
  9. Format the Linux partition with mkfs.ext2 /dev/block/mmcblk0p2
  10. Convert the ext2 partition to ext4 with tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p2 (if you want to use ext2 go to step 11)
  11. Force a filesystem check with e2fsck -fDC0 /dev/block/mmcblk0p2 Fix any errors with y.
  12. Reboot your phone with reboot, FroyoMOD will now automagically mount the partitions as /mnt/sdcard and /sd-ext, move your remaining apps from the phone flash to the new ext partiton on the SD card and in general do some crazy mount and link magic. Read: you do not need to wait for anything to happen at this point.
  13. Enable “mass storage share”. Don’t worry, this will not interfere with the previous step.
  14. Restore your SD card with rsync. This will also restore the apps you moved to the SD with app2sd. Nice to have a backup, right?
  15. Disable “mass storage share” to give your phone complete access to the SD card again.
  16. To move the app2sd apps on the “mass storage share” partition to the new app2ext partition go to Menu -> Settings -> Applications Manage Applications -> On SD Card and move the apps back to the “phone”. This might be confusing, but the app2ext partition is transparent to app2sd, so moving an app to the phone actually moves it to the new app2ext partition on the SD card.
  17. Congratulations, you are done! Enjoy more free space on the phone and slightly better performance (depending on you SD card)!

Bonus hints gained while investigating:

  • The available milestone kernels are missing the swap module, so don’t bother setting up a swap partition.
  • I have not tried creating the 512MB ext partition first and then auto filling up the rest of the SD with FAT, tell me how it goes. It should work.
  • Unfortunately, there is no mkfs.vfat on a running FroyoMOD busybox. And I could not boot into Recovery Mode to see if it was available there.
  • My linux fu is still usefull on an android phone and it was interesting to see the way android taylored linux to its needs.
  • I still don’t understand the difference between app2sd and app2sd+ … if such a thing even exists …

Leave a comment below if I could help you with this.

so long

Veröffentlicht von Jörn Dreyer

learned in a bank, studied business informatics, took the red pill and went down the rabbit hole of software engineering til a Ph.D.

8 Antworten auf „Partitioning the SD card for app2ext with adb shell“

  1. For Linux old bones:
    You can use Parted/Gparted on Ubuuntu to manage partitions on the SD card in your phone. Just hook it up via USB, do unmount, start Parted.
    Now the old geeks should feel good.
    The next thing for me is to copy/link /data (or parts of it) to sdcard.

  2. A good guide. Thanks for that. I am not sure if SWAP partition on the SD would be a good idea. Even the fastest available MicroSDs‘ (Class 10) speed is around 25MB/s. Having may open applications might be too slooow. We will also lose the possibility to Hot-Swap or umount SD card. But it is really worth trying. It appears that there are few Apps to enable it. I am not going to mention them since I did not test them personally.

    Regarding having EXT4 at the beginning and FAT at the end, I do not think that it should be a problem.

  3. I followed the above steps and was able to partition my sd card. However i cannot copy any new files to the FAT32 partition of SD Card it gives me disk full error even though it has more than 90% free space. Let me know how to solve the issue

Kommentare sind geschlossen.