###Use Minminal Image (https://www.linuxsystems.it/raspbian-wheezy-armhf-raspberry-pi-minimal-image/) ###Steps Below Uses the some the steps from the links belwo to optimize image ###(http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=61033) ###(https://extremeshok.com/1081/raspberry-pi-raspbian-tuning-optimising-optimizing-for-reduced-memory-usage/) ###Get sudo some images do not have apt-get -y install sudo ###First boot sudo raspi-config ###1. expand filesystem (can skip this step if extra partitions needed) ###2. Advanced Options -> Memory Split -> give 16MB to GPU ###3. Overclock 800Mhz ####Switch DNS resolve to Google Server (So packages will not update) sudo apt-get install resolvconf sudo nano /etc/resolvconf/resolv.conf.d/base nameserver 8.8.8.8 nameserver 8.8.4.4 ###(ctrl-x Save exit) ###Upgrade packages sudo apt-get update && sudo apt-get -y upgrade && sudo reboot ###Get rpi-update some images do not have sudo wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update -O /usr/bin/rpi-update sudo chmod +x /usr/bin/rpi-update sudo apt-get -y install git sudo apt-get -y install curl sudo apt-get -y install rpi-update ###Get raspi-config some images do not have sudo echo "deb http://archive.raspberrypi.org/debian/ wheezy main" >> /etc/apt/sources.list sudo wget http://archive.raspberrypi.org/debian/raspberrypi.gpg.key sudo apt-key add raspberrypi.gpg.key sudo apt-get update sudo apt-get -y install raspi-config ###Get lsusb images do not have sudo apt-get -y install usbutils ###Upgrade firmware ###Beta: FIQ_FSM USB driver rewrite (http://www.raspberrypi.org/forums/viewtopic.php?f=28&t=70437) sudo BRANCH=next rpi-update ###You must also edit cmdline.txt to add the following (fiq_fsm is not enabled by default): sudo nano /boot/cmdline.txt dwc_otg.fiq_enable=1 dwc_otg.fiq_fsm_enable=1 dwc_otg.fiq_fsm_mask=0x3 ###(ctrl-x Save exit) ###1. Setup kernel options sudo nano /boot/config.txt ###Copy Paste Below at end of File: arm_freq=800 core_freq=250 sdram_freq=400 over_voltage=6 gpu_mem=1 emmc_pll_core=1 force_turbo=1 init_emmc_clock=500000000 ###(ctrl-x Save exit) ###2. Setup kernel options sudo nano /boot/cmdline.txt elevator=noop ###sets the Network device not in turbo mode. turns off buffering network traffic smsc95xx.turbo_mode=N ###(ctrl-x Save exit) ####tune system sudo nano /etc/sysctl.conf fs.file-max = 150000 vm.min_free_kbytes = 16384 vm.dirty_background_ratio = 20 vm.dirty_expire_centisecs = 0 vm.dirty_ratio = 80 vm.dirty_writeback_centisecs = 1200 vm.overcommit_ratio = 2 vm.laptop_mode = 5 vm.swappiness = 10 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_sack = 1 net.ipv4.tcp_window_scaling = 1 net.core.rmem_default = 31457280 net.core.rmem_max = 12582912 net.core.wmem_default = 31457280 net.core.wmem_max = 12582912 net.core.somaxconn = 65536 net.core.netdev_max_backlog = 65536 net.core.optmem_max = 25165824 net.ipv4.tcp_mem = 65536 131072 262144 net.ipv4.udp_mem = 65536 131072 262144 net.ipv4.tcp_rmem = 8192 87380 16777216 net.ipv4.udp_rmem_min = 16384 net.ipv4.tcp_wmem = 8192 65536 16777216 net.ipv4.udp_wmem_min = 16384 ###(ctrl-x Save exit) ### Set the CPU scaling governor to performance sudo echo -n performance | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ###Fix fstab sudo nano /etc/fstab ###Add noatime to all, mount /var/run and other fast burning partitions to tmpfs (except /var/log) ###Mount /boot in ro mode: proc /proc proc defaults 0 0 none /var/run tmpfs size=1M,noatime 0 0 none /tmp tmpfs size=1M,noatime 0 0 none /var/tmp tmpfs size=1M,noatime 0 0 /dev/mmcblk0p1 /boot vfat noatime 0 2 /dev/mmcblk0p2 / ext4 defaults,noatime 0 1 ###(ctrl-x Save exit) sudo sed -i 's/defaults,noatime/defaults,noatime,nodiratime/g' /etc/fstab ###Setup fsck sudo nano /etc/default/rcS # automatically repair filesystems with inconsistencies during boot FSCKFIX=yes ###(ctrl-x Save exit) sudo tune2fs -c 3 /dev/mmcblk0p2 ###Replace syslog with inetutils-syslogd sudo su sudo apt-get -y remove --purge rsyslog sudo apt-get -y install inetutils-syslogd sudo echo -e "*.*;mail.none;cron.none\t -/var/log/messages\ncron.*\t -/var/log/cron\nmail.*\t -/var/log/mail" > /etc/syslog.conf sudo mkdir -p /etc/logrotate.d sudo echo -e "/var/log/cron\n/var/log/mail\n/var/log/messages {\n\trotate 4\n\tweekly\n\tmissingok\n\tnotifempty\n\tcompress\n\tsharedscripts\n\tpostrotate\n\t/etc/init.d/inetutils-syslogd reload >/dev/null\n\tendscript\n}" > /etc/logrotate.d/inetutils-syslogd sudo service inetutils-syslogd start ###Install ramlog sudo apt-get -y install lsof sudo dpkg -i /boot/ramlog_2.0.0-omv_all.deb ###Edit /etc/init.d/ramlog: sudo nano /etc/init.d/ramlog ### BEGIN INIT INFO # Provides: ramlog # Required-Start: # X-Start-Before: inetutils-syslogd # X-Stop-After: inetutils-syslogd sudo insserv ###Disable swapping sudo dphys-swapfile swapoff && sudo dphys-swapfile uninstall && sudo update-rc.d dphys-swapfile remove ###Disable IP6 echo "net.ipv6.conf.all.disable_ipv6=1" >> /etc/sysctl.d/disableipv6.conf echo "install ipv6 /bin/true" >> /etc/modprobe.d/blacklist.conf echo "install ipv6 /bin/true" >> /etc/modprobe.d/raspi-blacklist.conf sudo sed -i '/::/s%^%#%g' /etc/hosts ###Replacing OpenSSH with Dropbear sudo apt-get -y install dropbear openssh-client sudo sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear sudo /etc/init.d/ssh stop && sudo /etc/init.d/dropbear start sudo apt-get purge openssh-server ###Remove the extra tty / getty’s | Save: +3.5 MB RAM sudo sed -i '/[2-6]:23:respawn:\/sbin\/getty 38400 tty[2-6]/s%^%#%g' /etc/inittab sudo sed -i '/T0:23:respawn:\/sbin\/getty -L ttyAMA0 115200 vt100/s%^%#%g' /etc/inittab ###Use Dash instead of BASH sudo dpkg-reconfigure dash ###Move/etc/network/interfaces to Symbolic Link (http://rpi.tnet.com/project/faqs/winaccessinterfacesfile) sudo cd /etc/network sudo cp interfaces /boot/interfaces sudo mv interfaces interfaces.save sudo ln -s /boot/interfaces interfaces ###Setup enable second network interface to have DHCP sudo nano /etc/network/interfaces auto lo iface lo inet loopback allow-hotplug eth0 iface eth0 inet dhcp allow-hotplug eth1 iface eth1 inet dhcp ###(ctrl-x Save exit) ###Assign network names based on location so image can boot on different PI sudo nano /etc/udev/rules.d/70-persistent-net.rules KERNEL=="eth*", KERNELS=="1-1.1", NAME="eth0" KERNEL=="eth*", KERNELS=="1-1.[2-3]", NAME="eth1" ###(ctrl-x Save exit) ##Remove NTP from service so it does not interruppt Network ### Another way to disable NTP (http://windycitytech.blogspot.com/2013/03/disable-ntp-sending-out-requests-on.html) sudo update-rc.d -f ntp remove ###Install gbd for debug purposes sudo apt-get -y install gdb ###Get killall some images do not have sudo apt-get -y install psmisc ###Remove Unwanted services sudo apt-get -y purge libx11-6 libgtk-3-common xkb-data lxde-icon-theme raspberrypi-artwork penguinspuzzle sudo apt-get -y autoremove ###Clear cmd history sudo cat /dev/null > ~/.bash_history && history -c && exit ##Reboot to have all setting take effect sudo reboot