Install Raspbian OS on a Raspberry Pi

From Embedded Lab Vienna for IoT & Security
Jump to: navigation, search

Summary

Install Raspbian OS on a Raspberry Pi using a 16 GB SD card and Ubuntu

Requirements

  • PC with SD card reader
  • Operating system: Ubuntu 18.04 bionic amd64


Description

Check device id

Insert the SD card in the SD card reader and determine the devices on the machine by issuing following command in a terminal

   lsblk
   NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
   sda           8:0    0   477G  0 disk 
   ├─sda1        8:1    0   953M  0 part 
   ├─.....
   mmcblk0     179:0    0  14,6G  0 disk 
   └─mmcblk0p1 179:1    0  14,6G  0 part 

SD card is device mmcblk0 which contains a partition mmcblk0p1, in the case this partition is autmatically mountet unmount the partition with

   umount /media/<username>/<dev-id>

Download image

Download newest raspbian desktop from https://www.raspberrypi.org/downloads/raspbian/ The current version at time of the documentation was 2019-09-26-raspbian-buster-full.zip

Unzip and install

  • Copying a zipped image to the SD card and showing the progress by using following command
   unzip -p 2019-09-26-raspbian-buster-full.zip | sudo dd of=/dev/mmcblk0 status=progress conv=fsync 
   6799950336 bytes (6,8 GB, 6,3 GiB) copied, 555 s, 12,3 MB/s
   13303808+0 records in
   13303808+0 records out
   6811549696 bytes (6,8 GB, 6,3 GiB) copied, 569,647 s, 12,0 MB/s

Verify image [optional]

This is done by copying back the image with dd from the SD card into another file and compare that file to the original image with diff.

  • The output of the first copying dd command shows the number of written blocks, so you need only to copy this number
  xxx+0 records in
 
  • then copy these xxx=13303808 blocks from the image to a new file
  sudo dd bs=4M if=/dev/mmcblk0 of=from-sd-card.img count=13303808
  • Unzipp the original image
  unzip 2019-09-26-raspbian-buster-full.zip
  
  • truncate to the other size
   sudo truncate --reference 2019-09-26-raspbian-buster-full.img from-sd-card.img
  • and compare
  diff -s 2019-09-26-raspbian-buster-full.img from-sd-card.img 
  Files 2019-09-26-raspbian-buster-full.img and from-sd-card.img are identical

Hardware

Kingston 16GB micro SD-HC class 10 Accessory Raspberry Pi 3 Model B+


References