Checklist for configuring my Raspberry Pi

These instructions are very bare, and intended only for my own use.

Preparation

  1. Write the disk image to the sd card with dd, using BS=4M.

  2. Resize the second partition to ~1.5GiB, create an ext4 partition on the remaining space for media storage.

  3. Expand the root partition with e2fsck -f /dev/sdx2 and resize2fs /dev/sdx2.

  4. Add an empty file called ssh on the boot partition

  5. Start the Pi and ssh in, username pi, password raspberry.

  6. Run raspi-config, set the hostname, reboot.

  7. Get updates/upgrades.

  8. Add smsc95xx.turbo_mode=N to /boot/cmdline.txt (don’t know if still necessary).

Users

  1. Run adduser.

  2. Use usermod -a -G <comma separated groups> louis to add pi’s groups to new user.

  3. Add new user to sudoers.

  4. Verify the new user works and can sudo, then disable the pi account with passwd -l pi.

  5. Add the extra partition to fstab, on /local using defaults,noatime 0 2.

  6. Run addgroup local and adduser louis local.

  7. Run chgrp local /local, and mount it.

Network Setup

Edit /etc/network/interfaces to the following:

auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
	address 192.168.1.25
	netmask 255.255.255.0
	gateway 192.168.1.1
	wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

and /etc/wpa_supplicant/wpa_supplicant.conf to have

country=NZ
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
	ssid="{SSID HERE}"
	psk="{KEY HERE}"
}

then reboot.

Network bridge setup

  1. Add @reboot sleep 60 && /root/wifibridge.sh to root’s crontab.

  2. Create a script /root/wifibridge.sh, remembering to chmod +x it. (See source at gist.)

#!/bin/sh
/sbin/ifconfig eth0 10.0.0.1 netmask 255.255.255.0 up
/sbin/iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
echo "1" | /usr/bin/tee /proc/sys/net/ipv4/ip_forward

Transmission setup

  1. Make the /local/torrents and /local/torrents/.incomplete directories. Set their groups to local and permissions to 775.

  2. Install the transmission-daemon and transmission-cli packages.

  3. Add debian-transmission to the group local.

  4. Stop the transmission service, and make the following settings changes:

    "cache-size-mb": 32,
    "download-dir": "/local/torrents",
    "download-queue-size": 1,
    "encryption": 0,
    "incomplete-dir": "/local/torrents/.incomplete",
    "incomplete-dir-enabled": true,
    "peer-limit-global": 40,
    "peer-limit-per-torrent": 10,
    "peer-socket-tos": "lowcost",
    "port-forwarding-enabled": true,
    "preallocation": 0,
    "prefetch-enabled": 0,
    "rpc-authentication-required": false,
    "rpc-whitelist": "192.168.1.*",
    "rpc-host-whitelist-enabled": false,
    "umask": 2

Minidlna setup

  1. Install minidlna

  2. Edit /etc/minidlna.conf with the following settings:

    • media_dir=/local/torrents

    • friendly_name=Pi Torrents

  3. Restart the minidlna service, then run service minidlna force-reload.

Samba setup

  1. Install samba and create an account with smbpasswd -a <username>.

  2. Remove the default share definitions.

  3. To create one private share and one public share (think carefully about whether you want this!)

    [Home]
    	path = /home/louis
    	writable = yes
    	valid users = louis

    [PiTorrents]
    	path = /local/torrents
    	security = share
    	browseable = yes
    	writable = yes
    	guest ok = yes
    	guest account = nfsnobody
    	public = yes
    	force user = root
    	force group = root