Of course you can. Although it seems like there's no problem to migrate dalvik-cache to a normal SD card filesystem (the most common, vfat), it still is highly recommended that you format your SD card to ext4 (or the same as your /data
) to ensure everything works fine.
So let's go. A full backup of all your apps is recommended before proceeding though if you feel lucky, it isn't required. Assuming that you have a terminal emulator to do the necessary jobs.
First, create a folder that you want to migrate your dalvik-cache to. Then chmod
and chown
the new folder to match /data/dalvik-cache
. If you're running a SELinux-enabled Android OS, don't forget to change security contexts correspondingly. Run
ls -dlZ /data/dalvik-cache
ls -lZ /data/dalvik-cache
to see the original permissions, owner/groups and security contexts of dalvik-cache folder.
Next, copy all files from /data/dalvik-cache
to your new location, for example /storage/sdcard1/dalvik-cache
. You can use cp -a
command to preserve file attributes, which would make things simpler.
Ensure no new apps start during the process of the following step.
Then, rm -r /data/dalvik-cache
and create a symbolic link to the new location using
ln -s /storage/sdcard1/dalvik-cache /data/dalvik-cache
That's all. We're done. Reboot your phone (not required but recommended).
Some notices about this process:
The busybox may not always work well as Android is based on a highly modified Linux kernel. For example almost all SELinux-related functions do not work properly. You can test it out as shown below.
toolbox ls -Z /data
busybox ls -Z /data
toolbox getenforce
busybox getenforce
However these may work properly, depending on Android version:
busybox chcon <context> <files...>
busybox runcon <context <program> [args...]
Never remove your SD card. If you re-format your SD card, make sure it's still ext4 AND create the dalvik-cache folder back before booting your phone for the first time.