User avatar
RichardBronosky
Posts: 82
Joined: Thu Feb 14, 2013 5:38 pm
Location: Atlanta, GA, USA

[CONTRIB] Add a first-run setup script to the fat partition

Tue Feb 26, 2013 2:49 pm

Here is the elevator pitch:
Enhance Raspbian with a mechanism by which any host system used to image an SD card can add a setup script to the SD card to initiate a process on first boot.

I wanted to hold off presenting the idea until I could put some rigor behind it. But, I didn't want to develop it until I knew the community's standards. I have to start somewhere, so I made this simple github project.
https://github.com/RichardBronosky/raspbian-boot-setup

It may not be immediately obvious, but this would make life so much easier for new adopters and for people who try to help others here on these forums. Because neither Windows nor Mac OS X can mount EXT files systems, it's impossible to tell those users to add something to the SD card that will automatically do something to the system. This project adds that capability to the fat partition so that it is available to everyone.

Wouldn't it be great to be able to tell someone how to setup their wifi or install/remove packages without having to get the system up and running first?

Remember, this is an educational platform. As an instructor (or student) wouldn't you want to be able to image an SD card and get it "ready" without having to boot it and run scripts or click around a GUI?

There are tons of projects on github for starting with Raspbian to create special/single purpose computers, like a NAS (Pogo Plug replacement), web server, print server, WiFi access point, MAME console, Apple AirPlay receiver, IR blaster (WiFi to IR home theater remote), home thermostat, BarBQ grill temperature control, homebrew brew automation, etc. They could all be changed from having instructions like this to having instructions like:
After you image the SD card with Raspbian replace the `boot_script.sh` with this one
That is my dream. It is a pretty unique case because it is not a "package" that could go upstream to Debian. It does not require anything of the GPU. So, what do you think? Where do I go from here?
-- Bruno Bronosky
1x RPi 1 (B)
1x RPi 1+ (B)
2x RPi 2
11x RPi 3
4x RPi Zero W
2x RPi camera module
3x AIY Voice kits
https://github.com/RichardBronosky/pi-gen-extender
https://github.com/RichardBronosky/raspbian-boot-setup

User avatar
jojopi
Posts: 3424
Joined: Tue Oct 11, 2011 8:38 pm

Re: [CONTRIB] Add a first-run setup script to the fat partit

Tue Feb 26, 2013 3:09 pm

One of the Foundation's early images actually had a /boot/boot.rc, intended for enabling or disabling sshd from a foreign platform. I have occasionally thought that this mechanism could be useful for fixing certain other very specific configuration problems, and sometimes easier than talking a forum user though booting in single user mode, etc.

However, in general it is not that useful, and I am not sure what applications you have in mind. If the image boots okay, then the user can log in (locally or by ssh) and paste the commands there. (Just one command to download and run the rest, if necessary.) And if the image does not boot there is no guarantee that dropping some non-interactive root commands into the sequence will be able to fix it.

User avatar
RaTTuS
Posts: 10748
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: [CONTRIB] Add a first-run setup script to the fat partit

Tue Feb 26, 2013 3:27 pm

http://www.fs-driver.org/
will allow you to mount ext2/3 filesystems on windows
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

plugwash
Forum Moderator
Forum Moderator
Posts: 3738
Joined: Wed Dec 28, 2011 11:45 pm

Re: [CONTRIB] Add a first-run setup script to the fat partit

Tue Feb 26, 2013 3:58 pm

Sounds like a reasonable idea to me.

It should use it's own init script, rc.local is reserved for the sysadmins private use.

You want to think about where in the boot process to insert it and then set up the dependencies in the init script approrpiately. I'd think you'd want it after the root filesystem is mounted read/write but before the network is brought up.

Once the package is made and I think it's sane i'll include it in the rpi section of the repository. It will of course be up to those creating images whether to include it in their images.

User avatar
SN
Posts: 1014
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK
Contact: Website

Re: [CONTRIB] Add a first-run setup script to the fat partit

Tue Feb 26, 2013 5:12 pm

