Skip to content

Instantly share code, notes, and snippets.

@blakeNaccarato
Last active January 13, 2024 01:18
Show Gist options
  • Save blakeNaccarato/e868cb2f55ac33f59b482d4bd0128cb9 to your computer and use it in GitHub Desktop.
Save blakeNaccarato/e868cb2f55ac33f59b482d4bd0128cb9 to your computer and use it in GitHub Desktop.
Setup for a Raspberry Pi image

Setup for Raspberry Pi image 21.02.02 Base.img

The Raspberry Pi image 21.02.02 Base.img is the base image.

Version info

This image runs Raspberry Pi OS from 2021-01-11 and Linux kernel 5.4. A sudo apt update and sudo apt full-upgrade was run before imaging.

$ uname -a
Linux raspberrypi 5.4.83-v7l+ #1379 SMP Mon Dec 14 13:11:54 GMT 2020 armv7l GNU/Linux
$ /opt/vc/bin/vcgencmd version
Copyright (c) 2012 Broadcom
version 194a85abd768c7334bbadc3f1911c10a7d18ed14 (clean) (release) (start_x)

Back up this image

Plug in a flash drive. Click on the start menu, navigate to Accessories, then SD Card Copier. For Copy From Device, choose GC1S5 (/dev/mmcblk0). For Copy To Device, choose /dev/sda. Be sure to tick the box for New Partition UUIDs. Then click Start. Once that is complete, install gparted.

sudo apt install gparted

Click on the start menu, navigate to System Tools, then GParted. Select /dev/sda. Then right-click on the rootfs partition, click Resize/Move, and shrink it to the minimum possible size. Run fdisk to find out the Sector size, which will be used later as <BLOCK SIZE> in the dd command.

$ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 59.7 GiB, 64088965120 bytes, 125173760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xbdba5d04

Using gparted, format the remaining unallocated space in the same flash drive as NTFS. Unplug and replug the flash drive to trigger mounting. Note the Mount Point of the NTFS partition, which will be used later as the <MOUNT POINT> in the dd command. Right-click on the NTFS partition, then click Information, and note the First sector, which will be used later as <COUNT> in the dd command.

Finally, use dd to copy /dev/sda to <MOUNT POINT>, where <BS> is the block size found from fdisk (512), and <COUNT> is found from the first sector of the NTFS partition. This ensures that dd stops before entering the NTFS partition.

dd if=/dev/sda of=<MOUNT POINT>/pi.img bs=<BS> count=<COUNT>

Reproduce this image

Update the appearance of the desktop

Right click on the desktop and click on Desktop Preferences. Choose a solid color of #464646 for the desktop, and #E8E8E8 for the text color. Make the menu bar Large (32x32), same colors as desktop background/text. Desktop font is PibotoLt size 12. Highlight color is #808080, and the mouse cursor is Small.

Raspberry Pi Configuration

Click on the start menu, navigate to Preferences, then Raspberry Pi Configuration. Enable all interfaces in the Interfaces tab. Increase GPU Memory to 256 on the Performance tab. Choose Disable for the fan, since we will power the fan from a fixed 3.3V pin.

Choose a static IP

Uncomment in /etc/dhcpcd.conf and modify as necessary to obtain a static IP of 192.168.1.31 (31 as in 3.1, the first two digits of pi). When running multiple Raspberry Pi's, change "31" so that you get a unique IP address.

# Example static IP configuration:
interface eth0
static ip_address=192.168.1.31/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 fd51:42f8:caae:d92e::1

# Example static IP configuration:
interface wlan0
static ip_address=192.168.1.31/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 fd51:42f8:caae:d92e::1

Configure a VNC server

Use the VNC server solution by RealVNC. If no display is connected to the Raspberry Pi, use a dummy display emulator for headless operation.

sudo apt install realvnc-vnc-server realvnc-vnc-viewer

Enable GPIO shutdown

Source: https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711_bootloader_config.md

The option wake_on_gpio is set by default. Additionally, add the following lines to /boot/config.txt.

# Enable GPIO shutdown
dtoverlay=gpio-shutdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment