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.
- Created
- 2015
- Updated
- 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.
- boot Raspberry Pi
- find its IP address:
- in your router config - if using DHCP
- you can specify static IP in cmdline.txt, e.g.
ip=192.168.1.2
)
- ssh to Raspberry Pi, user
pi
, passwordraspberry
- run
$ sudo raspi-config
to change hostname, locale, etc. - shutdown
$ sudo shutdown -h now
or$ sudo systemctl poweroff
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.
- print current partition layout:
p
- delete second partition:
d
->2
- create new primary root partition:
n
->p
->2
first sector: just after boot partition last sector (see previous list)
last sector:+8G
- create new primary home partition:
n
->p
->3
first sector: just after previous one (default
)
last sector:default
- write changes:
w
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=192.168.1.2
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=192.168.1.2/24
static routers=192.168.1.1
static domain_name_servers=8.8.8.8 8.8.4.4
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