From 5f778a505a6507efbd34dbfcd3c343b3b266b5c3 Mon Sep 17 00:00:00 2001 From: Matthias Reichl Date: Fri, 13 Sep 2019 10:28:56 +0200 Subject: [PATCH] init: make copying SYSTEM to RAM opt-in Copying SYSTEM to RAM eats up precious memory that'd be better used for kernel filesystem cache and other things and can takes quite some time on slower storage devices like SD cards. Instead of having two options to define a minimum RAM size (below which SYSTEM won't be copied) and the "noram" option (which disables copying completely) reverse the logic and use a single "toram" option which users can set on kernel command line if they want SYSTEM copied to RAM. Signed-off-by: Matthias Reichl --- packages/sysutils/busybox/scripts/init | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/sysutils/busybox/scripts/init b/packages/sysutils/busybox/scripts/init index 81e2e6735a..f86ccbd71e 100755 --- a/packages/sysutils/busybox/scripts/init +++ b/packages/sysutils/busybox/scripts/init @@ -41,9 +41,6 @@ GRUB_DEFAULT="" NBD_DEVS="0" FLASH_FREE_MIN="5" -INSTALLED_MEMORY=$(cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}') -SYSTEM_TORAM_LIMIT=1024000 - LIVE="no" BREAK_TRIPPED="no" @@ -914,11 +911,11 @@ check_update() { prepare_sysroot() { progress "Preparing system" - if [ "$SYSTEM_TORAM" = "no" -o "$INSTALLED_MEMORY" -lt "$SYSTEM_TORAM_LIMIT" ]; then - mount_part "/flash/$IMAGE_SYSTEM" "/sysroot" "ro,loop" - else + if [ "$SYSTEM_TORAM" = "yes" ]; then cp /flash/$IMAGE_SYSTEM /dev/$IMAGE_SYSTEM mount_part "/dev/$IMAGE_SYSTEM" "/sysroot" "ro,loop" + else + mount_part "/flash/$IMAGE_SYSTEM" "/sysroot" "ro,loop" fi mount --move /flash /sysroot/flash @@ -1019,11 +1016,8 @@ for arg in $(cat /proc/cmdline); do nosplash) SPLASH=no ;; - noram) - SYSTEM_TORAM=no - ;; - ramlimit=*) - SYSTEM_TORAM_LIMIT="${arg#*=}" + toram) + SYSTEM_TORAM=yes ;; live) LIVE=yes