1

Hope this is the correct forum.

I'm new to Raspberry Pi and programming.

I have been trying to get my script running at startup without any success, until I found an answer on stack overflow.

https://stackoverflow.com/questions/30507243/start-shell-script-on-raspberry-pi-startup

I wrote the code into /etc/rc.local which got the script to run at startup. The script keep on running. I have had the SD card into my PC where i added init=/bin/sh, to cmdline.txt which gives me an command line when starting up my Raspberry. When I write sudo nano /etc/rc.local I can open the file, delete the code from earlier, but I can't save the file.

Any good advice on how to fix this problem so my script ain't running at boot-up in my terminal anymore?
Thanks.

  • Does it give you an error when you try to save it? If so, what? – Mark Wagoner Dec 14 '15 at 12:28
  • @MarkWagoner it says "Error writing /etc/rc.local: Read-only file system" – ThomasD Dec 14 '15 at 12:32
2

The only reason I can think of for not being able to save the file is that the file system has been mounted read only as it is corrupt.

You need a PC with a SD card reader.

That PC must be another Linux machine or booted from a live Linux CD.

That would allow you to check and fix the SD card file system.

  • Could the problem be that i was logged in as pi when i made the add to the file in the graphical mode? And now I am not logged in while it stops it all before login? – ThomasD Dec 14 '15 at 12:33
  • 1
    No, the comment you added confirms the file system has been mounted read only. I.e. it has faults. – joan Dec 14 '15 at 12:42
  • Okay, might take a copy of my script and make a new image mount then. I have got it up running again. – ThomasD Dec 14 '15 at 13:02
2

I installed the program Paragon extfs on my PC.
I could then open the rc.local file and delete the code. I opened the cmdline.txt and deleted the init=/bin/sh
The Raspberry Pi is now starting up normally again.

Thanks

  • Just out of curiosity, is Paragon extfs free ? – dhruvvyas90 Dec 14 '15 at 15:51
  • @dastaan yes it is free for personal use. – ThomasD Dec 14 '15 at 16:10
  • Can I wave the flag for ext2fsd a free for all users, not just personal one, (as it is a GPLed) driver that I've used for several years without incident. (For both a ext3 partition and a small ext2 filesystem mounted as a Ramdrive). – SlySven Dec 14 '15 at 20:09
0

One much, MUCH easier way to run a script at start up than what you're trying to do is to put it in the crontab.

You can edit your crontab with "crontab -e" And add at the bottom the line:

@reboot <full path of script>

This will run the script as soon as it can when the pi boots up. (The arrows are not included)

As for your problem with being able to write to the file, the

ls -al

command will let you see the permissions of files in the directory you specified. you should run that command on /etc/rc.local and make sure your current user has read write and execute permissions.

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.