Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add volatile-log boot parameter for mounting /var/log as tmpfs
commit 8f43fd71173f6da79b5029343e35285c8800a1de
Author: Penk Chen <penkia@gmail.com>
Date: Fri Dec 16 11:47:03 2016 +0000
Add volatile-log boot param
diff --git a/init b/init
index 43f1571..bb7f995 100755
--- a/init
+++ b/init
@@ -61,6 +61,7 @@ export fastboot=n
export forcefsck=n
export fsckfix=
export recovery=
+export volatile=
# mdadm needs hostname to be set. This has to be done before the udev rules are called!
@@ -164,6 +165,9 @@ for x in $(cat /proc/cmdline); do
rw)
readonly=n
;;
+ volatile-log)
+ volatile=y
+ ;;
debug)
debug=y
quiet=n
@@ -330,6 +334,13 @@ unset fastboot
unset forcefsck
unset fsckfix
+# To reduce log writing
+if [ "$volatile" == "y" ]; then
+ mkdir -p /var/log
+ mount -t tmpfs -o "noexec,nosuid,size=10%,mode=0755" tmpfs /var/log
+ mount -n -o move /var/log ${rootmnt}/var/log
+fi
+
# Move virtual filesystems over to the real filesystem
mount -n -o move /sys ${rootmnt}/sys
mount -n -o move /proc ${rootmnt}/proc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment