Install Go

If you don’t already have Go installed, install Go 1.8.

Install the gokrazy packer

go get -u github.com/gokrazy/tools/cmd/gokr-packer

Overwrite an SD card with gokrazy

Plug an SD card into your card reader and locate its device node by checking dmesg | tail. In this example, we’ll assume the SD card is accessible as /dev/sdb.

To overwrite the entire SD card /dev/sdb with a gokrazy installation running a hello world program, use:

sudo setcap CAP_SYS_ADMIN,CAP_DAC_OVERRIDE=ep $(go env GOPATH)/bin/gokr-packer
gokr-packer -overwrite=/dev/sdb github.com/gokrazy/hello

The gokr-packer command above will result in log output like this:

2017/03/01 20:59:55 packer.go:85: installing [github.com/gokrazy/hello]
2017/03/01 20:59:56 packer.go:131: partitioning /dev/sdb
2017/03/01 20:59:56 parttable.go:40: device holds 15931539456 bytes
2017/03/01 20:59:56 packer.go:139: waiting for /dev/sdb1 to appear
2017/03/01 20:59:59 packer.go:205: mkfs.ext4 /dev/sdb4
2017/03/01 20:59:59 packer.go:208: http://gokrazy:secretpw@gokrazy/

After booting from this SD card, your Raspberry Pi 3 will:

  • 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
    (the default password can be recovered from ~/.config/gokrazy/http-password.txt)
  • supervise all installed programs (only the hello world program in this example)