From 84ef3d5289d99bf1cf9587c7428f9ca8671b4cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Pe=C4=8Dovnik?= Date: Thu, 14 Oct 2021 00:01:23 +0200 Subject: [PATCH] Extending free memory detection to swap (#3195) Host machines with 4Gb physical memory are unable to build all images. During workiin on CI improvements it was noticed that runners with just 4Gb of memory are unable to create rootfs cache or make an images even that should be sufficient. Memory reservations are set very conservatively and we can keep that since adding a swap into the equation proves to be enough. If host machine is running Armbian (which will be in most cases) our ZRAM / ZSWAP memory management takes care of securing that extra needed memory. --- lib/debootstrap.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/debootstrap.sh b/lib/debootstrap.sh index 862b7c7ce8..22358e07ad 100644 --- a/lib/debootstrap.sh +++ b/lib/debootstrap.sh @@ -36,10 +36,9 @@ debootstrap_ng() mkdir -p $SDCARD $MOUNT $DEST/images $SRC/cache/rootfs # stage: verify tmpfs configuration and mount - # default maximum size for tmpfs mount is 1/2 of available RAM - # CLI needs ~1.2GiB+ (Xenial CLI), Desktop - ~2.8GiB+ (Xenial Desktop w/o HW acceleration) - # calculate and set tmpfs mount to use 2/3 of available RAM - local phymem=$(( $(awk '/MemTotal/ {print $2}' /proc/meminfo) / 1024 * 2 / 3 )) # MiB + # CLI needs ~1.5GiB, desktop - ~3.5GiB + # calculate and set tmpfs mount to use 2/3 of available RAM+SWAP + local phymem=$(( (($(awk '/MemTotal/ {print $2}' /proc/meminfo) + $(awk '/SwapTotal/ {print $2}' /proc/meminfo))) / 1024 * 2 / 3 )) # MiB if [[ $BUILD_DESKTOP == yes ]]; then local tmpfs_max_size=3500; else local tmpfs_max_size=1500; fi # MiB if [[ $FORCE_USE_RAMDISK == no ]]; then local use_tmpfs=no elif [[ $FORCE_USE_RAMDISK == yes || $phymem -gt $tmpfs_max_size ]]; then