← Back to team overview

ubuntu-phone team mailing list archive

[PATCH] Create swap file on first boot

 

Hi everyone,

Please find attached a small patch that will create /data/swapfile on first boot.
If you don't want a swapfile, just create an empty /data/swapfile.

Pros:

 * The swap file can be removed from the rootfs, which makes that
   significantly smaller and faster to flash.
 * Once created, the swap file persists updates and does not need to be
   recreated.

Cons:

 * Can't think of any.

Details:

 * The patch should be applied to git://phablet.ubuntu.com/ubuntu/uchroot.
 * Creates /data/swapfile, if it does not exist yet.
 * Runs swapon, if the file exists and is not empty.

Hope this patch is acceptable and can be included for everyone.

f69m

commit 0a42c16f2d8410f5974467961833a1837000240f
Author: f69m <git+commit@xxxxxxx>
Date:   Fri Mar 1 19:54:23 2013 +0100

    Create swapfile as /data/swapfile

diff --git a/ubuntu_chroot b/ubuntu_chroot
index 0127e7d..d3029bb 100644
--- a/ubuntu_chroot
+++ b/ubuntu_chroot
@@ -27,10 +27,13 @@ UCHROOT=/system/bin/uchroot
 
 enable_swap()
 {
-    if [ -f /data/ubuntu/SWAP.swap ]
-    then
-        /system/xbin/swapon /data/ubuntu/SWAP.swap
-    fi
+	if [ ! -f /data/swapfile ]; then
+		/system/bin/dd if=/dev/zero of=/data/swapfile bs=1048576 count=100
+		/system/xbin/mkswap /data/swapfile
+	fi
+	if [ -s /data/swapfile ]; then
+		/system/xbin/swapon /data/swapfile
+	fi
 }
 
 export_qt5_shell_envvars()

Follow ups