Skip to content

Commit

Permalink
Deploy: Increase swap size for Raspberry Pi builds
Browse files Browse the repository at this point in the history
Deploy: Increase swap size for Raspberry Pi builds

Raspbian sets the swap size to 100MB by default, which causes the npm install step to hang the system on devices with 500MB of RAM. About 700MB of total memory is needed for the build/install process.

This commit adds a step to build_rpanion.sh to increase the swap size, which enables the installation to complete successfully.

Fixes issue #207 and maybe #208 also
  • Loading branch information
ddd999 authored and stephendade committed Apr 1, 2024
1 parent d5ceab5 commit e87b2a7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions deploy/RasPi2-3-4-5-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ git submodule update --init --recursive
sudo raspi-config nonint do_camera 0
sudo raspi-config nonint do_ssh 0

# Increase swap size to 1024MB if it is currently less than 1000MB
# Allows the NPM build to complete successfully on systems with 500MB of RAM
if [ $(stat -c%s "/var/swap") -le 1000000000 ]; then
echo "Swap file is less than 1000MB. Increasing to 1024MB."
sudo dphys-swapfile swapoff
sudo sed -i '/CONF_SWAPSIZE=.*/c\CONF_SWAPSIZE=1024' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
else
echo "Swapfile is already >1000MB"
fi

## Pi5 uses a different UART for the 40-pin header (/dev/ttyAMA0)
# See https://forums.raspberrypi.com/viewtopic.php?t=359132
if [ -e "/proc/device-tree/compatible" ]; then
Expand Down

0 comments on commit e87b2a7

Please sign in to comment.