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?

  • 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, 2020 at 15:30
  • my main system is a windows device. I guess that says it all 😂
    – rdmueller
    Feb 22, 2020 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, 2020 at 1: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, 2020 at 12:42

1 Answer 1


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.

  • than - this is the answer I was searching for!
    – rdmueller
    Feb 23, 2020 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.