Using Raspberry Pi 4 with a power adapter only
Tags: raspberrypi, iot, linux
Published: 2019-06-27 08:58:07

## Story

I ordered my Raspberry Pi 4 one hour after its world premiere on Monday morning from a train to London. I rushed through the https://thepihut.com/ checkout process to ensure that I got my board before they run out of stock and, more importantly, while I still got a 3G signal on my mobile.

I admit I got prompted by the website to buy an HDMI cable which I kindly refused to. After all I also have a Raspberry Pi Zero W which uses a Mini-HDMI port so I was sure I was fully covered and I didn't need yet another HDMI cable.

How wrong I was! The next evening I received the board I noticed my Mini-HDMI is huge compared to the Micro-HDMI connectors that Raspberry Pi 4 use now.

I quickly ordered a Micro-HDMI cable with a next-day delivery but I still wanted to use my newly arrived board now. No, I mean it. NOW!

## Headless mode

Luckily I knew there was a way to run the previous version of Raspberry Pi in a headless mode, i.e. without a display, keyboard and mouse. So I thought that maybe it would be possible to install the operating system without connecting it to a display too.

And it was indeed. Here is how I did it. The key part was to skip the NOOBS installer entirely (even with its `silentinstall` option which didn't work for me) and clone the Raspbian image directly onto the SD card.

All you need to start enjoying your new board with only a power adapter at your disposal is:

* a Unix-based computer with an SD card reader
* an SD card

## Download Raspbian

Go to https://www.raspberrypi.org/downloads/raspbian/ and start downloading **Raspbian Buster Lite** zip file.

## Prepare your SD card

Insert your SD card to your card reader and run `sudo fdisk -l` to check its `/dev/sdX` path.

![](https://thepracticaldev.s3.amazonaws.com/i/qi2e8gq2c7up6gmwxb1f.jpg)

In my case the SD card reader was at `/dev/sde`.


Now run an app called `gparted` and select your device from a drop-down in the top-right.

If your SD card is a brand new one and has not been formatted yet you might need to create a partition table. Simply click _Device_ → _Create Partition Table…_ from the main menu.

![](https://thepracticaldev.s3.amazonaws.com/i/lxpnhqawg1fe7s8ufw35.jpg)

You can now create a new partition. Just create a single one with the maximum capacity and format it using `ext4` filesystem.

## Install Raspbian

Extract an `2019-06-20-raspbian-buster-lite.img` file from the downloaded *Raspbian Buster Lite* zip package.

Write the image onto the SD card using below command:

```
sudo dd if=2019-06-20-raspbian-buster-lite.img of=/dev/sde bs=4M conv=fsync
```

## Enable SSH and setup WiFi

The above `dd` utility has created two partitions on your SD card: `boot` and `roofs`.

Go to the `boot` “directory in your file browser and create an empty file named `ssh`. This will enable the SSH protocol for you Raspberry.

Create another file in the same boot path named `wpa_supplicant.conf` and paste below content to it:

```
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="Your network name, e.g. BTHub1-123QWE"
    psk="Y0ur_P455w0rd"
    key_mgmt=WPA-PSK
}
```

Replace `country`, `ssid` and `psk` values to match your WiFi settings.

## Grande finale

Your SD card is now ready. Insert it to your Raspberry Pi SD card slot at the bottom of the board.

Connect a power adapter.

Scan your local network (in my case `192.168.1.*`) to see what IP address has been assigned to the Raspberry Pi.

```
sudo nmap -sS -p 22 192.168.1.0/24 | grep "Nmap scan"
```

You can power off the board to see which of the IP addresses will disappear from the list to identify the Pi.

Connect to the board:

```
ssh pi@192.168.1.101
```

The password is `raspberry`.

![](https://thepracticaldev.s3.amazonaws.com/i/no8yiigcf93c8o4mztgi.jpg)

You're back in the game! Change your password with `passwd` and enjoy!

## Bonus! Change WiFi after installation

Let's say you have changed your WiFi password but your Raspberry is no longer in a pre-installation mode. Don't worry! It's much easier to change WiFi password for a Raspberry that has an operating system already installed.

Simply eject an SD card from your Raspberry and read it on your PC's card reader. Then locate the `/etc/wpa_supplicant/wpa_supplicant.conf` file and replace your WiFi settings there. Remember to `sudo` yourself in order to access and overwrite this file.