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.
This commit is contained in:
Igor Pečovnik 2021-10-14 00:01:23 +02:00 committed by GitHub
parent d5662a50a2
commit 84ef3d5289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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