2

everytime I setup a new sd card for a pi, I first have to ssh to the running pi and then start to install some software via shell commands.

Isn't there a way to drop a shell setup file to the fat32 partition of a fresh sd card which then gets executed on the first run?

rdmueller
  • 277
  • 4
  • 16
  • 2
    Probably easier to put it into the root filesystem, unless a constraint is you can't access anything but the first partition. Enabling/activating a systemd service is really just a matter of creating a symlink, so it can be done without the system running. If that is too complicated, I think /etc/rc.local still runs by default, you could use or replace that. Beware tasks that require more than a second or two should fork and exit the foreground. – goldilocks Feb 22 '20 at 15:30
  • my main system is a windows device. I guess that says it all – rdmueller Feb 22 '20 at 16:24
  • "everytime I setup a new sd card" how often? why? I setup a SD Card about every 2 years when a new OS is released and then clone. – Milliways Feb 23 '20 at 01:13
  • you know, I also install additional software and I don't like to do it manually every time. In addition, when I experiment with setups, I would like to have the chance to easily roll back. – rdmueller Feb 23 '20 at 12:42

1 Answers1

3

This is a problem that was discussed in the past and has some suggestions to run a script only on the first boot up from the fat32 boot partition. On a virgin Raspbian image you will find a script call to init_resize.sh for first boot up in /boot/cmdline.txt. You may modify it with some knowledge of scripting but there is a script to execute on first boot. You can find it also on github at pi-boot-script.

Ingo
  • 42,107
  • 20
  • 85
  • 197