Cloudia-o

A small web and ftp server I built for the Sandberg Design Department which will be maintained by Tharim Cornellisse after I leave :)

Thursday, 05.05.22

10:11, Lukas

It seems that I lost some notes. I will investigate this, because they describe how I installed Alpine Linux in the end, and actually include some important commands. It works now!

Important for now:

usr: (redacted) pwd: (redacted)

Today I am trying to get the little display working.

To start with, I am creating a user though. For this we use

# adduser [-g "<Full Name>"] <username>

I went with

(redacted)

This creates a /home folder. We need to make sure it's persistant, meaning the changes in this folder need to be saved to the SD card when we commit. We can just include the /home directory in the lbu backup for this. We do this with:

# lbu include /home
# lbu commit

We can double check if this worked by rebooting and seeing if the folder with our username still exists after rebooting. After reboot we can log directly into that user.

I also installed sudo, to be able to use it from that user account, and gave it rights with:

# apk add sudo
# NEWUSER='yourUserName'
# echo "$NEWUSER ALL=(ALL) ALL" > /etc/sudoers.d/$NEWUSER && chmod 0440 /etc/sudoers.d/$NEWUSER
# lbu commit

Lastly, we need to install git

# apk install git

From now on we will work in the (redacted) user. There are instructions at http://www.lcdwiki.com/3.5inch_RPi_Display but they don't work for alpine linux. Instead, I first install xorg and manually install endev-input, because the setup scripts try to install those with apt-get, which is ubuntu etc, while we need to use apk.

setup-xorg-base
apk add xf86-input-endev

Now we download the script:

wget http://www.lcdwiki.com/res/MHS3528/kali-linux/LCD-show.tar.gz

we put it into whatever folder we want (i made one called driver), and extract it, and make the script executable

tar -xvzf LCD-show.tar.gz
chmod -R 755 LCD-show
cd LCD-show/

Now we have to open the script with nano, and remove the last line which wants to reboot, because of course we need to save the changes we make first. Also, we need to change the shebang from bash to sh, or install bash. I chose to change it to sh. I used nano for this:

nano MHS35-show

14:33, Lukas

It didn't work. I admitted defeat. And installed Raspbian. Instructions for this are here: https://www.raspberrypi.com/documentation/computers/getting-started.html. It's very easy, and worked straight away. For now I set it to run on the HDMI port again using the guide here: https://www.waveshare.com/wiki/3.5inch_RPiLCD(A)

cd LCD-show/
 ./LCD-hdmi

afterwards we can toggle back with

 ./LCD35-show

16:26, Lukas

I started building a script that automatically will play videos from a folder over and over once it's run. I plan to run it every hour or so.

sudo apt-get install vlc

I created a directory in the Documents folder with a script file and a folder for the videos:

mkdir videoscript
cd videoscript
touch videoscript.sh
mkdir files

The script I wrote is:

#!/bin/bash

# close all instances of vlc
killall -SIGTERM vlc

# get all the video files in the folder, make into one list
MP4=$(find . -iname '*.mp4')

# run  the vlc command with repeat (L) and on shuffle (Z)
vlc -ZL --fullscreen $MP4 & 

Tuesday, 26.04.22

13:26, Lukas

I ended up biting the bullet and followed the manual install described here: https://wiki.alpinelinux.org/wiki/Create_a_Bootable_Device#Manually_copying_Alpine_files

This was actually not so bad in the end. I had to look up where syslinux was installed on my ubuntu system in step 6, but found it quite fast and replaced the right part of the command.

Now, the Pi boots Alpine Linux from the SD card, which I now have to figure out. In order to do this I have to read a bit more about the process. The instructions for this are here: https://wiki.alpinelinux.org/wiki/Raspberry_Pi

17:47, Lukas

Update: when trying to set up Alpine properly I broke the SD card. So I will have to do it all again. Be careful out there, kids.

20:27, Lukas

Giving it another try. I set up the bootable drive again. What I didn't do last time was to create a partition on the SD card that I can use to store any data. I tried a bit to do this in Alpine, but ultimately chickened out and did it in Ubuntu using a GUI. I followed this guide: https://wiki.alpinelinux.org/wiki/Alpine_local_backup#Saving_and_loading_ISO_image_customizations

Following this guide, I then created an fstab entry to mount this partition on boot, and use it for cache etc. This worked! Alpine Linux runs now, and I can edit any changes with the lbu commit command :) Root password is: (redacted)

