|
8 | 8 | # at build time. |
9 | 9 | # |
10 | 10 |
|
| 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 | + |
11 | 33 | function post_family_tweaks_bsp__copy_lowmem_config() { |
12 | 34 | display_alert "${EXTENSION}" "Installing default configuration" "debug" |
13 | 35 |
|
@@ -41,23 +63,12 @@ function post_family_tweaks__enable_lowmem_mkswap() { |
41 | 63 | } |
42 | 64 |
|
43 | 65 | function pre_umount_final_image__memory_optimize_defaults() { |
44 | | - local LOWMEM_TMPFS_RUN_MB=${LOWMEM_TMPFS_RUN_MB:-20} |
45 | 66 | # Optimize /etc/default settings to reduce memory usage |
46 | 67 | display_alert "${EXTENSION}" "Disabling ramlog by default to save memory" "debug" |
47 | 68 | sed -i "s/^ENABLED=.*/ENABLED=false/" "${MOUNT}"/etc/default/armbian-ramlog |
48 | 69 |
|
49 | 70 | display_alert "${EXTENSION}" "Disabling zram swap by default" "debug" |
50 | 71 | sed -i "s/^#\?\s*SWAP=.*/SWAP=false/" "${MOUNT}"/etc/default/armbian-zram-config |
51 | 72 |
|
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 | | - |
62 | 73 | return 0 |
63 | 74 | } |
0 commit comments