4 min read

Setting up Raspian Jessie on a Pi

No tags available
Table of Contents

There are a few changes to setting up Raspian Jessie on a Pi. Here’s what I do:

Burn the image

  1. Get the Raspbian image from the Raspberry Pi downloads page. I’ve been using Jessie Lite, since I don’t need the full package.
  2. 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)
  3. 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:

  1. Expand Filesystem
  2. Change User Password
  3. Internationalisation Options / Change Locale, pick en_US UTF-8
  4. Internationalisation Options / Change timezones, pick yours
  5. 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.

  1. Edit /etc/dhcpcd.conf (not /etc/network/interfaces) so the wired interface is static
  2. 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)
  3. Now would be a good time to edit /etc/hostname as well
  4. 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.

  1. sudo addgroup —gid 3009 myshare
  2. sudo adduser —uid 3000 myuser
  3. 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
  4. 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.