Skip to content

Instantly share code, notes, and snippets.

@penk
Created December 16, 2016 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penk/4bc2d1d54b8255a72efa140707a0eb24 to your computer and use it in GitHub Desktop.
Save penk/4bc2d1d54b8255a72efa140707a0eb24 to your computer and use it in GitHub Desktop.
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