Stop Raspberry Pi from running program at boot

user2506445 picture user2506445 · Jun 21, 2013 · Viewed 62.4k times · Source

I was trying to figure out how to run a program at boot, but after realizing this program is an infinite loop, I have no way of getting out, or back to the terminal. Right when I give the Pi power it just goes right to the program on a black background. I don't remember exactly what I did to make it run at boot, I believe I just added some code in a place right above something that said "exit 0" and below something that says "esac". I don't remember the command that even got me there. (I am new to the Pi and Python and have just been playing around..unsucessfully.)

If anyone could help me either delete this program or get me to be able to edit it so I can fix the infinite loop that would be great. I'd rather not have to completely over-write the sd card with a fresh raspbian. But like I said I can't do anything at boot, and Ctrl + C doesn't do anything nor Ctrl + Alt + Delete.

EDIT: When I put the SD card in my computer, I see a list of 11 files: bootcode cmdline config fixup fixup_cd issue kernel kernel_cutdown kernel_emergency start.elf start_cd.elf

None of these mean anything to me...

Answer

hek2mgl picture hek2mgl · Jun 21, 2013

Update: Looks like I failed to get that you want to interrupt the running bootprocess and stop the script.

The simplest idea would be to turn of the pi, unplug the sd card and plug it into your desktop, (re)move the script and boot again.


Processes spawned during boot are stored in scripts in /etc/init.d/.... These scripts are called by the init process, the first process on a Linux machine (PID:1)

But init starts not all scripts in /etc/init.d. This depends on the run level. On a debian system there are 7 run levels.

For every run level there is a folder called like:

/etc/rc0.d
...
/rc6.d

in which are softlinks to scripts from /etc/init.d are stored.

To remove a script from being executed on every boot you'll delete all links from that folders. Usually on debian systems this is done using the update-rc.d tool:

update-rc.d NAME_OF_INIT_SCRIPT remove

You should also have a look at the file /etc/rc.local