From charlesreid1

(Created page with "===By The Way: Modifying Headless Raspberry Pi Boot Sequence=== Part of my struggles in debugging the issue above led me to the <code>rc.d</code> and <code>init.d</code> on...")
 
No edit summary
Line 1: Line 1:
===By The Way: Modifying Headless Raspberry Pi Boot Sequence===
=Modifying Raspberry Pi Boot Sequence=


Part of my struggles in debugging the issue above led me to the <code>rc.d</code> and <code>init.d</code> on the SD card, and modifying the services that start on boot on the headless Raspberry Pi.
If you want to add startup services to your Raspberry Pi (and there are many useful applications of having programs start automatically when the Pi is plugged in, as opposed to having to be started manually, [[RaspberryPi/Reverse SSH]] being one of them), you can mount the SD card on another computer and modify the <code>rc.d</code> and <code>init.d</code>, and modify the services that start on boot.


Here's how to add and modify startup services and configurations on the Pi:
First, load up the SD card and mount it. You will need to mount the filesystem partition of the SD card, which is an ext4 filesystem. If you are on a Mac, you will need to install MacFUSE to read an ext4 file system. If you are on Linux, you are good to go. (If you are on Windows... may God have mercy on your soul.)


First load up the SD card and mount it (as described at [[Kali_Raspberry_Pi/Installing#How_the_Kali_Linux_Startup_SD_Card_Works]]).
Once you've mounted the Pi's filesystem, you will want to change what starts at different runtime levels. Debian Raspberry Pis start in runtime level 2 by default, so anything you want to start up should go into <code>/etc/rc2.d</code>.


Now you can modify files in the Linux partition, to change what starts up at different runtime levels. Debian Raspberry Pis start in runtime level 2, so anything you want to start up should go in <code>etc/rc2.d</code>.
But the way you should do this is, first put a service script into <code>/etc/init.d/myservice</code>, and make it executable with <code>chmod +x /etc/init.d/myservice</code>. This script should look like other init scripts in the <code>/etc/init.d</code> folder.  


Actually, what you should do is, put a service script in <code>etc/init.d/myservice</code>, make it executable, then create a symbolic link in <code>etc/rc2.d</code>.
Now create a symbolic link in <code>/etc/rc2.d</code> with the command <code>ln -fs /etc/init.d/myservice /etc/rc2.d/</code>


More details here: http://raspberrywebserver.com/serveradmin/run-a-script-on-start-up.html
More details here: http://raspberrywebserver.com/serveradmin/run-a-script-on-start-up.html

Revision as of 02:31, 18 January 2016

Modifying Raspberry Pi Boot Sequence

If you want to add startup services to your Raspberry Pi (and there are many useful applications of having programs start automatically when the Pi is plugged in, as opposed to having to be started manually, RaspberryPi/Reverse SSH being one of them), you can mount the SD card on another computer and modify the rc.d and init.d, and modify the services that start on boot.

First, load up the SD card and mount it. You will need to mount the filesystem partition of the SD card, which is an ext4 filesystem. If you are on a Mac, you will need to install MacFUSE to read an ext4 file system. If you are on Linux, you are good to go. (If you are on Windows... may God have mercy on your soul.)

Once you've mounted the Pi's filesystem, you will want to change what starts at different runtime levels. Debian Raspberry Pis start in runtime level 2 by default, so anything you want to start up should go into /etc/rc2.d.

But the way you should do this is, first put a service script into /etc/init.d/myservice, and make it executable with chmod +x /etc/init.d/myservice. This script should look like other init scripts in the /etc/init.d folder.

Now create a symbolic link in /etc/rc2.d with the command ln -fs /etc/init.d/myservice /etc/rc2.d/

More details here: http://raspberrywebserver.com/serveradmin/run-a-script-on-start-up.html