Advertisement
evgeniyosipov

rpi_optimise

Jul 28th, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.28 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Run script from home directory with this two commands:
  4. # sudo chmod u+x rpi_optimise.sh
  5. # sudo ~/rpi_optimise.sh
  6.  
  7. # Change the following word 'pi' to your own username if it's not 'pi'
  8. YOURUSERNAME="pi"
  9.  
  10. YELLOW="\033[1;33m"
  11. RED="\033[0;31m"
  12. BLUE="\033[1;34m"
  13. ENDCOLOR="\033[0m"
  14.  
  15. if [ $USER != root ]; then
  16.   echo -e $RED"Error: you need to be root! Use 'sudo'..."
  17.   echo -e $YELLOW"Exiting..."$ENDCOLOR
  18.   exit 0
  19. fi
  20.  
  21. # Remove unnecessary GUI programmes and their configuration files (obviously don't do this if you want a graphical desktop)
  22. echo -e $YELLOW"Removing pointless packages. This could take a while, maybe one should make a cup of tea."$ENDCOLOR
  23. apt-get purge --auto-remove scratch -y
  24.  
  25. apt-get purge --auto-remove debian-reference-en dillo idle3 python3-tk idle python-pygame python-tk -y
  26.  
  27. apt-get purge --auto-remove lightdm gnome-themes-standard gnome-icon-theme raspberrypi-artwork -y
  28.  
  29. apt-get purge --auto-remove gvfs-backends gvfs-fuse desktop-base lxpolkit netsurf-gtk zenity xdg-utilse -y
  30.  
  31. apt-get purge --auto-remove mupdf gtk2-engines lxde lxtask menu-xdg gksu -y
  32.  
  33. apt-get purge --auto-remove midori xserver-xorg xinit xserver-xorg-video-fbdev -y
  34.  
  35. apt-get purge --auto-remove libraspberrypi-dev libraspberrypi-doc -y
  36.  
  37. apt-get purge --auto-remove dbus-x11 libx11-6 libx11-data libx11-xcb1 x11-common x11-utils -y
  38.  
  39. apt-get purge --auto-remove lxde-icon-theme gconf-service gconf2-common -y
  40.  
  41. apt-get purge --auto-remove libreoffice* -y
  42.  
  43. rm -rf /home/$YOURUSERNAME/Desktop /home/$YOURUSERNAME/python_games /home/$YOURUSERNAME/ocr_pi.png
  44.  
  45. echo -e $YELLOW"Upgrading packages, normally takes a few minutes..."$ENDCOLOR
  46. aptitude update
  47.  
  48. aptitude -r full-upgrade -y
  49.  
  50. aptitude clean
  51.  
  52. echo -e $YELLOW"Updating Raspberry Pi firmware.."$ENDCOLOR
  53. rpi-update
  54.  
  55. # Remove the extra tty / gettys to save 3.5MB RAM
  56. echo -e $YELLOW"Removing extra ttys / gettys, to save some RAM"$ENDCOLOR
  57. sed -i '/[2-6]:23:respawn:\/sbin\/getty 38400 tty[2-6]/s%^%#%g' /etc/inittab
  58.  
  59. # Disable getty on the Raspberry Pi serial line
  60. sed -i '/T0:23:respawn:\/sbin\/getty -L ttyAMA0 115200 vt100/s%^%#%g' /etc/inittab
  61.  
  62. # Customise the size of the swap file, 512MB recommended
  63. echo -e $YELLOW"Customising swap to make better use of RAM..."$ENDCOLOR
  64. echo "CONF_SWAPSIZE=512" > /etc/dphys-swapfile
  65.  
  66. # Initialise the swapfile
  67. dphys-swapfile setup
  68.  
  69. # Enable the swapfile
  70. dphys-swapfile swapon
  71.  
  72. # Default swappiness is 1, we will change this value to 10, which will allow for better memory usage at the expense of more swap usage
  73. sed -i 's/vm.swappiness=1/vm.swappiness=10/g'  /etc/sysctl.conf
  74.  
  75. # Purge cached block devices before cached filesystem entries
  76. echo 'vm.vfs_cache_pressure=50' >> /etc/sysctl.conf
  77.  
  78. # Most users will not need IPv6 support - it's not used much yet, and can potentially pose a security threat (rarely). Disable it to save the resources and speed up networking.
  79. echo -e $YELLOW"Disabling IPv6 - it's not needed generally and will speed up networking a bit"$ENDCOLOR
  80. echo "net.ipv6.conf.all.disable_ipv6=1" > /etc/sysctl.d/disableipv6.conf
  81.  
  82. # Disable the kernel module
  83. echo 'blacklist ipv6' >> /etc/modprobe.d/blacklist
  84.  
  85. # Remove IPv6 hosts
  86. sed -i '/::/s%^%#%g' /etc/hosts
  87.  
  88. # All done!
  89. echo -e $BLUE"Script Finished! Reeboot then go grab a beer..."$ENDCOLOR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement