I have a rom that supports swap, but the swap script is missing.

How would i make that swap script manually?

I.E: What code would be in the file /etc/init.d/07swapon?


1 Answer 1


How about this?

Open a console, navigate to the android SDK tools folder.
Type "adb mount /system", without the quotes doh!
Type "adb shell".
At the shell copy paste the following commands one by one and press enter after pasting them.
echo "#!/system/bin/sh" > /system/etc/init.d/05userinit
echo "swapon -a" >> /system/etc/init.d/05userinit
echo "/dev/block/mmcblk0p3 swap swap" >> /system/etc/fstab
chmod +x /system/etc/init.d/05userinit
chmod g-w /system/etc/init.d/05userinit
chmod o-w /system/etc/init.d/05userinit
chmod g-w /system/etc/fstab
chmod o-w /system/etc/fstab

Now you are back at the normal command prompt, type "adb reboot".
Device will reboot, when its done open a terminal and type "free".
It should show swap space allocated.

And with some programs in memory you can see swap being used:

adb shell
total used free shared buffers
Mem: 407860 399940 7920 0 872
Swap: 249596 16596 233000
Total: 657456 416536 240920

Information from here

  • hello, i've added a custom file in init.d and it cannot seem to be executed at boot
    – Joe
    Commented Apr 18, 2012 at 18:38
  • @Joe Your rom/kernel has to support init.d scripts. Does it?
    – Liam W
    Commented Dec 1, 2012 at 17:29
  • 1
    @TheAndroNerd yeah it does. but the rom, doesn't fix permissions of the scripts, so the built-in scripts in the init.d folder isn't being executed. tried "chmod +x" to everyone of them and it worked. :)
    – Joe
    Commented Dec 2, 2012 at 10:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .