# Raspberry Pi

## Headless Alpine Installation
Flash SD card with Alpine Linux using `rpi-imager`

Mount the SD card and drop the following files on the root of the card:
- [headless.apkovl.tar.gz](https://raw.githubusercontent.com/macmpi/alpine-linux-headless-bootstrap/refs/heads/main/headless.apkovl.tar.gz)
- `wpa_supplicant.conf`

    ```
    country=CA
    
    network={
    	key_mgmt=WPA-PSK
    	ssid="<network-name>"
    	psk="<password>"
    }
    ```

Find Pi's IP:
```
nmap -sn 192.168.1.0/24
```

SSH will be enabled by default, you can login as `root` with no password.

Run the setup script to install the system:
```
setup-alpine
```

When you reach the "Disk & Install" phase use the following options:

```
 Disk & Install
----------------
No disks available. Try boot media /media/mmcblk0p1? (y/n) [n] y

Available disks are:
  mmcblk0       (32.0 GB  )

Which disk(s) would you like to use? (or '?' for help or 'none') [none] mmcblk0

The following disk is selected:
  mmcblk0       (32.0 GB  )

How would you like to use it? ('sys', 'data', 'crypt', 'lvm' or '?' for help) [?] sys

WARNING: The following disk(s) will be erased:
  mmcblk0       (32.0 GB  )

WARNING: Erase the above disk(s) and continue? (y/n) [n] y
```

## Read-only root filesystem with tmpfs overlay
Makes root filesystem read-only reducing wear on SD card. Simply add `overlaytmpfs=yes` to `/boot/cmdline.txt`:
```
sed -i 's/$/ overlaytmpfs=yes/' /boot/cmdline.txt
reboot
```

Make root writable again:
```
sed -i 's/ overlaytmpfs=yes//' /boot/cmdline.txt
reboot
```

# References
- https://wiki.alpinelinux.org/wiki/Raspberry_Pi
- https://wiki.alpinelinux.org/wiki/Installation_on_a_headless_host
- https://wiki.alpinelinux.org/wiki/OverlayFS#Immutable_root_with_tmpfs_overlay
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9