Notes for configuring Ubuntu 20.04.1 LTS on Raspberry Pi.
I currently use a customized Ubuntu image that includes the following modifications:
On first boot you can find the Pi on the network from a DHCP server (or any other host that has an ARP cache for the subnet including this host) using the following:
#!/bin/bash echo "The following Raspberry Pi 4 devices have been found:" arp -a | grep dc:a6 # add MAC for other models...
After logging in you should reconfigure the filesystem and disable cloud-init to ensure that it does not automatically modify the filesytem or partitions in future updates.
# disable touch /etc/cloud/cloud-init.disabled # manually modify the partition table and grow the filesystem parted /dev/mmcblk0 resizepart # configure partition 2 as desired quit resize2fs /dev/mmcblk0p2 # optional: remove cloud-init completely apt-get purge cloud-init # if you do not remove cloud-init be sure not to allow your # configuration to be overwritten in future updates to the package
Another option is to create a small 1Mb partition after your root partition to ensure that it can never be grown into the empty space on your SD card.
Next do the following:
# disable the unattended upgrades service (you can re-enable later if you prefer) systemctl disable unattended-upgrades # install python for Ansible apt install python # set editor to Vim (optional) update-alternatives --config editor # set a hostname echo "$MYHOSTNAME" > /etc/hostname # don't forget to update /etc/hosts
Configure network interface for static use:
# /etc/netplan/99-static.yaml network: version: 2 renderer: networkd ethernets: eth0: addresses: - 10.1.2.3/24 gateway4: 10.1.2.1 link-local: [ ] nameservers: search: [subnet.quay.net, quay.net] addresses: - 10.1.2.53
Test netplan configuration:
netplan try # if that works, remove any other config files and run: netplay apply # once successfully tested you should also remove the default config from cloud-init # (add to Ansible playbook in future) rm -f /etc/netplan/50-cloud-init.yaml
# standard configuration for all Raspberry Pi systems # this playbook does the following: # - base configurations (raspi_ubuntu) # - time service config (chrony) # - firewall config (nftables) ansible-playbook -l raspi.in.quay.net raspi_ubuntu.yml # regenerate SSHD keys on host after build # NOTE: Ubuntu ships with a default set of SSHD keys ansible-playbook -l raspi.in.quay.net regen_sshd_keys.yml
Add the following to Ansible plays in the future:
Quick reference for Raspberry Pi hardware tools on Ubuntu.
# Install the I2C tools to access the bus and configure your RTC apt install i2c-tools # Enable your RTC in the Pi boot config RTCMODEL=ds3231 echo "dtoverlay=i2c-rtc,$RTCMODEL" >> /boot/firmware/usercfg.txt # show I2C bus config # - 68 = hardware detected # - UU = dtoverlay configured correctly and driver is loaded i2cdetect -y 1