mirror of https://github.com/armbian/build.git
LowMem: Slim down initramfs and set /run size
This commit is contained in:
parent
66453c636f
commit
4c68c97ce7
|
|
@ -8,6 +8,28 @@
|
|||
# at build time.
|
||||
#
|
||||
|
||||
function post_family_tweaks_bsp__initramfs() {
|
||||
local LOWMEM_TMPFS_RUN_MB=${LOWMEM_TMPFS_RUN_MB:-20}
|
||||
display_alert "${EXTENSION}" "Set initramfs config for low memory" "debug"
|
||||
|
||||
# Create /etc/initramfs-tools/conf.d/armbian-lowmem.conf configuration file
|
||||
if [ ! -f "$destination/etc/initramfs-tools/conf.d/armbian-lowmem.conf" ]; then
|
||||
mkdir -p "$destination/etc/initramfs-tools/conf.d"
|
||||
install -m 644 /dev/null "$destination/etc/initramfs-tools/conf.d/armbian-lowmem.conf"
|
||||
|
||||
# Load only modules needed for boot
|
||||
echo "MODULES=dep" >> "$destination/etc/initramfs-tools/conf.d/armbian-lowmem.conf"
|
||||
|
||||
# /run is 10% of RAM by default
|
||||
# systemd throws errors when <16MB is *free* in this partition
|
||||
# during daemon-reload operations.
|
||||
# Address with a fixed /run size of ${LOWMEM_TMPFS_RUN_MB}
|
||||
echo "RUNSIZE=${LOWMEM_TMPFS_RUN_MB}M" >> "$destination/etc/initramfs-tools/conf.d/armbian-lowmem.conf"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function post_family_tweaks_bsp__copy_lowmem_config() {
|
||||
display_alert "${EXTENSION}" "Installing default configuration" "debug"
|
||||
|
||||
|
|
@ -41,7 +63,6 @@ function post_family_tweaks__enable_lowmem_mkswap() {
|
|||
}
|
||||
|
||||
function pre_umount_final_image__memory_optimize_defaults() {
|
||||
local LOWMEM_TMPFS_RUN_MB=${LOWMEM_TMPFS_RUN_MB:-20}
|
||||
# Optimize /etc/default settings to reduce memory usage
|
||||
display_alert "${EXTENSION}" "Disabling ramlog by default to save memory" "debug"
|
||||
sed -i "s/^ENABLED=.*/ENABLED=false/" "${MOUNT}"/etc/default/armbian-ramlog
|
||||
|
|
@ -49,15 +70,5 @@ function pre_umount_final_image__memory_optimize_defaults() {
|
|||
display_alert "${EXTENSION}" "Disabling zram swap by default" "debug"
|
||||
sed -i "s/^#\?\s*SWAP=.*/SWAP=false/" "${MOUNT}"/etc/default/armbian-zram-config
|
||||
|
||||
# /run is 10% of RAM by default
|
||||
# systemd throws errors when <16MB is *free* in this partition
|
||||
# during daemon-reload operations.
|
||||
# Address with a fixed /run size of ${LOWMEM_TMPFS_RUN_MB}
|
||||
if ! grep -qE "tmpfs[[:space:]]+/run[[:space:]]+tmpfs" "${MOUNT}/etc/fstab"; then
|
||||
# Skip if /run entry already exists in fstab (userpatches, etc)
|
||||
display_alert "${EXTENSION}" "Fixing /run size in /etc/fstab" "debug"
|
||||
echo "tmpfs /run tmpfs rw,nosuid,nodev,noexec,relatime,size=${LOWMEM_TMPFS_RUN_MB}M,mode=755 0 0" >> "${MOUNT}"/etc/fstab
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue