Headless Raspberry Pi setup w/o Ethernet

Some Raspberry Pi models such as the Zero and Zero W do not have an Ethernet port on the board. While one can use a USB-Ethernet adapter in the USB OTG port, if one wants to use only the Pi itself without adapters, the procedure below is required.

Install Raspberry Pi operating system on micro SD card.

On the SD card, edit /boot/config.txt, adding the line:

dtoverlay=dwc2

Now pick one of the following connection methods.

Ethernet over USB

Edit boot/cmdline.txt, adding after rootwait on the same line with a space:

rootwait modules-load=dwc2,g_ether

Boot the Pi with the micro SD card inserted, waiting 90 seconds or so. Then type from laptop (username, hostname are those picked for the Pi by the Raspberry Pi Imager program):

ssh username@hostname.local

If this doesn’t work, ensure that you see the new Ethernet port on your laptop. On Linux this would be seen in

ip a

reference

serial over USB

This method uses very basic USB drivers that should be on any laptop operating system.

Edit boot/cmdline.txt, adding after rootwait on the same line with a space:

rootwait modules-load=dwc2,g_serial

Boot the Pi with the micro SD card (using an HDMI monitor or SSH), and type in the Pi:

systemctl enable getty@ttyGS0.service

this is a one-time command that will be “remembered”

Reboot the Pi and connect from your laptop with a serial client like PuTTY at 115200 baud. You can find the port the device is on in Linux from

dmesg

ls /dev/tty*

before and after plugging in the Pi.


reference

Related: Headless Raspberry Pi setup with Ethernet