Raspberry Pi Zero W – Backup USB Terminal

I often get lazy and don’t want to look up the IP of some PI that I just installed the OS on, nor do I want to go find the monitor.. This is where the USB SSH terminal comes in super handy.

This is a Linux thing, so if you have windows, I’m sorry. Google it more.

So step one is to install the ISO of your choice. I used the Raspberry Pi OS Lite version from the official source at: https://www.raspberrypi.org/software/operating-systems/, even though I don’t like Debian. The configuration files are all in the wrong place… anyways.. it’s stable and runs well.

Install is fairly straight forward. Unzip the download, and run dd. Replace the img with your image, and sdX is your SD card.

dd bs=1M if=2021-01-11-raspios-buster-armhf.img of=/dev/sdX conv=fsync

This will create two drives on your device, The first being boot, and the 2nd being root. Let’s start in boot. Touch the SSH file, and edit the config.txt to add the dtoverlay line.

touch /Volumes/boot/ssh
echo 'dtoverlay=dwc2' >> /Volumes/boot/config.txt

Now open cmdline.txt using your favorite text editor, which of course is Vim.

vi /Volumes/boot/cmdline.txt

add

modules-load=dwc2,g_ether

after “rootwait”, and before anything else. make sure there is only one space between all of them otherwise it will get borked. Now I’m going to be lazy and hook up both Wifi and USB Networking, so I’m going to configure the USB on a static IP address

vi /etc/dhcpcd.conf

Skip down to the bottom and add a USB configuration. In this example, I’m not specifiying the DNS entry for the USB, because I want it to pull data though the wifi when possible.

interface usb0
static ip_address=192.168.7.2
static routers=192.168.7.1
#static domain_name_servers=192.168.7.1

I don’t have a 192.168.7.xxx network anywhere, so I’m using that. Now I just go and configure my USB network on my PC to be a Static of 192.168.7.1, and I’m done. Plug the USB cable into the center USB connection, and wait for the light to turn on. Now I can SSH into the board without issue.

  ssh pi@192.168.7.2