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:
- Connect your mobile phone in USB debugging mode and enable “mass storage share”.
- Backup your SD card with rsync. I recommend rsync becaus the USB link may not be very stable and copying 16GB of data might need several runs of rsync.
- 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.
- After the backup, disable “mass storage share”.
adb shell
to your device.- Unmount the SD card partitions with
umount /mnt/sdcard/.android_secure
andumount /mnt/sdcard
- 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)- Delete the old partition table:
d
Beware! This is where you wipe the SD card. You did make a backup, right? - Create new primary partition:
n p 1 enter +15500M
Adjust the value to the size of your SD minus ~512MB. - Mark it as FAT:
t b
This will be the new partition visible as „mass storage share“. - 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. - Print the new partition table:
p
- Check that you now have a
WIN95 FAT32
partition/dev/block/mmcblk0p1
and aLinux
partition/dev/block/mmcblk0p2
If not, read up onfdisk
and go back to step a. - Write the new partition table with
w
.
- Delete the old partition table:
- Format the FAT partition with
newfs_msdos -F 32 /dev/block/mmcblk0p1
- Format the Linux partition with
mkfs.ext2 /dev/block/mmcblk0p2
- 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) - Force a filesystem check with
e2fsck -fDC0 /dev/block/mmcblk0p2
Fix any errors withy
. - 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. - Enable “mass storage share”. Don’t worry, this will not interfere with the previous step.
- 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?
- Disable “mass storage share” to give your phone complete access to the SD card again.
- 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. - 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 FroyoMODbusybox
. 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
adb is not workin…
how to open adb shell??????????plzzzzzz help
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.
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.
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
Thanks – ths worked perfectly for me – Jorn.