the obvious use for this (if you don't have another linux box or fs-driver or access to the pi console because its entirely selfcontained) is for wifi or lan ip setup
so you have your standard image and drop on a config file (or copy of /etc/network/interfaces etc) onto the FAT32 /boot and when you first boot the pi on that sd card it updates its real /etc/network/interfaces with the one from /boot
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?

User avatar
RichardBronosky
Posts: 82
Joined: Thu Feb 14, 2013 5:38 pm
Location: Atlanta, GA, USA

Re: [CONTRIB] Add a first-run setup script to the fat partit

Tue Feb 26, 2013 6:21 pm

SN wrote:the obvious use for this (if you don't have another linux box or fs-driver or access to the pi console because its entirely selfcontained) is for wifi or lan ip setup
so you have your standard image and drop on a config file (or copy of /etc/network/interfaces etc) onto the FAT32 /boot and when you first boot the pi on that sd card it updates its real /etc/network/interfaces with the one from /boot
SN,
That is exactly what I am doing here. I tried it out and it works like a charm!
https://github.com/RichardBronosky/rasp ... d94119cb35
-- Bruno Bronosky
1x RPi 1 (B)
1x RPi 1+ (B)
2x RPi 2
11x RPi 3
4x RPi Zero W
2x RPi camera module
3x AIY Voice kits
https://github.com/RichardBronosky/pi-gen-extender
https://github.com/RichardBronosky/raspbian-boot-setup

User avatar
RichardBronosky
Posts: 82
Joined: Thu Feb 14, 2013 5:38 pm
Location: Atlanta, GA, USA

Re: [CONTRIB] Add a first-run setup script to the fat partit

Tue Feb 26, 2013 6:30 pm

plugwash wrote: You want to think about where in the boot process to insert it and then set up the dependencies in the init script approrpiately. I'd think you'd want it after the root filesystem is mounted read/write but before the network is brought up.
You are dead on. I'll do it exactly as you say. This is what I was thinking with the "Alternate Implementation" where I referenced /etc/init.d/regenerate_ssh_host_keys
plugwash wrote: Once the package is made and I think it's sane i'll include it in the rpi section of the repository. It will of course be up to those creating images whether to include it in their images.
Awesome! I'd like to learn more about who creates images and how. Where might I go to learn?

Ultimately this is only valuable to the community if we can say "start with this image". If someone has to build their own image to take advantage of this, we've missed the whole point. That person isn't going to need this convenience method.
-- Bruno Bronosky
1x RPi 1 (B)
1x RPi 1+ (B)
2x RPi 2
11x RPi 3
4x RPi Zero W
2x RPi camera module
3x AIY Voice kits
https://github.com/RichardBronosky/pi-gen-extender
https://github.com/RichardBronosky/raspbian-boot-setup

User avatar
tonyhughes
Posts: 951
Joined: Wed Dec 26, 2012 3:46 am

Re: [CONTRIB] Add a first-run setup script to the fat partit

Tue Feb 26, 2013 6:42 pm

I think it is a fantastic idea. It will open up a whole lot of possibilities. I'd love to see it in the standard foundation endorsed image.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: [CONTRIB] Add a first-run setup script to the fat partit

Wed Feb 27, 2013 2:57 am

I'm with the other guys, think it's a great idea.
Could make custom distros easier to setup as well !
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

User avatar
RichardBronosky
Posts: 82
Joined: Thu Feb 14, 2013 5:38 pm
Location: Atlanta, GA, USA

Re: [CONTRIB] Add a first-run setup script to the fat partit

Fri Mar 01, 2013 8:13 am

Okay, plugwash, I've done some research on the previous boot.rc and this is where I'm at
https://github.com/RichardBronosky/raspbian-boot-setup

I have no idea how to package this, though. The install.sh doesn't really work for me because I'm doing it on a Mac with the EXT partition mounted via Fuse. It messes up the file ownership and I have to boot once to fix it then reboot.

What do you think?
-- Bruno Bronosky
1x RPi 1 (B)
1x RPi 1+ (B)
2x RPi 2
11x RPi 3
4x RPi Zero W
2x RPi camera module
3x AIY Voice kits
https://github.com/RichardBronosky/pi-gen-extender
https://github.com/RichardBronosky/raspbian-boot-setup

User avatar
RichardBronosky
Posts: 82
Joined: Thu Feb 14, 2013 5:38 pm
Location: Atlanta, GA, USA

Re: [CONTRIB] Add a first-run setup script to the fat partit

Wed Mar 06, 2013 8:30 am

I'm able to do this from a Mac or Linux (RPi with a USB SD card reader) now. Turns out I was inserting my init script into the wrong run level.

I'd like to get some feedback on this.

https://github.com/RichardBronosky/raspbian-boot-setup

Thanks!
-- Bruno Bronosky
1x RPi 1 (B)
1x RPi 1+ (B)
2x RPi 2
11x RPi 3
4x RPi Zero W
2x RPi camera module
3x AIY Voice kits
https://github.com/RichardBronosky/pi-gen-extender
https://github.com/RichardBronosky/raspbian-boot-setup

User avatar
RichardBronosky
Posts: 82
Joined: Thu Feb 14, 2013 5:38 pm
Location: Atlanta, GA, USA

Re: [CONTRIB] Add a first-run setup script to the fat partit

Wed Mar 06, 2013 8:37 am

RaTTuS wrote:http://www.fs-driver.org/
will allow you to mount ext2/3 filesystems on windows
For Mac:
https://github.com/osxfuse/osxfuse and http://sourceforge.net/projects/fuse-ext2/ work well. Though mount in read-write is "Experimental", it's worked for the small tasks I've needed it for.

What I didn't realize is that homebrew has a ext2fuse recipe. If it works on ext4, it would be easier.
-- Bruno Bronosky
1x RPi 1 (B)
1x RPi 1+ (B)
2x RPi 2
11x RPi 3
4x RPi Zero W
2x RPi camera module
3x AIY Voice kits
https://github.com/RichardBronosky/pi-gen-extender
https://github.com/RichardBronosky/raspbian-boot-setup

gjoseph
Posts: 2
Joined: Tue May 21, 2013 6:48 pm

Re: [CONTRIB] Add a first-run setup script to the fat partit

Wed Apr 08, 2015 9:03 am

Hey Richard, have you been able to make any progress on this ? I was going to your github repo a try, but have actually not been able to mount the ext partition. Am also on OSX. I installed Fuse, but I'm not sure what to do next.

gjoseph
Posts: 2
Joined: Tue May 21, 2013 6:48 pm

Re: [CONTRIB] Add a first-run setup script to the fat partit

Wed Apr 08, 2015 11:42 am

Ok, so after a bit of confusion (one needs to install the optional "MacFUSE compatibility layer", and the 0.0.7 binaries of fuse-ext2 seem to work fine, despite the source-only version on GitHub being 0.0.9), I got things working. If anyone's confused as I was, perhaps my notes will help:

Code: Select all

# install Fuse for OSX : https://osxfuse.github.io  - with optional "MacFUSE compatibility layer"
# install Fuse-Ext2: http://sourceforge.net/projects/fuse-ext2/ (get the 0.0.7 from SourceForge)

# Enable read/write for fuse-ext2:
sudo /usr/bin/sed -e 's/OPTIONS="auto_xattr,defer_permissions"/OPTIONS="auto_xattr,defer_permissions,rw+"/' -i .orig /System/Library/Filesystems/fuse-ext2.fs/fuse-ext2.util

# Mount both partitions of the Raspbian disk image:
# Open .img file, should mount “boot” automatically, but probably not the ext2 partition
open ~/Downloads/2015-02-16-raspbian-wheezy.img
# This will likely mount the "boot" partition automatically, but not the ext2 one (at least for me, it seems to be mounted as /Volumes/Untitled, but is not readable)
diskutil list # find “Linux” partition
mkdir /mnt/wheezy # this is where we'll mount the partition
diskutil unmount /mnt/wheezy/ # to be sure
# Actually mount it in /mnt/wheezy, in r/w mode:
sudo fuse-ext2 /dev/disk1s2 /mnt/wheezy  -o rw+

Return to “Raspberry Pi OS”