Start overhauling docs for ubuntu

This commit is contained in:
KemoNine 2020-08-03 01:05:29 +00:00
parent 06d0362b3a
commit ebe4eae7e4
10 changed files with 95 additions and 269 deletions

View file

@ -12,12 +12,9 @@ This folder contains a bunch of general information on how to get the base of a
Items marked ```REQUIRED``` are assumed to be setup and working. You've been warned. Items marked ```REQUIRED``` are assumed to be setup and working. You've been warned.
* [Base Firmware (REQUIRED)](base.md) * [Base Firmware (REQUIRED)](base.md)
* [Finalize Arch Setup (REQUIRED)](finalize_setup.md) * [Finalize Setup (REQUIRED)](finalize_setup.md)
* [Setup swap (REQUIRED)](swap.md) * [Setup swap (REQUIRED)](swap.md)
* [journald Tweaks (make it less chatty and resource hungry)](journald.md)
* [Standard Raspberry Pi Toolchain Setup (REQUIRED)](rpi_tools.md)
* [CPU Governor](cpu_governor.md) * [CPU Governor](cpu_governor.md)
* [AUR Package Manager (REQUIRED)](aur_package_manager.md)
* [Slideshow Prep (REQUIRED)](slideshow_prep.md) * [Slideshow Prep (REQUIRED)](slideshow_prep.md)
* [Slideshow Setup (REQUIRED)](slideshow.md) * [Slideshow Setup (REQUIRED)](slideshow.md)
* [Email Notifications (REQUIRED)](email_notifications.md) * [Email Notifications (REQUIRED)](email_notifications.md)

View file

@ -1,26 +0,0 @@
# AUR Package Manager
This project uses some packages from the Arch Linux AUR repos. As such, we are going to setup a package manager for those packages. Pacman doesn't support the AUR repos natively and this is the most accessible approach for installing AUR packages.
The commands below will setup the ```yay``` AUR package manager.
``` sh
pacman -S --needed base-devel go
useradd yay -s /usr/bin/nologin
mkdir /home/yay
chown yay: -R /home/yay
git clone https://aur.archlinux.org/yay.git /opt/yay
chown yay: -R /opt/yay/
cd /opt/yay
cat > /etc/sudoers.d/yay <<EOF
yay ALL=(ALL) NOPASSWD: ALL
EOF
chmod 600 /etc/sudoers.d/yay
sudo -sHu yay makepkg -si
cat >> ~/.bashrc <<EOF
alias yay="/usr/bin/sudo -sHu yay /usr/bin/yay"
EOF
source ~/.bashrc
```

View file

