My Raspberry Pi 400 Keyboard Computer
Tagged with cinnamon, linux, raspberry pi, trim on December 7, 2023
The Raspberry Pi 400 (“Pi” for short) is a keyboard computer, much like the keyboard computers of the 1970s and 1980s. The default operating system is a Linux distribution called “Raspberry Pi OS”. I bought the complete kit from CanaKit in July 2021, while I was in the United States. It was the only computer I used for almost six months after I returned to the Philippines in 2022.
I made changes, of course. I used an external solid-state drive instead of the micro SD card that came with the Pi. After using the default desktop environment for a few days, I changed it to something else.
The Desktop Environment
The desktop environment for Raspberry Pi OS is called “PIXEL”, which is based on LXDE. The later versions use the Wayland compositor instead of the X Window System. Unfortunately, there aren’t as many tools that work with Wayland as much as X Windows. Connecting remotely can be a challenge.
I’ve installed everything I use multiple times. I always start with Raspberry Pi OS Lite, which doesn’t include any desktop environment at all. The next step is installing the Cinnamon desktop environment with sudo apt install cinnamon.
After installation is complete, one line of the /etc/lightdm/lightdm.conf file needs to be replaced:
# user-session = Session to load for users
Change to:
user-session = Cinnamon
This method will probably work for any desktop environment.
Trim Unused Blocks on an SSD
As far as I know, based on my limited experience, the fstrim command works fine on internal solid-state drives. If you run this command on an external SSD and it returns “full”, the fstrim command won’t work at all. I’ve tested this on other computers as well.
cat /sys/block/sda/device/scsi_disk/*/provisioning_mode
It needs to return “unmap”. This command will change it (use the correct device name instead of “sda” when there’s an internal drive as well):
echo unmap | tee /sys/block/sda/device/scsi_disk/*/provisioning_mode
I created a BASH script (named “unmapit.sh”), which has to be run as root:
#!/bin/bash if [ "cat /sys/block/sda/device/scsi_disk/*/provisioning_mode" != "unmap" ] ; then echo unmap | tee /sys/block/sda/device/scsi_disk/*/provisioning_mode fi
I added a cron entry (sudo crontab -e) to run it hourly because some Linux distributions change the provisioning mode to “disabled” after the fstrim command executes:
@hourly /home/username/unmapit.sh
Note that the script doesn’t change anything if “unmap” is returned. The fstrim command only runs weekly unless you change the schedule or run it manually.
Overclocking
I overclocked the CPU and GPU in the beginning, just because I could. Since I no longer do that, these instructions are only for reference purposes.
Running this in the terminal shows the clock speeds of the CPU:
lscpu
The results are 1800 maximum and 600 minimum for each of the four cores. By adding the following to the /boot/config.txt file and rebooting, you can increase the maximum to 2147 (but it will display as 2200 with lscpu):
over_voltage=6 arm_freq=2147
You can overclock the GPU as well, just below the arm_freq:
gpu_freq=750
Remote Computing
Since this domain name is hosted at Cloudflare, I created dynamic DNS entries to point to my computers. After logging in and going to my domain name, I added those records as “DNS Only”. I then went to my profile and got the API keys. Finally, I installed a GitHub script called “DDNS Cloudflare Bash Script” on both computers that updates those DNS entries.
I created cron jobs to run the scripts on each computer every five minutes. The script won’t actually do anything if the remote IP address hasn’t changed:
*/5 * * * * /home/username/update-cloudflare-dns.sh
I have two ports forwarded to my computers at the router, and I’ve assigned static LAN IP addresses to each of them (192.168.1.100 for the Pi and 192.168.1.101 for the other computer). Another script runs on the Pi every five minutes to update the firewall, which uses iptables and UFW. Again, the script won’t actually do anything if the remote IP address hasn’t changed:
#!/bin/bash HOSTNAME=sub.domain.com IPFILE=/home/username/access.txt STATIC_IP=192.168.1.101 CURRENT_IP=$(dig +short $HOSTNAME) if [ ! -f $IPFILE ]; then /usr/sbin/ufw allow from $STATIC_IP /usr/sbin/ufw allow from $CURRENT_IP echo $CURRENT_IP > $IPFILE else OLD_IP=$(cat $IPFILE) if [ "$CURRENT_IP" = "$OLD_IP" ] ; then echo IP address has not changed else /usr/sbin/ufw delete allow from $OLD_IP /usr/sbin/ufw allow from $CURRENT_IP echo $CURRENT_IP > $IPFILE echo iptables have been updated fi fi
The command, sudo ufw status, returns something like this:
Anywhere ALLOW 192.168.1.101 Anywhere ALLOW 123.123.123.123
I installed xrdp on the Pi for visual connections. With the other computer, I connect using Remmina on port 3309. I also use SSH on port 22.
I also use the Pi to backup documents:
@hourly rsync -avzh -e ssh /home/local_username/Documents/ [email protected]:/home/remote_username/Documents/ --delete
Image by Raspberry Pi. This article was rewritten on November 8, 2024.
← Previous ArticleNext Article →