Skip to content

Commit cbdef9a

Browse files
Implement workaround for low-mem models.
The installer makes a backup (in memory) of itself to /bootfs, but after restore to the new FAT32 partition doesn't remove that memory copy. The 256MB model is so memory constrained that it fails, likely due to an OOM problem. For those models (only), remove the RAM copy and when the new boot partition gets mounted (to /rootfs/boot), make a 'mount --bind' to /bootfs, so if any code assumes the data/files to be there, it'll still find them, so it won't break any code. This fixes #520. Signed-off-by: Diederik de Haas <[email protected]>
1 parent 44ed58e commit cbdef9a

File tree

1 file changed

+28
-0
lines changed
  • scripts/etc/init.d

1 file changed

+28
-0
lines changed

scripts/etc/init.d/rcS

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,23 @@ sync
11021102
umount /boot || fail
11031103
log_msg_end "OK"
11041104

1105+
model_memory=$(busybox free -m | grep "^Mem:" | awk '{print $2}')
1106+
low_mem_model=""
1107+
if [ "$model_memory" -le "260" ] ; then
1108+
low_mem_model="true"
1109+
else
1110+
low_mem_model="false"
1111+
fi
1112+
log_msg "Model memory in MB: '$model_memory' is a low mem model: '$low_mem_model'"
1113+
1114+
if [ "$low_mem_model" = "true" ] ; then
1115+
log_msg_start "Removing backup copy in /bootfs... "
1116+
rm -r -- /bootfs/*
1117+
log_msg_end "OK"
1118+
else
1119+
log_msg "Keeping backup copy in /bootfs"
1120+
fi
1121+
11051122
# only do modprobe if the module is NOT built into the kernel
11061123
if [ "$(grep -c $rootfstype /lib/modules/"$(uname -r)"/modules.builtin)" -eq 0 ]; then
11071124
log_msg_start "Loading $rootfstype module... "
@@ -1120,6 +1137,12 @@ mkdir /rootfs/boot || fail
11201137
mount $bootpartition /rootfs/boot || fail
11211138
log_msg_end "OK"
11221139

1140+
if [ "$low_mem_model" = "true" ] ; then
1141+
log_msg_start "Bind mount /rootfs/boot to /bootfs... "
1142+
mount --bind /rootfs/boot /bootfs
1143+
log_msg_end "OK"
1144+
fi
1145+
11231146
log_msg "Starting install process..."
11241147
# With 'cdebootstrap_cmdline we're actually using the word splitting what SC2086 warns us against
11251148
# This should probably be fixed at some point, but not in this run/branch.
@@ -1671,6 +1694,11 @@ chmod 0640 /rootfs/var/log/raspbian-ua-netinst.log
16711694

16721695
log_msg_start "Unmounting filesystems... "
16731696

1697+
if [ "$low_mem_model" = "true" ] ; then
1698+
log_msg_inline "removing bind mount to /bootfs... "
1699+
umount /bootfs
1700+
fi
1701+
16741702
umount /rootfs/boot
16751703
umount /rootfs
16761704
log_msg_end "OK"

0 commit comments

Comments
 (0)