Quickstart
Prep: pick a supported device
Currently, the Raspberry Pi 4 B is the recommended platform for using gokrazy, but you can find other supported and upcoming platforms.
Prep: Install Go
If you don’t already have Go installed, install the latest Go version.
Prep: Install the gok CLI
Now that you have a working Go installation, install the gok command line tool (CLI):
Step 1: Insert an SD card
Run watch -d1 ls -l '/dev/disk/by-id/*' (see the permanent data section for macOS instructions)
and insert an SD card. Copy the highlighted device name:
In this example, we’ll assume the SD card is accessible as /dev/sdx.
Step 2: Create a gokrazy instance and overwrite an SD card with gokrazy
Create a directory for this gokrazy instance:
The --parent_dir can also be changed permanently by setting the
GOKRAZY_PARENT_DIR environment variable.
If you’re curious, you can run gok edit to open the generated config.json in
your editor.
To overwrite the entire SD card /dev/sdx with a build of this
gokrazy installation, use:
The following packages are included in newly created instances by default:
- github.com/gokrazy/fbstatus
- github.com/gokrazy/hello
- github.com/gokrazy/serial-busybox
The gokrazy packer builds each specified Go program
(e.g. github.com/gokrazy/hello) in a separate build directory, each with its
own go.mod file. See Working with Go modules for more
details.
This is what the above gok commands look like in action:
Click here to show the gok log output
It is safe to unplug your SD card once gok returns.
Step 3: Boot gokrazy
After booting from this SD card, your device will:
- display system status on the monitor connected via HDMI, if any
- obtain an IP address for hostname “gokrazy” via DHCP (IPv4) and SLAAC (IPv6)
- synchronize the clock using NTP
- expose a password-authenticated web interface on private IP addresses
(each instance gets its own password in theUpdate→HTTPPasswordkey of itsconfig.json, seegok edit) - supervise all installed programs (only the hello world program in this example)
To interact with your device, you can:
- Open the gokrazy web interface in your browser (easiest option)
- Attach a serial console (see below)
- Use the breakglass package to start an interactive SSH session.
gok newsets it up by default.
Congratulations! 🎉 You now have a working gokrazy installation!
Next, see the Configuration guide for details on how to use other programs.
Optional: Using the serial console
See also: Configuration → Instance Config Reference → SerialConsole
If you prefer the serial console, you can optionally connect a serial adapter to
the Raspberry Pi and remove the "SerialConsole": "disabled" line from your gokrazy
instance’s config.json to make the primary Linux console end up on the serial
console.
When pressing Enter on the serial console, gokrazy will
interactively start either:
/tmp/serial-busybox/ash(provided by the serial-busybox package)/perm/sh, if present (supplied by you, the user)