Skip to content

Instantly share code, notes, and snippets.

@atanasyanew
Created August 8, 2021 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atanasyanew/017e0d73005de50c82dab31806a4bb98 to your computer and use it in GitHub Desktop.
Save atanasyanew/017e0d73005de50c82dab31806a4bb98 to your computer and use it in GitHub Desktop.
RPI disable swap and log2ram
#!/bin/bash
if [ $1 = "uninstallswap" ]; then
echo "Uninstalling swapfile..."
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
sudo update-rc.d dphys-swapfile remove
sudo systemctl disable dphys-swapfile
echo "Swap file has been removed"
elif [ $1 = "disableswap" ]; then
echo "Disabling swapfile..."
if [ $(grep -c swappiness /etc/sysctl.conf) -eq 0 ]; then
echo "vm.swappiness=0" | sudo tee -a /etc/sysctl.conf
echo "updated /etc/sysctl.conf with vm.swappiness=0"
else
sudo sed -i "/vm.swappiness/c\vm.swappiness=0" /etc/sysctl.conf
echo "vm.swappiness found in /etc/sysctl.conf update to 0"
fi
sudo sysctl vm.swappiness=0
echo "set swappiness to 0 for immediate effect"
else
echo "Param not set, pass either 'uninstallswap' or 'disableswap'"
fi
#!/bin/bash
if [ ! -d ~/log2ram ]; then
git clone https://github.com/azlux/log2ram.git ~/log2ram
chmod +x ~/log2ram/install.sh
pushd ~/log2ram
sudo ./install.sh
popd
else
echo "Log2RAM is already installed. You can reinstall by running: 'sudo ./install.sh' from ~/log2ram "
sleep 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment