WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 36b8b11

Browse files
committed
LowMem: Slim down initramfs and set /run size
1 parent c133a7d commit 36b8b11

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

extensions/lowmem.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@
88
# at build time.
99
#
1010

11+
function post_family_tweaks_bsp__initramfs() {
12+
local LOWMEM_TMPFS_RUN_MB=${LOWMEM_TMPFS_RUN_MB:-20}
13+
display_alert "${EXTENSION}" "Set initramfs config for low memory" "debug"
14+
15+
# Create /etc/initramfs-tools/conf.d/armbian-lowmem.conf configuration file
16+
if [ ! -f "$destination/etc/initramfs-tools/conf.d/armbian-lowmem.conf" ]; then
17+
mkdir -p "$destination/etc/initramfs-tools/conf.d"
18+
install -m 644 /dev/null "$destination/etc/initramfs-tools/conf.d/armbian-lowmem.conf"
19+
20+
# Load only modules needed for boot
21+
echo "MODULES=dep" >> "$destination/etc/initramfs-tools/conf.d/armbian-lowmem.conf"
22+
23+
# /run is 10% of RAM by default
24+
# systemd throws errors when <16MB is *free* in this partition
25+
# during daemon-reload operations.
26+
# Address with a fixed /run size of ${LOWMEM_TMPFS_RUN_MB}
27+
echo "RUNSIZE=${LOWMEM_TMPFS_RUN_MB}M" >> "$destination/etc/initramfs-tools/conf.d/armbian-lowmem.conf"
28+
fi
29+
30+
return 0
31+
}
32+
1133
function post_family_tweaks_bsp__copy_lowmem_config() {
1234
display_alert "${EXTENSION}" "Installing default configuration" "debug"
1335

@@ -41,23 +63,12 @@ function post_family_tweaks__enable_lowmem_mkswap() {
4163
}
4264

4365
function pre_umount_final_image__memory_optimize_defaults() {
44-
local LOWMEM_TMPFS_RUN_MB=${LOWMEM_TMPFS_RUN_MB:-20}
4566
# Optimize /etc/default settings to reduce memory usage
4667
display_alert "${EXTENSION}" "Disabling ramlog by default to save memory" "debug"
4768
sed -i "s/^ENABLED=.*/ENABLED=false/" "${MOUNT}"/etc/default/armbian-ramlog
4869

4970
display_alert "${EXTENSION}" "Disabling zram swap by default" "debug"
5071
sed -i "s/^#\?\s*SWAP=.*/SWAP=false/" "${MOUNT}"/etc/default/armbian-zram-config
5172

52-
# /run is 10% of RAM by default
53-
# systemd throws errors when <16MB is *free* in this partition
54-
# during daemon-reload operations.
55-
# Address with a fixed /run size of ${LOWMEM_TMPFS_RUN_MB}
56-
if ! grep -qE "tmpfs[[:space:]]+/run[[:space:]]+tmpfs" "${MOUNT}/etc/fstab"; then
57-
# Skip if /run entry already exists in fstab (userpatches, etc)
58-
display_alert "${EXTENSION}" "Fixing /run size in /etc/fstab" "debug"
59-
echo "tmpfs /run tmpfs rw,nosuid,nodev,noexec,relatime,size=${LOWMEM_TMPFS_RUN_MB}M,mode=755 0 0" >> "${MOUNT}"/etc/fstab
60-
fi
61-
6273
return 0
6374
}

0 commit comments

Comments
 (0)