There are a few changes to setting up Raspian Jessie on a Pi. Here’s what I do:
Burn the image
- Get the Raspbian image from the Raspberry Pi downloads page. I’ve been using Jessie Lite, since I don’t need the full package.
- Unzip it on a Linux box (mine saw the SD card as /dev/sdb, use your SD card device and don’t wipe your hard drive)
- Pop the card out of the Linux box and into the Pi
The command to write that I used:
sudo dd if=2015-01-31-raspbian.img of=/dev/sdb bs=4M
Configure the Pi
When the Pi boots into raspi-config, do the following:
- Expand Filesystem
- Change User Password
- Internationalisation Options / Change Locale, pick en_US UTF-8
- Internationalisation Options / Change timezones, pick yours
- Internationalisation Options / Change Keyboard Layout, pick US PC 104, accept defaults
Set up the network
I have my Pi configured with a static IP. The first time I boot I attach a network cable.
- Edit /etc/dhcpcd.conf (not /etc/network/interfaces) so the wired interface is static
- My /etc/resolv.conf was configured automatically by dhcp and was mostly right (missing domain and search, but I guess I can live with that)
- Now would be a good time to edit /etc/hostname as well
- Edit /etc/hosts to use the new hostname and hostname.domainname
(Thanks to https://pi-hole.net/faq/how-do-i-set-a-static-ip-address-in-raspbian-jessie-using-etcdhcpcd-conf/ for the revised instructions for a static IP.)
I added the following to the end of my /etc/dhcpcd.conf:
# Configure eth0 to be static
interface eth0
static ip_address=192.168.17.5
static routers=192.168.17.1
static domain_name_servers=192.168.17.1
static domain_name=mydomain.foo
Install an editor
I can do a few things like adding users while updates are happening. So:
sudo aptitude update
sudo aptitude install zile
Update the OS
This takes a while, but you can continue on while this is happening.
sudo apt-get install rpi-update
sudo aptitude dist-upgrade
Add my user
I don’t like to use the default user, so I add my own.
- sudo addgroup —gid 3009 myshare
- sudo adduser —uid 3000 myuser
- sudo usermod -a —groups adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio,myshare myuser log out, log in - make sure I can sudo with the new user
- prevent login as pi
To prevent the pi login, I do:
sudo vipw -s
and replace the password for pi with *.
Update everything else
Once the dist-upgrade has completed and it’s time to reboot:
sudo /sbin/shutdown -r now
Now you can log in again and upgrade the firmware:
sudo rpi-update
sudo /sbin/shutdown -r now
Get things I know I’ll need
I like to have an emacs clone:
zile ~/.bash_aliases
alias emacs='zile'
I also like tightvncserver on non-Lite images:
sudo aptitude install tightvncserver
tightvncserver
(set password)
Finally, make emacs the default editor by appending this to ~/.bashrc:
export EDITOR=/usr/bin/zile
Mounting a CIFS drive
I don’t like to do more writing than I have to, so:
sudo mkdir /etc/samba/credentials
sudo chmod 700 /etc/samba/credentials
sudo chown root.root /etc/samba/credentials
sudo mkdir /shared
sudo zile /etc/fstab
sudo zile /etc/samba/credentials/myserver
In /etc/fstab, I add:
//myserver/shared /shared cifs credentials=/etc/samba/credentials/myserver 0 0
While in /etc/fstab, I change the following to reduce wear on the SD card:
/dev/mmcblk0p1 /boot vfat noatime 0 0
/dev/mmcblk0p2 / ext4 defaults,noatime 0 2
{Edit} I used to have ro,noatime on /boot but the Pi gets really unhappy when you try to upgrade the OS if /boot isn’t writable. So out it came.
In /etc/samba/credentials/myserver, I add:
username=myuser
password=mypass
That’s about it.