Close

Update 6 - Headless Raspberry Pi Install

A project log for Smart Lock with Web Interface

Raspberry Pi based smart lock for apartment dwellers

chrisChris 12/14/2017 at 20:450 Comments

A headless Raspberry Pi Zero W install isn’t terribly difficult, but I’m including a fairly comprehensive list of steps here because this process is always changing and many online guides are out of date.

  1. Download the latest Raspbian image (https://www.raspberrypi.org/downloads/raspbian/). I like the full image because it includes everything just in case I need something later. This build uses more memory and flash, but I’ve convinced myself it will save time later on if I need something. The clean image only uses abut 75MB of memory anyway, so the trade-off isn’t bad.
  2. Unzip the image. On Windows I use Etcher (https://etcher.io/) to write it my SD card. I use a 16GB card, but you can get away with 8GB. Same as above, I’m a fan of paying an extra $2 now to avoid any future space issues.
  3. Enable SSH by placing a blank file named “SSH” in the root directory of the boot partition. Before 2016 SSH was enabled by default. The boot partition is FAT32 formatted, so you will be no issues accessing the drive.
  4. Set your wireless settings (https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md). These are in the ext4 formatted partition (the big one that most stuff is stored on) which Windows cannot access on its own. I use the ext2fsd driver (http://www.ext2fsd.com/) for Windows to get around this. Always be sure to “flush cache to disk” and properly eject the SD card from Windows before taking the card out. Go to /wpa_supplicant/wpa_supplicant.conf and add to the bottom of the file
    network={
    ssid="YOUR SSID HERE"
    psk="YOUR PASSWORD HERE"
    }  
    You can have multiple sections like this if you will be moving your Pi to different networks. If you follow the link above, there are instruction to encrypt your password if you don’t want it saved in plain text.
  5. Once you pop the card in the Raspberry Pi, it should be on your wifi within 30 seconds. You can then SSH in with the default username: pi and default password: raspberry. I use Putty for this (and you should too) in Windows (http://www.putty.org/). The hostname raspberrypi will eventually show up on your network, but I normally find it faster to go to my router and find the IP address.
  6. For debugging, it’s always good to know you can start the RealVNC server to remotely view the desktop. Just run
    vncserver  
     to start the server. You can then use any VNC viewer (https://www.realvnc.com/en/connect/download/viewer/windows/) on another system to connect.
  7. I occasionally use X11 forwarding instead of VNC for remote viewing. On Windows you’ll need Xming (https://sourceforge.net/projects/xming/) installed and X11 forwarding enabled in Putty. In Putty the only change you need to make is to check the box in the settings at Connection -> SSH -> Enable X11 forwarding. You do not need to set any display locations. The standard Xming settings are fine. To start the desktop over SSH using Xming, use Putty to connect over SSH, then run
    lsession &
    For anyone very new to Linux the ‘&’ tells the system to run the previous command in the background, which lets you keep using you current SSH window. VNC generally performs better than X11 though.
  8. Once you’re in, you should perform a system update
    sudo apt-get update
    sudo apt-get dist-upgrade
  9. And at a minimum change your password
    passwd 
  10. That's it. Others will tell you to also create a new user account and enable a firewall. This really depends on your use case and if you’re going to maintain control of the device. If you’re behind a router, using it for a dedicated purpose, and no one else is touching your Pi, you’re probably fine.

Discussions