Skip to content

Instantly share code, notes, and snippets.

@IntegrityKnight
Last active May 3, 2019 01:19
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 IntegrityKnight/66c7184b53dfde6fffdb6fa2e7adbd08 to your computer and use it in GitHub Desktop.
Save IntegrityKnight/66c7184b53dfde6fffdb6fa2e7adbd08 to your computer and use it in GitHub Desktop.
Raspbian Stretch Headless Setup, wpa_supplicant.conf and empty ssh
# ------------ download and install raspbian
# show block device
lsblk
# umount folder
umount /media/<USER>/boot
umount /media/<USER>/rootfs
# install Raspbian
cd Downloads
sudo dd bs=4M if=2018-11-13-raspbian-stretch.img of=/dev/sdf status=progress conv=fsync
# reference ( linux installing ):
# https://www.raspberrypi.org/documentation/installation/installing-images/linux.md
# ------------ setup and tunning my raspbian
# SSH to Raspberry Pi
# change pi password and config local, hostname, timezone, keyboard layout.
sudo raspi-config
# update first
sudo apt-get update && sudo apt-get upgrade
# install rdp for windows user ( windows command "mstsc" )
sudo apt-get -y install xrdp
# install chinese fonts
sudo apt-get -y install fonts-arphic*
# install input method for chinese typing
sudo apt-get -y install scim scim-tables-zh scim-gtk-immodule im-switch
sudo reboot
# http://atceiling.blogspot.com/2017/03/raspberry-pi_26.html
# ------------ remove package
# remove "programming" package
sudo apt-get remove --purge --auto-remove bluej greenfoot nuscratch scratch scratch2 sonic-pi
# remove "Sense HAT Emulator"
sudo apt-get remove --purge --auto-remove python-sense-emu python3-sense-emu python-sense-emu-doc sense-emu-tools
# remove "Internet" package
sudo apt-get remove --purge --auto-remove claws-mail claws-mail-i18n
# remove "games" package
sudo apt-get remove --purge --auto-remove minecraft-pi python-minecraftpi python-pygame
rm -rf ~/python_games
# clean up
sudo apt-get clean
sudo apt-get autoremove
# reference
# http://yehnan.blogspot.com/2017/02/raspberry-pi.html
# ------------ backup and create image
# create image from TF card to linux
sudo dd bs=4M if=/dev/sdf of=/home/<USER>/Downloads/backup.img status=progress conv=fsync
# use pishrink.sh reduce image size
sudo pishrink.sh backup.img
# restore from shinked.img to TF card
sudo dd bs=4M if=shinked.img of=/dev/sdf status=progress conv=fsync
# https://www.raspberrypi-spy.co.uk/2018/03/free-space-raspberry-pi-sd-card/
# ------------ advance
# pi support exFAT
sudo apt-get update
sudo apt-get install exfat-fuse
# USB drive
lsblk
sudo mkdir /mnt/USB
sudo mount -o uid=pi,gid=pi /dev/sda1 /mnt/USB
sudo umount /mnt/USB
# https://www.raspberrypi.org/documentation/configuration/external-storage.md
# https://www.raspberrypi.org/forums/viewtopic.php?t=38058#p317871
# list package
dpkg-query -l> list_packages.txt
sudo apt-get remove --purge python-pygame minecraft-pi python-minecraftpi
# http://www.howtoptec.com/2016/08/delete-pre-installed-applications-on.html
# sftp to Raspbian
# use WinSCP or filezilla transfer files. Be caution, please use UTF-8 encoding in text file.
# Paste this file into boot folder for enable SSH function
# reference: https://www.raspberrypi.org/documentation/configuration/wireless/headless.md
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
# Please edit your country code, refer to "ISO 3166-1 alpha-2"
country=HK
network={
ssid="Your network SSID"
psk="Your WPA/WPA2 security key"
key_mgmt=WPA-PSK
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment