-
Notifications
You must be signed in to change notification settings - Fork 1
Image Build Instructions
ChickenDevs edited this page Sep 25, 2021
·
10 revisions
If you want to be able to control everything that goes into the Pi, here are the instructions to build it from scratch.
We recommend choosing the smallest SD card possible. This will help to speed up image creation.
- Download the Raspberry Pi Imager.
- Click
Choose OS
,Ubuntu
, thenUbuntu Server 20.10 (RPi 3/4/400)
(Make sure you get the 64-bit). - Plug in and choose the SD card. Click
WRITE
. - Transfer the SD Card to the Raspberry Pi and power it on. Get the IP address for the pi. Then ssh to the pi using
ssh ubuntu@ip-address
with the passwordubuntu
. - Change the hostname
- Run
sudo hostnamectl set-hostname webcast-pi
- Run
- Create the user
- Run
sudo useradd webcast -m -G sudo -s /bin/bash
- Run
sudo passwd webcast
and enter the password. We will be usingalma3738
.
- Run
- Run
sudo visudo
and change-
%sudo ALL=(ALL:ALL) ALL
to%sudo ALL=(ALL) NOPASSWD: ALL
-
- Remove the ubuntu user and home directory
- Close the ssh session, and login with the webcast username and password as set earlier.
ssh webcast@ip-address
with passwordalma3738
. - Run
sudo userdel ubuntu
- Run
sudo rm -r /home/ubuntu
- Close the ssh session, and login with the webcast username and password as set earlier.
- Update networking config
- Run
echo network: {config: disabled} | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg > /dev/null
- Run
sudo mv /etc/netplan/50-could-init.yaml /etc/netplan/50-webcast-pi.yaml
- Run
sudo vi /etc/netplan/50-webcast-pi.yaml
and edit the file to look like the following:
network: ethernets: eth0: dhcp4: true optional: true version: 2 renderer: NetworkManager
- Run
sudo netplan generate
- Run
sudo netplan apply
- Run
- Pull the code and copy it to the right places
- Run
git clone https://github.com/ChickenDevs/webcast.git
- Run
cd webcast
- Run
sh setup.sh
- Run
- Clean up the image as needed, for example:
sudo apt --purge autoremove -y
sudo apt autoclean -y
sudo rm -rf /tmp/*
- Fill the empty space with zeros to maximize compression
- Run
dd if=/dev/zero of=/tmp/zero
and wait for it to finish (might be a long time for large SD cards) - Run
rm -f /tmp/zero
- Run
- Run
history -c
- Shutdown the Pi and move the microSD card to another system for imaging.
- We use a USB adapter to another Linux system
- Run
sudo dd bs=4M if=/path/to/microSD of=/path/to/output.img
- Replace the
if=
entry with the correct reference to the microSD card - Replace the
of=
entry with the desired destination - i.e.
sudo dd bs=4M if=/dev/sde of=/data/backups/pi/webcast-pi4.img
- Replace the
- Shrink the resulting image and prepare it to for distribution
- Install PiShrink on the Linux system being used to capture the image and use it to shrink and prepare the image
- i.e.
sudo pishrink.sh -za /data/backups/pi/webcast-pi4.img
- The resulting file in the above example would be
/data/backups/pi/webcast-pi4.img.gz
which is ready for distribution