The blog post contains notes about the installation of piCore Linux on Raspberry Pi 3 computer. The related topic is well known, discussed by many similar posts however the article represents my own copy & paste reference for later usage.
The first generation of Raspberry Pi 1 has been with us since February 2012. Recently in version 3B, the Pi3 is equipped with 1.2 GHz 64-bit quad-core ARM Cortex-A53 processor, 1 GB of RAM and it has integrated 2.4 GHz WiFi 802.11n (150 Mbit/s), Bluetooth 4.1 (24 Mbit/s) on Broadcom BCM43438 chip. It also provides the integrated 10/100 Ethernet port. These factors along with the cheap price (~ 35 US), small size (~ 85.60mm x 56mm x 21mm), low weight (~ 45g) and low power consumption (maximum 1.34 A or 6.7 W under stress when peripherals and WiFi are connected) makes this single-board computer ideal candidate for use in the recent Internet of Things (IoT) world.
Raspberry Pi can run several OSs built for ARM architecture such as Windows 10 IoT Core, Raspbian (based on Debian), Ubuntu Mate and many others. The Linux distributions offer either full desktop environment or they are released as lite distributions, without GUI. Personally, I use piCore Linux that is the lightweight ARM clone of Tinycore Linux. The Core Linux is unique because it runs entirely in RAM. It touches the SD card only when some action is needed, for instance a new extension is being installed. It helps to extend of the lifetime of SD card which is a flash memory with limited write cycles (~ 100,000).
I do believe that the RAM size 1024MB included in Pi 2 and 3 models is capable to accommodate all installed piCore extensions for a typical IoT device. You can just boot piCore from SD card and remove the card afterwards. In this scenario, the system cannot be destroyed by hackers or they cannot install backdoors in to device as there is not storage medium inserted in the device. However either electricity must be secured to avoid of piCore reboot or the SD card must be presented in case of reboot. On the other side, digital evidences might by destroyed easily just switching off the Raspberry box.
The steps below discuss deployment Linux piCore on SD card.
1. Downloading piCore for Raspberry Pi3 and Copy Image to SD Card
We will download the latest piCore 9.0.3 and save it to x86-64 Ubuntu
$ wget http://distro.ibiblio.org/tinycorelinux/9.x/armv7/releases/RPi/piCore-9.0.3.zip
$ unzip RPi/piCore-9.0.3.zip
Be sure that SD card is not mounted. If yes, umount the card.
$ sudo umount /dev/mmcblk0
Copy the extracted piCore image to SD card.
$ sudo dd bs=4M if=piCore-9.0.3.img of=/dev/mmcblk0 status=progress conv=fsync
Remove SD card from Ubuntu and insert it to Raspberry Pi.
2. SD Card Partitioning
We will done SD partitioning on piCore Linux. This process ensures that all capacity of SD card will be used for the second partition.
$ sudo fdisk -u /dev/mmcblk0
List the available partitions. Press 'p'
Picture 1 - SD Card Before Resizing Partition mmcblk0p2
Device /dev/mmcblk0p2 is a Linux ext4 partition which contains preinstalled extensions, openssh and mc (Midnight Commander) and configuration files. It is a small partition with no free space so we must expand its size to have enough room for additional extensions, updates and backups.
Starting sector for the partition /dev/mmcblk0p2 is 77824 and ending sector is 100351. The size of the second partition is 11 MB. To delete the second partition press 'd' and type '2'. Write changes with 'w'. Afterwards run fdisk again.
$ sudo fdisk -u /dev/mmcblk0
- Create a new partition with 'n'
- Press 'p' for primary and '2' for the second partition
- Enter the first sector - 77824
- Press Enter for the default end sector
- Save changes with 'w'
Now insert SD to Raspberry Pi and expand a file system to the new partition boundaries typing the command below as root:
$ sudo resize2fs /dev/mmcblk0p2
Note: the default user is tc with the password piCore.
Picture 2 - SD Card After Resizing Partition mmcblk0p2
As you can see, the size of the partition /dev/mmcblk0p2 has been extended to 3.7 GB. It corresponds with the overall capacity 4 GB of SD card. Now, shutdown piCore, remove SD card and make copy of the card with dd command on Ubuntu.
$ sudo dd bs=4M if=/dev/mmcblk0 of=piCore-9.0.3-clean.img status=progress conv=fsync
Our piCore is ready for installation additional extensions. They will be stored on the partition mmcblk0p2.