Code Monkey home page Code Monkey logo

raspi-hacks's Introduction

Raspberry Pi hacks

This repository contains proof of concept code for performing first-boot initialisation on a Raspbian system without requiring access to the ext4 partition.

A working Raspbian system is required for bootstrap purposes.

Legal

This software (such that it is) is under the ISC licence; see the file raspi-hacks.sh for details. Note, however, that busybox (which is a dependency of this script) is licenced under the GNU General Public License version 2.

Acknowledgements

A sideways look at Bytemark's pi-init2 was taken to see how other people solve this problem.

Quick Setup

Mount the vfat partition of the Raspberry Pi that you wish to perform the first-boot setup on.

On the running Raspbian system from which you are bootstrapping, install busybox-static and copy /bin/busybox to the root of the vfat partition that was just mounted.

Copy the script raspi-hacks.sh from this repository to the root of the vfat partition.

Make a copy of cmdline.txt in the vfat partition called cmdline.txt.new. Modify the parameters in the original cmdline.txt file which look like this:

root=/dev/mmcblk0p2 rootfstype=ext4

to something like this:

root=/dev/mmcblk0p1 rootfstype=vfat rootflags=umask=000 init=/raspi-hacks.sh

(This makes the assumption that the parition layout of your SD card is the default Raspbian layout, i.e. that the vfat boot partition is the first on disk, and the ext4 root partition is the second.)

Put the SD card into a Raspberry Pi and boot it up. With a bit of good luck, it should boot, write the string "Hello, World!" to a file called /hello on the root filesystem, and then reboot into the normal Raspbian system.

Details

The statically linked version of busybox is used (in the intended "swiss-army knife" manner) to provided the commands needed to run raspi-hacks.sh in an environment where standard Unix utilities aren't available. This shell script mounts the root filesystem, performs initialisation tasks, modifies boot configuration and then reboots.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.