“Headless setup” of my Raspberry Pi 2 Model B

by Michael Urspringer - 20.02.2015

Yesterday my first Raspberry Pi 2 Model B arrived (I am glad that I have waited so long because I now could get the newest, faster version :-)).

I bought a package with the Pi, a power adapter and a small case and also a 32 Gb Micro SD card. I also ordered an USB Wifi Adapter (which has not yet arrived).

Here are my steps to get started with a “headless” installation (without a monitor or keyboard attached):

  1. Download the Raspbian operating system (http://raspbian.org/).
  2. Write the image file to your SD Card (I used Win32DiskImager to do that).
  3. You need to tell the Raspberry which IP address it should listen after boot.
    Locate the file “cmdline.txt” on the SD Card and open it with an editor (this file has only one line).
    Add the desired IP address at the end of the line, e.g. “ip=192.168.0.1”.
    Make sure you do not add additional (even blank) lines to the file and save it.
  4. Create a file “ssh” (no extension) in the root filesystem of the SD card (to enable the SSH login after boot)
  5. Prepare your PC: Set your Ethernet adapter to a fixed IP address in the same subnet as your Raspberry Pie  (e.g. 192.168.0.100).
  6. Directly connect the Pi to your Ethernet adapter on your PC.
  7. Power up the Pi and wait a minute until it has finished booting.
  8. Open a ssh connection to the IP address of your Pi (in this case: ssh 192.168.0.1).
    Use “pi” as user and “raspberry” as password.
  9. Now you should have a command prompt.

What I did next is to modify the network configuration of the Pi so that it uses a fixed address in my network. Here are the steps to do that:

  1. Edit /etc/network/interfaces:sudo nano /etc/network/interfacesMy file looks similar to that:
    auto lo
    iface lo inet loopback
     
    auto eth0
    iface eth0 inet static
    address 192.168.0.100
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1
     
    #allow-hotplug wlan0
    #iface wlan0 inet manual
    #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
    #iface default inet dhcp

    where:

    address: the IP address of your Pi, e.g. 192.168.0.100

    network: the network address of your network, e.g. 192.168.0.1

    netmask: the netmask of your network

    broadcast: the broadcast address of your network, mostly .255, e.g. 192.168.0.255

    gateway: the standard gateway; mostly the address of your router, e.g. 192.168.0.1

  2. Add the DNS server address to /etc/resolv.conf:sudo nano /etc/resolv
    nameserver=192.168.0.1

    nameserver: the IP address of our DNS server; mostly your router, e.g. 192.168.0.1

  3. Remove the “ip=192.168.0.1” from the first line in your “cmdline.txt” which you have set before.
  4. Attach your Pi to your network switch and reboot it (“sudo reboot”).
  5. It now should come up with the IP address you have specified in “/etc/network/interfaces” and you now should be able to connect to it with SSH
Tagged with:  

Leave a Reply

© 2000-2015 Michael Urspringer