sudo apt-get update
sudo apt-get upgrade
sudo rm -rf opt
cd /var/log/
sudo rm `find . -type f`
sudo swapoff --all
sudo update-rc.d -f dphys-swapfile remove
sudo apt-get remove dphys-swapfile
sudo rm /etc/init.d/dphys-swapfile
sudo apt-get autoremove
sudo apt-get clean
sudo nano /etc/default/rcS
#Add "RAMTMP=yes" to the bottom
sudo nano /etc/fstab
#Add modify these lines
tmpfs /tmp tmpfs nodev,nosuid,size=30M,mode=1777 0 0
tmpfs /var/log tmpfs nodev,nosuid,size=30M,mode=1777 0 0
/dev/mmcblk0p1 /boot vfat defaults,ro,errors=remount-ro 0 2
/dev/mmcblk0p2 / ext2 defaults,ro,noatime,errors=remount-ro 0 1
sudo nano +60 /etc/init.d/hwclock.sh
#Change "-f" to "-L"
sudo nano /etc/environment
#Add "BLKID_FILE="/var/local/blkid.tab"" into the file
sudo rm /etc/mtab
sudo ln -s /proc/self/mounts /etc/mtab
cd ~
printf "mount -o remount,rw /\nmount -o remount,rw /boot" > writeenable.sh
printf "mount -o remount,ro /\nmount -o remount,ro /boot" > readonly.sh
chmod 500 writeenable.sh
chmod 500 readonly.sh
sudo nano /etc/rc.local
#Add following up to #end just before exit 0
echo ""
echo "Disk is mounted in readonly mode."
echo "To enable readwrite, run sudo ./writeenable.sh"
echo "To set back to readonly, run sudo ./readonly.sh"
#end
#To change hostname
#Replace “raspberrypi” with whatever hostname you desire.
sudo nano /etc/hosts
sudo nano /etc/hostname
sudo /etc/init.d/hostname.sh #Script to commit changes
history -c -w
sudo reboot
##References