BBUK
Posts: 142
Joined: Tue Dec 18, 2012 10:34 am

Headless and networkless configuration

Sun Apr 27, 2014 2:22 pm

Dear all.

I was developing a tool that I wanted to be deployable by a user headless and without resorting to the command line. In the end, the tool did not work as well has I hoped but, what did work quite well was the deployment solution.

All it does is use an initrd to configure either Arch or Raspbian to autorun a /boot/setup.sh script on boot. The script can be anything you want.

From the user's perspective all that needs to be done is:

(a) drop the initrd.img file and a setup.sh into the Windows-visible FAT partition (eg after burning one of the standard Arch or Raspbian images - not NOOBS)

(b) add a line at the end of config.txt (eg using a Windows text editor) saying:

Code: Select all

initramfs initrd.img followkernel
(c) plug the SD card into a Pi and power up.

As an example, here is a setup.sh that resizes the root partition to fill the SD card and configures wifi (change the variables at the start of the script to suit).

http://www.mediafire.com/view/g8jrsk576b7w6rn/setup.sh

If any of you want to use this, bear in mind:

(i) the initrd init script comments out the initramfs line in config.txt (so it only runs once)
(ii) your setup.sh should have a means of ensuring that once it is done it will not be run on every reboot - see the reset_autostart function in the sample setup.sh.
(iii) the thing is set up such that setup.sh logs to /boot/log.txt

Here is the initrd file

http://www.mediafire.com/download/3046r ... initrd.img

If any of you are interested, I created the initrd with Arch's mkinitcpio tool - makes things very easy indeed. Here is the script I used to create the initrd.

http://www.mediafire.com/view/6c51bav78 ... einitrd.sh

Have fun

User avatar
procount
Posts: 2209
Joined: Thu Jun 27, 2013 12:32 pm
Location: UK

Re: Headless and networkless configuration

Sun Apr 27, 2014 9:48 pm

You could even use this technique with noobs.
Use my noobsconfig to deploy the initrd.img and setup.sh script to the Raspbian FAT/boot partition during its installation from noobs.
See https://github.com/procount/noobsconfig/
PINN - NOOBS with the extras... https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=142574

aigars.kadikis
Posts: 1
Joined: Sun May 20, 2018 1:15 pm

Re: Headless and networkless configuration

Sun May 20, 2018 5:26 pm

BBUK wrote:
Sun Apr 27, 2014 2:22 pm
Dear all.

I was developing a tool that I wanted to be deployable by a user headless and without resorting to the command line. In the end, the tool did not work as well has I hoped but, what did work quite well was the deployment solution.

All it does is use an initrd to configure either Arch or Raspbian to autorun a /boot/setup.sh script on boot. The script can be anything you want.

From the user's perspective all that needs to be done is:

(a) drop the initrd.img file and a setup.sh into the Windows-visible FAT partition (eg after burning one of the standard Arch or Raspbian images - not NOOBS)

(b) add a line at the end of config.txt (eg using a Windows text editor) saying:

Code: Select all

initramfs initrd.img followkernel
(c) plug the SD card into a Pi and power up.

As an example, here is a setup.sh that resizes the root partition to fill the SD card and configures wifi (change the variables at the start of the script to suit).

http://www.mediafire.com/view/g8jrsk576b7w6rn/setup.sh

If any of you want to use this, bear in mind:

(i) the initrd init script comments out the initramfs line in config.txt (so it only runs once)
(ii) your setup.sh should have a means of ensuring that once it is done it will not be run on every reboot - see the reset_autostart function in the sample setup.sh.
(iii) the thing is set up such that setup.sh logs to /boot/log.txt

Here is the initrd file

http://www.mediafire.com/download/3046r ... initrd.img

If any of you are interested, I created the initrd with Arch's mkinitcpio tool - makes things very easy indeed. Here is the script I used to create the initrd.

http://www.mediafire.com/view/6c51bav78 ... einitrd.sh

Have fun
This solution works brilliantly on Raspbian Wheezy. It really allows to execute 'sudo apt-get update -y && sudo apt-get upgrade -y && sudo reboot' in 'setup.sh'. Is there any way to get custom '/boot/initrd.img' with '/boot/setup.sh' support on Raspbain Stretch?

Best regards,
Aigars

Return to “Advanced users”