# Setup notes

## Writing an OS image to the sdcard (or usb drive)

```
sudo dd bs=4M if=/path/to/os/image of=/dev/mmcblk0 status=progress
```

## Headless wifi setup

Mount the boot partition and create a file called *wpa_supplicant.conf* with the following contents:

```
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="SSID"
    scan_ssid=1
    psk="PASSWORD"
    key_mgmt=WPA-PSK
}
```

## Enable SSH prior to first boot 

Mount the boot partiton and create an empty file called *ssh:*

```
touch /path/to/boot ssh
```

## Initial setup

Use the *raspi-config* utility to set the follwing options as desired:

- Network Options > Hostname > HOSTNAME
- Localization Options > Change Locale > *en_US.UTF-8*
- Localization Options > Change Time Zone > *America/New_York*
- Localization Options > Change WLAN Country > *US*
- Interfacing Options > SSH > *Yes*
- Interfacing Options > SPI > *Yes*
- Interfacing Options > I2C > *Yes*
- Advanced Options > Overscan > No
- Advanced Options > Memory Split > 32
- Advanced Options > Screen Blanking > No

## Changing the default username (pi)

<p class="callout warning">This must be done while logged in as the root user. It cannot be done (with sudo or su) while the pi user is looged in.</p>

<p class="callout info">To enable root login, edit <i>/etc/passwd,</i> removing the 'x' after the first colon on the line that begins with <code>root:x:...</code>. Also, if attempting this over SSH, the <i>/etc/sshd.conf</i> file will need to be modified, changing the line <code>PermitRootLogin=prohibit-password</code> to <code>PermitRootLogin=yes</code>. Don't forget to revert these changes once the pi user has been renamed.</p>

```
usermod -l USERNAME pi
usermod -d /home/USERNAME -m USERNAME
groupmod -n USERNAME pi
rm /etc/sudoers.d/010_pi-nopasswd
```

## Disable WiFi Power Managment

Create the file `/etc/network/interfaces.d/wlan0` with the following contents:
```
allow-hotplug wlan0
iface wlan0 inet manual
wireless-power off
```