Raspberry Pi Install with Overlay Control (Ubuntu Studio)
These instructions enable a Raspberry Pi to be configured with a ramdisk overlay, thereby protecting the underlying OS memory card from corruption
They contain scripts which are designed to run on a linux host system to initialise and pre-install the memory card.
In addition to setting up the machine, they also allow for a USB device to be mounted which contains the user home directories.
The script has been tested on Ubuntu Studio 20.
INGREDIENTS
- Configuration Script
- 1 Raspberry Pi
- 1 Pi Memory Card
- 1 USB Memory Stick
METHOD
1. Configuration Script
Include Bundle Link
tar xzf pi-config-script.tar.gz
2. Preparing the USB Stick
Ensure that the USB memory stick is formatted for use on a Linux operating system, ideally with the ext2 disk format.
- Use dmesg, or lsblk to identify the device name of the USB stick.
- And then, use the fdisk to create a partition.
- And then use mkfs.ext2 to format that partition.
3. Downloading the Raspberry Pi OS
Download the latest Raspberry Pi OS Lite from:
4. Setting up your Network
# cp wpa_supplicant.conf.org wpa_supplicant.conf# vi wpa_supplicant.conf
5. Formatting and Installing
# ./install.sh 2021-01-11-raspios-buster-armhf-lite.img /dev/sda
sda 8:0 1 14.9G 0 disk
├─sda1 8:1 1 256M 0 part /media/username/boot
└─sda2 8:2 1 14.6G 0 part /media/username/rootfs
type YES to confirm you wish to use this device
yes
Confirmed use of device /dev/sda
Unmounting /dev/sda1
Unmounting /dev/sda2
Writing image to card ....
[sudo] password for user: ******
1776+0 records out
1862270976 bytes (1.9 GB, 1.7 GiB) copied, 128.924 s, 14.4 MB/s
Write complete
Waiting for device to mount. If it doesn't happen automatically
after 30 seconds, remove and reinsert the card.
Image complete, copying files
Transferring install scripts to /media/username/rootfs/home/pi
1776+0 records in
On completion, the disk can be removed and installed into the Pi
6. Booting the Pi
# ssh -l pi raspberrypi.localpassword: raspberry
7. Configuring the Pi
# install/install.sh
Reading package lists... DoneBuilding dependency treeReading state information... Doneinitramfs-tools is already the newest version (0.133+deb10u1).initramfs-tools set to manually installed.0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.update-initramfs: Generating /boot/initrd.img-5.4.83-v7l+==================================================Disabling swapfile==================================================Setting login message of the day==================================================Mounting memory stick as /usbhomeFound ext2 Device: /dev/sda1 with partuuid: 0a2d4262-af55-c643-8971-9192939a9b93No fstab entry found, adding one/usbhome disk mounted==================================================current hostname is raspberrypiEnter new hostname:
openhab
Updating /etc/hostname for new hostnameUpdating /etc/hosts for new hostnamehostname is now: openhabEnter the account username for a new adminuser user:
adminuser
Creating user adminuserEnter a password for adminuserNew password: *****Retype new password: *****passwd: password updated successfullyEnter the account username for a new mortal user:
mortaluser
Enter the full (readable) Name of the new mortal user:
M User
Creating user mortaluserNot copying any file from skel directory into it.Enter a password for mortalusersNew password: *****Retype new password: *****passwd: password updated successfullyChanging pi user password - this is important to ensure the device is secureNew password: *****Retype new password: *****passwd: password updated successfullyNOTE: It is recommended you remove the pi userNew User Addition Complete/ will be mounted RW on next bootNow reboot, and connect again with 'ssh -l adminuser openhab.local'Press ENTER to reboot
8. Reboot the Pi
# deluser -r pi
9. Install Other Software
10. Enable Overlay
# sudo overctl -r# sync# sudo reboot