0

I am trying to copy a file from the boot directory for a rasbian image. I would like add this file once to the sd card and not have to run raspbian to manually add this file (preferable, write a script for raspbian to copy on startup).

I have a custom configuration file that I would like to copy over during startup, preferably into /home/pi. I put the sd card into my computer and dropped the file into the boot directory.

The issue is that the file isnt visible in /boot when I boot up the pi and ssh into it. I am putting a file named custom-configuration.txt into the /boot directory (next to wpa_supplicant and ssh files).

What am I doing wrong? Is there a better way to do this? I know I can put the file in there manually but I would like to not have to ssh in to do so, would like to just drop it onto the sd card after writing the image with etcher on osx as I have to do this many time and the configuration file will be different for each.

1

You drop the file custom-configuration.txt to the boot directory on the SD Card when it is attached to your computer. After booting the SD Card in a Raspberry Pi you should find this file with:

rpi ~$ sudo ls -l /boot/custom-configuration.txt
-rwxr-xr-x 1 root root 0 Apr 29 20:39 /boot/custom-configuration.txt

The only reason I can figure why the file custom-configuration.txt isn't present is that it isn't the same boot directory than you used on the computer.

For testing try the other way. First delete boot/custom-configuration.txt on the computer. Then boot the SD Card in the RasPi and create the file with:

rpi ~$ sudo touch /boot/custom-configuration.txt

Then look if you find it on the computer.

Update from a comment
@timmyg13 found the reason for the issue and wrote:

I just realized that I was running ssh pi@raspberrypi.local to connect but I was actually connecting to a separate raspberry pi running elsewhere on my network - so obviously the files weren't there.

  • I tried this out and I dont see it under either circumstance. All the files are exactly the same (a lot of .dtb, .dat, .elf files) but no new file I create is visible from the computer that I wrote directly from the pi nor on the pi that I wrote directly onto the sd card from my computer. – timmyg13 May 2 '19 at 11:28
  • seems like according to this jeffgeerling.com/blog/2017/… I can do it all via the SD card. I would prefer to not have to mount, etc. and just be able to drop it in the boot directory (along with the wpa_supplicant) and have a script move it over (and remove it from /boot) on startup – timmyg13 May 2 '19 at 11:34
  • 1
    Ahh - I just realized that I was running ssh pi@raspberrypi.local to connect but I was actually connecting to a separate raspberry pi running elsewhere on my network - so obviously the files weren't there. Sorry! – timmyg13 May 10 '19 at 23:26
  • @timmyg13 Thanks for feedback :-) I have added the reason to the answer. – Ingo May 11 '19 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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