Apps2SD
From CyanogenMod Wiki
Apps2SD moves your apps to the SD card, freeing up more room on your phone. As of the latest_version, apps2SD is not necessary, however, this may become a requirement in the future.
This is not recommended if using less than a Class 4 SD card, as it may randomly eject and cause all sorts of issues.
A Class 6 card is strongly recommended.
This will erase EVERYTHING from your SD card, so make sure to back it up before you start !
These instructions are for Cyanogen's latest recovery console (version 1.4)
Contents |
[edit] Pros
- More room on phone
- Easy recovery after wipe with fix_permission script (for most apps)
[edit] Cons
- Cannot remove SD card
- More complicated setup = more likely to break
- Possibly slower
[edit] Installation
[edit] via recovery console
- Power off your phone.
- Press and hold Home and then press Power to boot into recovery mode.
- Once in recovery mode, Press ALT+X (or select "go to console") to enter the command line. WARNING: There is no way to interact with the console on a phone without a keyboard, such as the HTC Magic. Instead, use the adb shell from your computer via usb.
- Once in the command line, press [enter] to continue.
- Type the following two commands to find the size of the SD card:
parted /dev/block/mmcblk0 [enter]
print [enter]
- Find the line that says "Disk /dev/block/mmcblk0: xxxxMB". Write this down!
- The next step is to delete all existing partitions.
rm 1 [enter]
rm 2 [enter]
etc... - Check to make sure all of the partitions were deleted.
print [enter]
- Once the SD card is blank, create the primary partition. (This is the amount of space you want for your music, pictures, etc.)
mkpartfs primary fat32 0 XXXX [enter]
- (XXXX = How many MB of storage you would like. Remember to leave 256-512 MB for your app partition, and optionally 64 MB for swap. You may need to put the number you wrote down for start in place of the zero if you are having trouble.)
-
Create the ext2 (application) partition.
mkpartfs primary ext2 XXXX YYYY [enter]- (XXXX = This will be the same XXXX number from step 9)
- (YYYY = XXXX + [256 or 512] (or whatever size you want to make this partition)
- (Optional) Create a swap partition. (Large sizes are unlikely to be useful, try 64MB or so.)
mkpartfs primary linux-swap YYYY ZZZZ [enter]
- (YYYY = This will be the same YYYY number from step 10)
- (ZZZZ = The end of your SD card (the initial size you wrote in step 6)
- See the Swap and Compcache page for instructions on how to enable swap.
- Check to see that the SD card was partitioned properly.
print [enter]
-
If everything is correct, exit parted, and run upgrade_fs to upgrade from ext2 to ext3
quit [enter]
upgrade_fs [enter]
-
(Optional)(Recommended) If you want, you can now upgrade from ext3 to ext4
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p2 [enter]
e2fsck -fpDC0 /dev/block/mmcblk0p2 [enter]
- Once that is finished, reboot the phone
reboot [enter]
Congratulations! Your SD card is now ready to use Apps2SD (CyanogenMod does the rest auto-magically)
[edit] Alternative mkpartfs parameters
When using larger SD cards (e.g. 16GB), parted does not print out MB values. To make installing easier (with less XXXX,YYYY,ZZZZ math!), you can pass parameters to mkpartfs as offsets from the end of the block device. Using the previous example (512MB ext2, 64MB swap), the parameters become:
-
mkpartfs primary fat32 0 -576mb [enter]
-
mkpartfs primary ext2 -576mb -64mb [enter] -
mkpartfs primary linux-swap -64mb -0 [enter]
This should work for any SD card size!
[edit] via Gparted
For a great Linux GUI alternative, use Linux 'GParted' a GUI based partition editor. (Designed for and found standard in the GNOME desktop environment, but can also easily be install in other desktop managers such as KDE and others.) Backup your SD card before you start ! The following steps will wipe the contents !
- Connect your phone to your computer
- Pull down the notification bar and mount the phone
- Start Gparted
- Gparted will search available drives. (Your phone should show up as a USB drive, and will be something like /dev/sdb1 or /dev/sdc1, etc..)
- In the upper right corner, select the correct USB device for your phone. (i.e. check to make sure it is correct size for your SD card)
- Right click on each partition and select 'unmount'
- Right click on each partition and select 'delete'
- If you know what you are doing, you can re-size the partitions and add a new 2nd partition formatted as ext2/3/4
- Right click on the big gray bar (should say unallocated x.xx gb) and click 'new'
- Enter configurations
- Free Space preceding = 0
- Create as = Primary
- New size = [don't touch]
- File system = fat32
- Free Space Following = 512 (or whatever you want)
- Click add
- Right click on the big gray bar (should say unallocated x.xx gb) and click 'new'
- Enter configurations
- Free Space preceding = 0
- Create as = Primary
- New size = [don't touch]
- File system = ext2/3/4 (recommend ext4)
- Free Space Following = 0 (or ~32 if you want swap)
- Click add
- If you want swap, set up one last partition with the remaining space as linux-swap
- Click edit, then 'Apply All Operations' to write changes to disk
- Quit GParted
- Unmount your SD Card
- Reboot your phone
Congratulations! Your SD card is now ready to use Apps2SD (CyanogenMod does the rest auto-magically)
[edit] via Amon_RA recovery
This is the easiest way by far. This will wipe everything from your SD card, so make sure to back up anything you want to keep.
- boot into recovery
- click [alt] + [p] or select "Partition sdcard"
- click [alt] + [o] or select "Partition SD"
- Follow onscreen instructions to set swap, ext3, and fat32 partitions
- reboot phone
Congratulations! Your SD card is now ready to use Apps2SD (CyanogenMod does the rest auto-magically)
[edit] via Recovery Console (no wipe)
This is the same as the 'via Recovery Console' section above, but it doesn't wipe your SD card! All data should be preserved, as long as you have enough free space.
- Power off your phone.
- Press and hold Home and then press Power to boot into recovery mode.
- Once in recovery mode, Press ALT+X (or select "go to console") to enter the command line.
- Once in the command line, press [enter] to continue.
- Type the following two commands to find the size of the SD card:
parted /dev/block/mmcblk0 [enter]
print [enter]
- Find the main partition (should only be 1), and write down the values under "Start" and "End"
- Subtract 256MB-512MB from the 'End' value, optionally another 64MB for swap
- enter the command:
resize <Partition_number> <start_value> <new_end_value>
- Example: If your original values were Partition number 1, "31.2kB" for "Start", and "1012MB" for "End", you might subtract off 256MB for apps, leaving 1012-256 = 756. So you would type:
resize 1 31.2kB 756MB (EXAMPLE ONLY! make sure to calculate your own numbers!)
- Example: If your original values were Partition number 1, "31.2kB" for "Start", and "1012MB" for "End", you might subtract off 256MB for apps, leaving 1012-256 = 756. So you would type:
-
Create the ext2 (application) partition.
mkpartfs primary ext2 XXXX YYYY [enter]- (XXXX = This will be the same "End" value from step 8)
- (YYYY = XXXX + [256 or 512] (or whatever size you want to make this partition)
- (Optional) Create a swap partition. (Large sizes are unlikely to be useful, try 64MB or so.)
mkpartfs primary linux-swap YYYY ZZZZ [enter]
- (YYYY = This will be the same YYYY number from step 9)
- (ZZZZ = The end of your SD card (the "End" value you wrote in step 6)
- See the Swap and Compcache page for instructions on how to enable swap.
- Check to see that the SD card was partitioned properly.
print [enter]
-
If everything is correct, exit parted, and run upgrade_fs to upgrade from ext2 to ext3
quit [enter]
upgrade_fs [enter]
-
(Optional)(Recommended) If you want, you can now upgrade from ext3 to ext4
tune2fs -O extents,uninit_bg,dir_index /dev/block/mmcblk0p2 [enter]
e2fsck -fpDC0 /dev/block/mmcblk0p2 [enter]
- Once that is finished, reboot the phone
reboot [enter]
[edit] via CLI (for *nix)
For incredibly detailed instructions on partitioning your sd card via a Linux/Unix(/Mac?) CLI, see Apps2SD_partitioning_via_*nix_CLI
[edit] Upgrading SD / Moving data to new SD
If you are using RA recovery, this is all done for you by making a BART backup. The following is if you're wanting to do it from the command line.
- First, backup your ext partition on to your fat32 partition. Note, you will need enough free space to hold all of your apps.
- In Terminal Emulator or recovery console:
mount -a [enter]
tar cvf /sdcard/ext.tar /system/sd [enter]
Note that you must have root access for Terminal Emulator. If you get "permission denied" after entering the above command, then try entering the command "su". "sudo" will not work. After entering "su" try the above command again. -
Or, Using ADB shell from your PC:
adb shellmount -a [enter]
tar cvf /sdcard/ext.tar /system/sd [enter]
- In Terminal Emulator or recovery console:
- Next, mount your SD card and download/backup everything on your fat32 partition. Make sure to get the ext.tar file that you just created in the previous step.
- Change cards/repartion, or do whatever it is you planned to do here. For instructions on creating new partitions see the installation instructions above.
- If you're not already, reboot into your recovery. Restore your backup files to your fat32 partition. Don't boot into CM yet!
-
Either go to console or ADB shell and type:
-
mount -a [enter]
-
tar xvf /sdcard/ext.tar [enter]
-
- Double check that your directories are moved with:
ls /system/sd [enter]
- Now you can reboot into CM!
- Run fix permissions to fix any corrupted permissions.
- Enjoy your new card!
- Note: If your applications continue to force close and not connect to the network. You will have to simply reinstall them by hand
[edit] Uninstall apps2SD
You will probably have to re-install any paid apps (app-private) but normal apps should run fine after this.
- First, you need to gain root access to the phone:
- For Terminal Emulator:
su [enter]
mount -o rw,remount /system [enter]
-
For ADB shell:
adb remount[enter]adb shell [enter]
- For Terminal Emulator:
- Next, you need to make a space for the apps on the internal phone SSD:
rm /data/app [enter]
mkdir /data/app [enter]
- And copy the files from the SD card to the phones internal SSD:
cp -r /system/sd/app/* /data/app/ [enter]
- Now, do the same thing for your paid apps (app-private):
rm /data/app-private [enter]
mkdir /data/app-private [enter]
cp -r /system/sd/app-private/* /data/app-private [enter]
- Now you will create a space for the dalvik-cache. No need to copy old data from the SD card, the phone will build all new data when it reboots:
rm /data/dalvik-cache
mkdir /data/dalvik-cache [enter]
- Lastly, reboot into recovery
reboot recovery [enter]
Once you are in recovery, go to the console, and press enter.
You now need to delete your apps2SD partition from your SD card, otherwise the phone will automatically reconfigure apps2SD and undo everything you just did:
-
parted /dev/block/mmcblk0 [enter]
-
rm 2 [enter]
-
quit [enter]
-
reboot [enter]
Note: If you had a 3rd partition for swap it will now be partition 2. Adjust your userinit.sh accordingly.
To confirm that apps2SD was removed, open the terminal emulator and run:ls -l /system [enter]and you should see 'app' and 'app-private' as directories (and not app -> /system/sd/app).
