Skip to content

Instantly share code, notes, and snippets.

@viliampucik
Last active May 5, 2020 12:05
Show Gist options
  • Save viliampucik/fb2113d1b3d997627fd78b964590b883 to your computer and use it in GitHub Desktop.
Save viliampucik/fb2113d1b3d997627fd78b964590b883 to your computer and use it in GitHub Desktop.
Raspbian Headless
# Unmount mounted microSD card partitions, just in case
sudo umount /dev/mmcblk0p1
sudo umount /dev/mmcblk0p2
# Download the latest Raspbian and upload it to microSD card: https://www.raspberrypi.org/documentation/installation/installing-images/linux.md
wget https://downloads.raspberrypi.org/raspbian_lite_latest
unzip -p 2020-02-13-raspbian-buster-lite.zip | sudo dd of=/dev/mmcblk0 bs=4M conv=fsync status=progress
sync
sudo partprobe /dev/mmcblk0
sudo mkdir /tmp/rpi
sudo mount /dev/mmcblk0p1 /tmp/rpi
# Enable SSH at startup by creating "/boot/ssh" file: https://www.raspberrypi.org/documentation/remote-access/ssh/
sudo touch /tmp/rpi/ssh
# Disable Bluetooth: https://www.raspberrypi.org/documentation/configuration/uart.md
sudo tee -a /tmp/rpi/config.txt > /dev/null <<'EOF'
dtoverlay=disable-bt
EOF
# Optionally disable PWR (red) LED
sudo tee -a /tmp/rpi/config.txt > /dev/null <<'EOF'
dtparam=pwr_led_trigger=none
dtparam=pwr_led_activelow=off
EOF
sudo umount /tmp/rpi
sudo mount /dev/mmcblk0p2 /tmp/rpi
# Set static IP for eth0: https://www.raspberrypi.org/documentation/configuration/tcpip/
sudo tee -a /tmp/rpi/etc/dhcpcd.conf > /dev/null <<'EOF'
interface eth0
static ip_address=192.168.1.254/24
static routers=192.168.1.1
static domain_name_servers=9.9.9.9
EOF
sudo umount /tmp/rpi
sudo rmdir /tmp/rpi
# Boot RPi from microSD card
ssh pi@192.168.1.254
#raspberry
passwd
# Disable Bluetooth service: https://www.raspberrypi.org/documentation/configuration/uart.md
sudo systemctl disable hciuart
# Configure additional parameters: https://www.raspberrypi.org/documentation/configuration/raspi-config.md
sudo raspi-config
# OS update: https://www.raspberrypi.org/documentation/raspbian/updating.md
sudo apt update
sudo apt full-upgrade
# Optional update to 5.4 kernel: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=269769
sudo BRANCH=next rpi-update
# Firmware update: https://www.raspberrypi.org/documentation/hardware/raspberrypi/booteeprom.md
sudo sed -ie 's/critical/stable/' /etc/default/rpi-eeprom-update
sudo rpi-eeprom-update
sudo rpi-eeprom-update -a
# Reboot to apply the changes
sudo reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment