Permalink
Browse files

add swap activation to init.d to enable swap during boot

- requires swap partition present as third partition on sdcard
- swap size (in kB) is determined by persist.sys.swapsize property
- no persist.sys.swapsize property defined or set to 0
  means no swap activation

example:
  su
  setprop persist.sys.swapsize 16384
  reboot

Change-Id: I663cbec036e3f9d140d087e76d18a559890cc4bf
  • Loading branch information...
1 parent fdeb3c0 commit b0aa1f64a0f605fd0f8057a964b833ec3ed06117 @nadlabak nadlabak committed Dec 11, 2012
Showing with 21 additions and 0 deletions.
  1. +20 −0 prebuilt/etc/init.d/12swap
  2. +1 −0 umts_sholes.mk
@@ -0,0 +1,20 @@
+#!/system/bin/sh
+
+if ! [ -e /dev/block/mmcblk0p3 ]; then
+ exit
+fi
+if ! [ -e /data/property/persist.sys.swapsize ]; then
+ exit
+fi
+SWAPSIZE=`cat /data/property/persist.sys.swapsize`
+if ((SWAPSIZE == 0)); then
+ exit
+fi
+SWAPPARTSIZE=$((`cat /sys/block/mmcblk0/mmcblk0p3/size`/2))
+if ((SWAPSIZE > SWAPPARTSIZE)); then
+ SWAPSIZE=$SWAPPARTSIZE
+fi
+mkswap /dev/block/mmcblk0p3 $SWAPSIZE
+swapon /dev/block/mmcblk0p3
+echo 10 > /proc/sys/vm/swappiness
+log -p i -t swap "${SWAPSIZE} kB swap activated on mmcblk0p3";
View
@@ -149,6 +149,7 @@ PRODUCT_COPY_FILES += \
device/motorola/umts_sholes/prebuilt/etc/init.d/07app2ext:/system/etc/init.d/07app2ext \
device/motorola/umts_sholes/prebuilt/etc/init.d/08lib2ext:/system/etc/init.d/08lib2ext \
device/motorola/umts_sholes/prebuilt/etc/init.d/60autoboot_or:/system/etc/init.d/60autoboot_or \
+ device/motorola/umts_sholes/prebuilt/etc/init.d/12swap:/system/etc/init.d/12swap \
device/motorola/umts_sholes/prebuilt/etc/location.cfg:/system/etc/location.cfg \
device/motorola/umts_sholes/prebuilt/etc/powervr.ini:/system/etc/powervr.ini \
device/motorola/umts_sholes/prebuilt/etc/gpsconfig.xml:/system/etc/gpsconfig.xml \

0 comments on commit b0aa1f6

Please sign in to comment.