-2

It used to be possible to just write a Raspberry Pi OS image to an SD card, mount the first partition and create a file named ssh, power up the Pi, and do everything else via ssh.

This was nice 1) because it's easy to document and 2) because it was easy to script.

Now, you can still use dd to write the image, and you can still enable ssh, but the installation won't proceed without asking for the keyboard layout and the name of the default user.

Is there any other way to set up Raspberry Pi OS from a fresh image without user interaction while setting up the SD card and without having to attach a monitor and keyboard to the Pi?

(I have seen questions like this and this, but they were from before the standard pi user was disabled).

1 Answers1

0

This used to be possible (although never that easy) but is not possible since Raspberry Pi OS no longer has a default user.

For some time Raspberry Pi OS has required that a user be generated on first boot. This was explained in https://www.raspberrypi.com/news/raspberry-pi-bullseye-update-april-2022/

It is POSSIBLE using the configuration menu in the RPi imager.

If you preconfigure during the imaging process you can set the hostname, user/password, Locale, wireless networking and enable ssh.

RPi Imager creates/modifies a file called firstrun.sh in the boot partition and modifies cmdline.txt to run this script on boot.

If you preconfigure during the imaging process firstrun.sh is modified to run /usr/lib/raspberrypi-sys-mods/imager_custom to set preconfigured data.


According to https://www.raspberrypi.com/documentation/computers/configuration.html#remote-access you can create a file named ssh in the boot partition of the SD card, then configure a user manually with userconf.txt although I have not done this on recent images.

These files are deleted on first boot.

Frankly it is easier to use a keyboard and monitor for initial setup.

Milliways
  • 62,573
  • 32
  • 113
  • 225