@ -1,118 +1,7 @@
# Base Firmware Setup # Base Firmware Setup
The ```PiFrame``` uses Arch Linux at its core. This document will outline a way to setup a micro sd card with Arch Linux. The ```PiFrame``` uses Ubuntu Linux at its core.
# Please Note There are a lot of documents online on how to flash Ubuntu to an sd card for the Raspberry Pi 4.
We assume you're going to use the Raspberry Pi itself for setting up an Arch Linux environment. In order to do this properly and safely, you'll need 2 micro sd cards and a USB to micro sd card adapter. **Please Note: You'll want the most recent LTS 64bit server version of Ubuntu for your PiFrame**
# Setup an Ubuntu SD Card
The first step is to setup a basic Ubuntu boot environment for the Raspberry Pi, we will use this to boot strap (initialize) the Arch Linux micro sd card. This Ubuntu micro sd card can also be used to recover a broken Arch Linux system if necessary.
1. Download Ubuntu from their main [download site](https://ubuntu.com/download/raspberry-pi/thank-you?version=20.04&architecture=arm64+raspi) and flash it to the sd card. There are a lot of guides on how to do this online.
1. Boot the Ubuntu installation
1. Check the ip address with ```ip addr`` and ssh into the environment if desired. This step can be skipped if you have a keyboard/monitor setup.
1. Login to the Ubuntu envrionment
1. Open a terminal
1. Run ```sudo -sHu root``` to elevate your privileges
# Prep / install arch linux on micro sd card
## Inspiration and Further Reading
- [https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4#installation](https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4#installation)
- [https://github.com/phortx/Raspberry-Pi-Setup-Guide](https://github.com/phortx/Raspberry-Pi-Setup-Guide)
## Arch Linux Disk Setup
Run the following commands to prep the Arch Linux micro sd card. Please note the device nodes like ```/dev/sda``` may be different depending on the usb adapter used.
``` sh
parted /dev/sda
mklabel msdos
mkpart
p
[enter]
1
100M
mkpart
p
[enter]
100M
-1
set 1 boot on
set 1 lba on
q
mkfs.fat /dev/sda1
mkfs.btrfs /dev/sda2
```
## Arch Linux Bootstrap
Run the following commands to bootstrap (initialize) a fundamental Arch Linux installation.
``` sh
mkdir /mnt/arch
mount -o nodiratime,noatime,compress /dev/sda2 /mnt/arch
mkdir /mnt/arch/boot
mount /dev/sda1 /mnt/arch/boot
cd /mnt/arch
wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-4-latest.tar.gz
tar -xpf ArchLinuxARM-rpi-4-latest.tar.gz
rm ArchLinuxARM-rpi-4-latest.tar.gz
```
## Tweak Bootstrapped System
The following commands will tweak the base Arch Linux distro to facilitate the needs of a photo frame as well as tune some of the debugging that's present in the default setup.
``` sh
cat > /mnt/arch/boot/config.txt <<EOF
# KmN: Borrowed some stuff from majaro
# See /boot/overlays/README for all available options
gpu_mem=512
dtoverlay=miniuart-bt
initramfs initramfs-linux.img followkernel
disable_overscan=1
#enable vc4
dtoverlay=vc4-fkms-v3d
max_framebuffers=1
# Make sure hdmi low power mode is set for when the feature is implemented on the Pi4
hdmi_blanking=1
# you may need to add hdmi settings specific to your lcd display panel
# for example, the below settings are for a 2560x1600 50Hz panel
# see https://www.raspberrypi.org/documentation/configuration/config-txt/video.md
# for additional details
#hdmi_cvt=2560 1600 50 5 0 0 1
#hdmi_group=2
#hdmi_mode=88
EOF
nano -w /mnt/arch/boot/cmdline.txt
root=/dev/mmcblk0p2 rootflags=nodiratime,noatime,compress rw rootwait
remove kgdboc=ttyAMA0,115200
parted /dev/sda
set 1 boot on
set 1 lba on
set 2 lba on
q
```
## Boot Arch Linux
That should do it for the bootstrapping process. You can now shutdown the Ubuntu environment via ```systemctl poweroff```, swap the micro sd cards and boot into the Arch Linux environment.
You should not need the Ubuntu micro sd card at this point unless you need to recover or fix a broken Arch Linux installation.

View file

@ -4,8 +4,12 @@ The below commands setup a CPU governor. This is to help reduce power consumptio
``` sh ``` sh
pacman -S cpupower sudo -sHu root /bin/bash
sed -i "s/#governor='ondemand'/governor='powersave'/g" /etc/default/cpupower apt install cpufrequtils
systemctl enable --now cpupower cat > /etc/default/cpufrequtils <<EOF
ENABLE="true"
GOVERNOR="ondemand"
EOF
systemctl restart cpufrequtils
``` ```

View file

@ -1,57 +1,51 @@
# Arch Linux Finalization # Setup Finalization
By default Arch Linux has very little software installed and even less configuration complete. The following will walk through finalizing setup of the base environment.
The following commands will finalize the fundamental Arch Linux setup and perform some mild tuning.
``` sh ``` sh
# login as root with password root # Wait for cloud initi to spew to LCD (this will take a minute, it's prepping the initial config and deploying it, including the default user account)
# Initialize pacman # Login as ubuntu / ubuntu and follow the prompts
pacman-key --init
pacman-key --populate archlinuxarm
# Update system to latest software sudo -sHu root /bin/bash
pacman -Syy
pacman -Su # Disable cloud-init as it's unnecessary for the purposes of this project
# Install btrfs-progs touch /etc/cloud/cloud-init.disabled
pacman -S btrfs-progs
# Reboot
systemctl reboot systemctl reboot
# Remove arch linux on arm default user # Login
userdel -r alarm
# Set root password sudo -sHu root /bin/bash
passwd
# Turn on colorized pacman output # Cleanup timezone
sed -i 's/#Color/Color/' /etc/pacman.conf # Add color to pacman dpkg-reconfigure tzdata
# Install fundamental tools # Full system update
pacman -S openssh tmux nano vim htop iotop nload python python-pip wget curl git bash-completion p7zip exfat-utils man-db man-pages btrfs-progs sudo apt update && apt upgrade
systemctl reboot
# Tweak sshd to allow root login # Login
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
systemctl enable --now sshd
systemctl restart sshd
# Finalize localiztation settings sudo -sHu root /bin/bash
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
timedatectl set-local-rtc 0 # Useful packages
timedatectl set-ntp true apt install build-essential cmake nano tmux vim htop iotop nload git
echo LANG=en_US.UTF-8 > /etc/locale.conf
sed -i "s/#en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen # Raspberry Pi tools
locale-gen apt install linux-tools-raspi
mkdir /opt/raspberry-pi
cd /opt/raspberry-pi
git clone https://github.com/raspberrypi/userland.git
cd userland
./buildme --aarch64
cat > /etc/profile.d/rpi-tools.sh <<EOF
#!/bin/bash
export PATH="$PATH:/opt/vc/bin/"
EOF
# Finalize basic network config # Finalize basic network config
nano -w /etc/hostname hostnamectl set-hostname piframe
nano -w /etc/hosts
# Turn off kernel audit logging
nano -w /boot/cmdline.txt
add audit=0 at end of cmdline
# Reboot system for all changes to take effect # Reboot system for all changes to take effect
systemctl reboot systemctl reboot

View file

@ -1,28 +0,0 @@
# journald
The below commands will adjust some ```journald``` settings so it is less chatty and uses fewer resources.
``` sh
mkdir /etc/systemd/journald.conf.d/
cat > /etc/systemd/journald.conf.d/00-wall.conf <<EOF
[Journal]
ForwardToWall=no
EOF
cat > /etc/systemd/journald.conf.d/00-journal-size.conf <<EOF
[Journal]
SystemMaxUse=256M
EOF
cat > /etc/systemd/journald.conf.d/00-audit.conf <<EOF
[Journal]
Audit=no
EOF
cat > /etc/systemd/journald.conf.d/00-console.conf <<EOF
[Journal]
ForwardToConsole=no
TTYPath=
EOF
systemctl mask systemd-journald-audit.socket
systemctl restart systemd-journald
```

View file

@ -1,16 +0,0 @@
# Raspberry Pi Standard Tools Setup
The below commands will setup and expose the standard Raspberry Pi tools from ```raspbian```. Some of these tools are necessary for additional features like HDMI display on/off support.
``` sh
# Standard tools included by arch linux on arm
sed -i "s/appendpath '\/usr\/bin'/appendpath '\/usr\/bin'\nappendpath '\/opt\/vc\/bin'/g" /etc/profile
source /etc/profile
# raspi-config that's commonly used by tutorials and guides online
pacman -S libnewt
wget https://raw.github.com/chattama/raspi-config-archlinux/archlinux/raspi-config -O /usr/local/bin/raspi-config
chmod a+x /usr/local/bin/raspi-config
```

View file

@ -1,46 +1,53 @@
# Slideshow # Slideshow
The below commands will setup ```feh``` as a slideshow on your display. The below commands will setup ```fim``` as a slideshow on your display.
## Important Notes ## Important Notes
* ```feh``` will crash if there are no photos for it to use as a slideshow * ```fim``` will crash if there are no photos for it to use as a slideshow
* You will likely want to tweak the ```feh``` command invocation below. These are great settings as a starting point but you'll probably want to make adjustments for your use case. * You will likely want to tweak the ```fim``` command invocation below. These are great settings as a starting point but you'll probably want to make adjustments for your use case.
* This setup uses ```incron``` to restart ```feh``` when photos are deleted from the pictures folder. Without this piece ```feh``` will crash if a picture is removed from the pictures directory prior to ```feh``` rescaning the pictures directory. * This setup uses ```incron``` to restart ```fim``` when photos are deleted from the pictures folder. Without this piece ```fim``` will crash if a picture is removed from the pictures directory prior to ```fim``` rescaning the pictures directory.
* We default to ```DejaVuSansMono``` as the font for display of EXIF data and filename. This is an open font and looks great on most displays. Any ```fontconfig``` font can be used in its place. Adjust according to your preferences.
## Setup ## Setup
``` sh ``` sh
pacman -S feh imagemagick ttf-dejavu useradd -m -G video -s /usr/sbin/nologin fim
# reload 86400 is to refresh the list of images daily -- tune for preferred number of seconds apt install acl
# slideshow-delay is number of seconds (as a float) between images ; tune accordingly setfacl -m "u:fim:rX" /tank/pictures
useradd -s /usr/bin/nologin -m feh setfacl -dm "u:fim:rX" /tank/pictures
chmod a+rx /tank/pictures apt install fim imagemagick ttf-dejavu
pacman -S acl cat > /home/fim/.fimrc <<EOF
setfacl -m "u:feh:rX" /tank/pictures _display_status_fmt="%N %?EXIF_DateTimeOriginal?[%:EXIF_DateTimeOriginal:]?";
setfacl -dm "u:feh:rX" /tank/pictures _info_fmt_str="";
pacman -S incron EOF
cat > /usr/local/bin/fim-slideshow.sh <<EOF
#!/bin/bash
/usr/bin/fim -a --cd-and-readdir --slideshow 300 -d /dev/fb0 -T 1 -u -r --no-history --no-commandline /tank/pictures
EOF
chmod a+x /usr/local/bin/fim-slideshow.sh
cat > /etc/systemd/system/fim.service <<EOF
[Unit]
Description=fim slideshow
After=network.target
[Service]
User=fim
PrivateTmp=true
ExecStart=/usr/local/bin/fim-slideshow.sh
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl stop getty@tty1
systemctl disable getty@tty1
systemctl enable --now fim
apt install incron
cat > /etc/incron.d/feh <<EOF cat > /etc/incron.d/feh <<EOF
/tank/pictures IN_DELETE systemctl restart greetd /tank/pictures IN_DELETE systemctl restart fim
EOF EOF
systemctl enable --now incrond systemctl enable --now incrond
cat > /usr/local/bin/feh-slideshow.sh <<EOF systemctl restart incrond
#!/bin/bash
/usr/bin/feh --auto-zoom --borderless --fullscreen --hide-pointer --image-bg black --randomize --recursive \
--slideshow-delay 300 --reload 86400 \
--draw-tinted --draw-exif --draw-filename \
--fontpath /usr/share/fonts/TTF/ --font DejaVuSansMono/10 \
--verbose \
/tank/pictures
EOF
chmod a+x /usr/local/bin/feh-slideshow.sh
cat >> /etc/greetd/config.toml <<EOF
[initial_session]
command = "/usr/bin/cage /usr/local/bin/feh-slideshow.sh"
user = "feh"
EOF
systemctl restart greetd
``` ```

View file

@ -4,13 +4,18 @@ The below commands will prep the system for storing photos as well as install fu
``` sh ``` sh
# prep storage for pics sudo -sHu root /bin/bash
btrfs subvolume create /tank
# Filesystem for pictures
apt install btrfs-progs
parted /dev/sda
mkfs.btrfs /dev/sda1
mkdir /tank
cat >> /etc/fstab <<EOF
/dev/sda1 /tank btrfs defaults,noatime,nodiratime,compress,ssd 0 1
EOF
mount /tank
btrfs subvolume create /tank/pictures btrfs subvolume create /tank/pictures
# load pictures via rclone/syncthing/scp/etc (semi-optional) # load pictures via rclone/syncthing/scp/etc (semi-optional)
# basic window manager stuffs for making feh work properly
yay -S greetd cage xorg-server-xwayland
systemctl enable --now greetd
``` ```

View file

@ -4,13 +4,13 @@ The below commands will setup 1Gb of swap space as a file on the root filesystem
``` sh ``` sh
sudo -sHu root /bin/bash
mkdir /swap mkdir /swap
chattr +C /swap chattr +C /swap
fallocate -l 1024M /swap/swap.1 fallocate -l 1024M /swap/swap.1
chmod 600 /swap/swap.1 chmod 600 /swap/swap.1
mkswap /swap/swap.1 mkswap /swap/swap.1
swapon /swap/swap.1 echo 'vm.swappiness=1' > /etc/sysctl.d/99-swap.conf
echo 'vm.swappiness=1' > /etc/sysctl.d/99-sysctl.conf
echo "/swap/swap.1 none swap defaults 0 0" >> /etc/fstab echo "/swap/swap.1 none swap defaults 0 0" >> /etc/fstab
swapon -a swapon -a