Raspbian Jessie Installation and Configuration

This guide covers installation and configuration of Raspbian GNU/Linux operating system on Raspberry Pi computer. Raspbian is based on Debian and their configuration is almost the same. Installation is not required because the official Raspbian is provided as finished SD card image only.

September 5, 2016

Create Bootable Raspbian SD Card

Download Raspbian here: https://www.raspberrypi.org/downloads/raspbian/ and flash it on (Micro)SD card. Instructions are on their website. On Linux you would use something like the following command.

$ unzip 2016-05-27-raspbian-jessie-lite.zip
$ sudo dd bs=4M if=2016-05-27-raspbian-jessie-lite.img of=/dev/sdb
$ sync

There's a good bloat-free alternative to the official image called raspbian-ua-netinst (https://github.com/debian-pi/raspbian-ua-netinst), which is not covered in this how-to.

UPDATE: There is official "Jessie Lite" image now.

First Boot

On the first boot we need to modify some settings. These steps are not required. Filesystem is now expanded (to fill the whole SD card) automatically on the first boot.

Format SD Card to F2FS (instead of EXT4)

Flash Friendly File System, F2FS, is faster and better for SD cards than ext4.

Insert Raspberry Pi's memory card into SD card reader on other Linux (Unix) PC (This was done on Fedora 22). To show current SD card partition scheme, run the following command (in all these commands substitute sdX with your drive location, it might be sdb, sdc, ...).

$ sudo fdisk -lu /dev/sdX

We need to backup all files from the second (root) ext4 partition.

$ cd /mnt
$ sudo mkdir rpi
$ sudo mkdir backup
$ sudo mount /dev/sdX2 rpi
$ sudo cp -a rpi/. backup
$ sudo umount rpi

We will create new partitions and copy all data back. Here I want to create a separate /home partition. Note: I am using 16 GB MicroSD card. We will do it from fdisk (MBR is used as partition format).

$ sudo fdisk /dev/sdX

While in fdisk, follow these steps.

Make sure sectors start at right boundaries (in fdisk it's automatic, first partition starts at 8192, first sector divisible by 2048). See http://3gfp.com/wp/2014/07/formatting-sd-cards-for-speed-and-lifetime/

Next we will create F2FS filesystem and copy all files back on SD card.

$ sudo mkfs.f2fs /dev/sdX2
$ sudo mkfs.f2fs /dev/sdX3
$ lsblk -f	# to see all filesystems used
$ sudo mkdir /mnt/rpi-home
$ sudo mount /dev/sdX2 /mnt/rpi
$ sudo mount /dev/sdX3 /mnt/rpi-home
$ sudo cp -a /mnt/backup/home/. /mnt/rpi-home/
$ sudo rm -r /mnt/backup/home
$ sudo cp -a /mnt/backup/. /mnt/rpi/

Modify fstab so that the new /home partition is mounted automatically. To do this, in /mnt/rpi/etc/fstab change ext4 to f2fs and add mmcblk0p3 as /home 0 2

Unmount all SD card partitions.

$ sudo umount /mnt/rpi
$ sudo umount /mnt/rpi-home

Mount RPi's /boot partition (it should be the first one), in cmdline.txt change rootfstype=f2fs.

Boot Raspberry Pi and install updates and f2fs-tools package.

$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ sudo apt-get install f2fs-tools
$ sudo rpi-upgrade

Basic Setup

Now Raspbian is installed, some other tweaks may be needed.

Set Static IP Address

IP address can be set either on kernel level or through dhcpcd. It is different from standard Debian installation.

The first option is this: add ip= in /boot/cmdline.txt

The second option: add the following text into /etc/dhcpcd.conf file. WARNING: Unlike in normal Debian installation, in official Raspbian image we shouldn't change /etc/network/interfaces and /etc/resolv.conf files.

interface eth0
static ip_address=
static routers=
static domain_name_servers=

Another option would be telling our DHCP server the IP address to assign to our Raspberry Pi.

Add Users

More information can be found on this link: https://www.raspberrypi.org/documentation/linux/usage/users.md.

$ sudo adduser david

Add new user to sudoers or to sudo group and comment out pi with NOPASSWD (to disable running sudo without a password).

$ sudo visudo

Get list of all groups pi user is in and add new user to the same groups.

$ groups pi
$ sudo usermod -a -G group1,group2 username

Disable pi user login (not required).

$ sudo passwd -l pi

VNC Server

According to https://www.raspberrypi.org/documentation/remote-access/vnc/.

$ sudo apt-get install tightvncserver
$ tightvncserver
$ vncserver :0 -geometry 1920x1080 -depth 24 -dpi 96