2

Is there a safe way to do a headless install of Raspbian with a WiFi-only network? I have a laptop with an SD slot to preconfigure the SD card as necessary. By "safe" I mean that at no point do I need to uncleanly power off the Pi.

The closest I have gotten is this:

  1. Use my laptop to prepare the SD card with NOOBS, and configure it to do a silent install. (https://github.com/raspberrypi/noobs/blob/master/README.md)
  2. Boot the Pi with the SD card and let it do the install of Raspbian. (essentially just wait for an hour or so)
  3. Uncleanly power off the Pi. I have no alternative at this point because I am headless, and the Pi is not yet on the wifi network.
  4. Insert the SD card back into the laptop and configure wifi settings found in /etc/networking/interfaces and /etc/wpa_supplicant/ as necessary.
  5. Boot the Pi again, and see it connect to wifi.

This worked, for me, but I'm very wary of step 3. Uncleanly powering off the Pi even just once or twice seems to be a big no-no (to the point that the question of how to do this as safely as possible isn't viewed as a legitimate question by the community: Safest way to switch off uncleanly (edit: At time of writing the linked question had been closed as a dupe. This has since been reverted.)).

I am hoping there is some additional tweaking of the SD card I can do in step 1, in order to pre-configure the Raspbian image with my WiFi settings. Does anyone know if this is possible and documented somewhere?

3
  • 4
    Powering off the Pi is much over hyped. Provided you wait until activity has ceased there is little risk. Installing NOOBS without a keyboard is almost impossible (there is no partition to configure, it is "created" on boot). If you still want to try, install Raspbian.
    – Milliways
    Commented Mar 5, 2015 at 9:37
  • 2
    Yes, install Raspbian directly, no need for NOOBS. You can preconfigure Raspbian on your laptop to a state where you can ssh into it an do the remaining configuration.
    – user236012
    Commented Mar 5, 2015 at 10:38
  • I thought I had bought the Rpi 2(I guess I was so excited I didn't check) and so I unpluged like 20 times while trying to install rpi 2 custom images.;) But it still works like a charm and the micro sd card isn't corrupted....yet.
    – NULL
    Commented May 19, 2015 at 10:42

4 Answers 4

2

I found an even easier way to setup a headless Raspberry Pi without ever needing to connect the Pi to a monitor, keyboard and mouse. This solution is probably the best answer for new users as it has a total of 1 step to complete.

  1. Use PiBakery to image your SD Card. You can specify your WiFi. Even turn on VNC. Comes with SSH enabled, and offers other options that automatically run the first time you start your Pi.

Pretty cool!

1
  • Thanks Ricardo, I've been using PIBakery alot for my work with Pi's now. Commented Dec 21, 2017 at 10:55
0

I believe I have seen the answer to this question before, but I can't remember quite where.
Anyway, this is the best way to do a headless install:

  1. Edit flavours.json in the raspian dir of noobs, and remove the boot to scratch option.

  2. Edit recovery.cmdline and put "silentinstall" at the end of the file.

  3. (Most important part, what you are probably lacking) Download noobs config: https://github.com/procount/noobsconfig/archive/master.zip

  4. put customize.sh from noobsconfig in the root dir of your sd card.

  5. create a folder named “wifi” in “/os/Rasbian/” on your sd card.

  6. copy wpa_supplicant.conf out of noobs config (/Examples/Rasbian/wifi/wifi/wpa_supplicant.conf) to that dir. (wifi)

  7. edit the wpa_supplicant file and supply your wifi info.
    You should then be able to boot up and have it connect to wifi automatically.

1
  • I just realized you already can do silent install, but it might help others who read this question if I include how.
    – jamesraf18
    Commented Jul 25, 2015 at 1:39
0

I know that this is a very late answer, but I think that the previous answers aren't as simple as they need to be. This method only requires a raspberry pi, a WiFi dongle (if using Pi 2 or earlier), another computer to SSH into it, and a power cable, and it works with secured WiFi networks.

Install Raspbian Jessie Lite from the official downloads page, and follow the instructions here to install onto the SD card, choosing your operating system. Once it has installed, mount the boot partition on your computer, and create an empty file named ssh with no extension, if you want ssh to be enabled. For WiFi, create a plaintext file named wpa_supplicant.conf, containing your SSID of the WiFi network you are using and, the key. It is in this format:

network={
    ssid="Your SSID"
    psk="Your wifi password"
}

Close the file and boot the pi. From the other computer, type ssh pi@<ip_address_of_your_pi>, or ssh [email protected], if your system supports it, and type raspberry as the password. A login shell should open. You should change your password from the default with the command passwd, and run sudo raspi-config to set up the software. You can also set up a static IP address here.

6
  • How do I tell what the IP of this will be (given that it'll be on DHCP), or do I need to be the operator of the wifi AP for that to work? Commented Mar 9, 2017 at 12:37
  • You could use ssh [email protected] if your system has support, or use nmap, i.e. nmap -n -p 22 --open 192.168.0.0/24. Also, there is Adafruit Pi Finder
    – Will
    Commented Mar 11, 2017 at 12:47
  • 1
    @DannyStaple You can create a static IP once you have logged in. See here for an updated way of achieving this.
    – Will
    Commented Mar 11, 2017 at 12:58
  • 1
    @DannyStaple You can even configure the router to reserve an Address for the device connected in the Lan setup i guess Commented Dec 20, 2017 at 20:19
  • @AnEpicPerson Where to create wpa_supplicant.conf file in the root ? Commented Dec 21, 2017 at 14:57
0

It is easy using any windows laptop

  1. First format the SD card using Ubuntu or any Linux based system or virtual machine
  2. Use window disk imager download here
  3. Download latest raspbian Jessie
  4. Load IMG file in window disk imager
  5. Let it complete
  6. Remove SD card and insert it into raspberry
  7. If it is latest Jessie then put a file name ssh in its boot folder, file will let the system know you want ssh connection
  8. Power on raspberry
  9. Connect it via LAN or router
  10. Find IP address
  11. Then login via putty or any serial terminal
1
  • 1
    How can be "Connect it via LAN or router" a valid step for a question that includes "WiFi only network" in its title? Commented Aug 25, 2019 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.