Monday, 25.04.22

19:36, Lukas

Just got the new Pi. I will install Alpine Linux on it. Alpine Linux is a really tiny distribution of Linux without a user interface that runs entirely from memory. That means: when it boots, the OS will load into the RAM and run from there the entire time. Because it's so small, this is not a problem, it only takes around 150MB of space there. The Pi I bought has 4GB of memory.

This two major advantages. First of all, it will be much faster than running from an SD card, as is common with Raspberry Pi's. Additionally, SD cards can only be written to so many times before they break, so as the main partition for an operating system they are actually not ideal. By loading the system once into memory on boot, the read/write cycles will be reduced to a minimum. We plan to connect Tharim's old NAS or something similar to the server, which can then act as the main hard drive for everything else. That's for later.

I am following the descriptions from the Alpine Linux wiki: https://wiki.alpinelinux.org/wiki/Raspberry_Pi. I downloaded the aarch64 RBP version from their website, and will create a bootable SD card from this next. I was originally trying to work on a MacBook next to this, so I tried to use Etcher to create a bootable SD card: https://www.balena.io/etcher/

But this didn't work. I formatted the SD card to FAT and ran Etcher, but the Raspberry Pi is not recognising this. So I switched to my Linux system and reformatted the disk using Gnome Disks, Ubuntu's GUI disk app. I also downloaded the right version of Alpine Linux again, and put it on a USB stick, to be able to access it from Alpine Linux. I actually think I could have just mounted the main hard drive from within Alpine, but this seemed easier.

The thing is that (for me) it's a bit of a complicated process to create this bootable SD card and I don't understand half of the documentation. Supposedly it's simpler if you already have a version of Alpine Linux installed. WARNING: This next part describes something that didn't work.

When working with Ada last time, we created a bootable USB stick that runs Alpine Linux using an app called Ventoy. The plan is now to boot my linux machine from that USB stick, and create a bootable SD card from there. For some reason the USB stick itself doesn't work on the Raspberry Pi directly.

First I had to set up this version of Alpine Linux though. There is a command, setup-bootable, which is supposed to do everything for you directly, but I needed to install a library for this first, called syslinux, which makes the SD card bootable after copying the OS. This didn't work without going through the installation process first.

The install can be a bit clunky. One thing I found important is to start the system without the SD card, and only insert it later, otherwise the system seems to run some kind of process on it and I cannot unmount it. It also can be helpful to already

There is a quick version of the setup command, using the q flag. This saves us quite some time, especially since you always have to start over if something doesn't work out which happens a lot. In order for this to work we need to first set up an internet connection, and then start the process. Lastly we have to install the syslinux library.

$ setup-interfaces
$ setup-alpine -q
$ apk add syslinux

This is the moment where you insert the SD card.

In order to make a bootable SD card, we need two arguments: the source and the target. The target being the SD card, the source being the version of Alpine we just downloaded. In order to do this, we also probably have to find and mount the USB stick with the version of Alpine Linux on it. We will use fdisk to identify both our SD card and the USB stick with the downloaded Alpine version on it, note both devices down and then mount the source USB.

$ fdisk -l
# find your devices in the list, then replace sdXY with your device
$ mkdir /media/stick
# for me it was sdb3
$ mount /dev/sdXY /media/stick

I already unzipped the tar file we downloaded before. If you haven't do that now, if you did, just use the unzipped folder as your source, and the SD card as target. For me this was:

$ setup-bootable -v /mnt/stick/alpine/ /dev/sdc1

BUT, this didn't work. I will try again tomorrow.

Friday, 22.04.22

12:20, Lukas

Talking with Ada: She says, don't run the Pi from an SD card. Either get a USB to SATA connector with a hard drive, or run Alpine Linux

Thursday, 21.04.22

10:45, Lukas & Tharim

Today, we met for the first time. We discussed what the server will need to be able to do, and what we need to achieve it. We decided that it will mainly be a web server: both to host things like the yearbook website, as well as an etherpad instance for the department.

We also will need an external backup solution. We will need to talk to the department about that, or maybe Jan Kees.

Additionally we thought it would be cool to set up FTP access. This way the students in the department can share warez, and upload videos. Videos for what?

There will be a screen connected to the server, which students can use to play videos at all times :)

We started writing an origin story for the server (Cloudia-o) as well. more details can be found (redacted)