Starting podman containers on boot with systemd

Podman is pretty cool, and I have been playing around with it a bit recently.

Podman is essentially docker but without a daemon so it runs in userspace, and is developed by RedHat so it has nice things like Ansible integration, and is the driver behind Fedora’s Toolbox, a tool for Fedora Silverblue.

The podman blog says that you can start containers by creating an entry in /etc/systemd/system for every container that you want to start with the following example for Redis

[Unit]
Description=Redis Podman container
Wants=syslog.service
[Service]
Restart=always
ExecStart=/usr/bin/podman start -a redis
ExecStop=/usr/bin/podman stop -t 10 redis
[Install]
WantedBy=multi-user.target

However, when I looked at Wireguard’s systemd service file as an example, I found a neater way to do it.

  • Create a new file /etc/systemd/system/podman@.service (the @ is the important part – be sure not to leave that out)
  • Add the following to the file:
[Unit]
Description=podman %I container

[Service]
Restart=always
ExecStart=/usr/bin/podman start -a %i
ExecStop=/usr/bin/podman stop -t 2 %i

[Install]
WantedBy=local.target
  • Stop (don’t rm) the container you want to run, and take note of its container name, eg: bitwarden_bitwarden_1
  • Start and enable the service with systemctl enable --now podman@container_name

I hope this helps someone out there 😀

The minimalist guide to digital minimalism

I was recently inspired by Matt D’Avella on YouTube to try and minimalise my digital life. This guide will teach you to be minimalist without having to use Apple products.

1. Install Ubuntu.

Click here for a guide to installing Ubuntu.

It is safe to say that Windows 10 is an incredibly messy OS, cluttered with unnecessary programs, and some of which are surprisingly difficult to remove.

Yes, there are plenty of distributions which are more minimalistic than Ubuntu, but the time you put into installing and maintaining the distribution, as well as the fact that there is far more software and support available for Ubuntu make Ubuntu the best option. Debian is also a good choice.

When you are installing Ubuntu, be sure to check the “Minimal Installation” box. This makes sure that only the essential programs are installed.

2. Don’t keep duplicates.

NOTE: This does not apply to backups of your data. Keep as many duplicate backups of your data as you can.

I find that for whatever reason I have 2 copies of the same file in different folders, or maybe two different web browsers for absolutely no reason.

Try, for a week, to stick to just one web browser. I recommend Brave Browser (as long as you turn off Brave Rewards) as it is pretty simple to install unlike Ungoogled Chromium, and tries to respect your privacy, unlike Google Chrome. Firefox-based browsers can be difficult to use exclusively as some websites are designed to only work in Google Chrome.

3. Organise your files.

I cannot emphasise this enough.

Create sub-directories of your Documents, Pictures, Downloads and Music folders. Create sub-directories for your sub-directories. Set your browser to ask where you want to save files. Make your screenshot tool autosave to a specific directory. AVOID CLUTTER!

Clutter leads to frustration.

Also remember your hidden dot files. Try to use XDG specification to keep these organised and avoid cluttering your $HOME.

3. Keep away from distractions.

One nice looking way to do this on Android is to install a simplistic launcher. I recommend Light Android Launcher from F-Droid, because it has a simple list layout without app icons, and you can pin the applications which are essential.

Quit social media.

Quit as many social media sites as you can. The obvious ones such as Twitter, Facebook, Instagram, Reddit, Snapchat and TikTok have endless scolling features which I am guilty of spending hours and hours on. A bonus to this is you will have more privacy in your day-to-day life.

You have reached the end of my blogpost. Thank you for putting up with my rambling.

Pine64’s PinePhone – Testing a few OSs

Disclaimer – The development on the PinePhone is very rapid and it is more than likely that by the time you are reading this, most of the issues I describe are fixed. I will try to update this blogpost as I test different OS images on the phone.

Last Thursday (2020-02-12) I received my Braveheart PinePhone all the way from Hong Kong. I had to pay £11.81 customs fees when I went to collected it, as I live in the UK. The box contained the phone, a note from Pine64, and a red USB-C to USB-A. When I took the phone out of the box and pressed the power button, it hesitated for about 5 seconds, then lurched into the factory test image based on PostmarketOS. It had a few tests such as for the vibration motor and the modem (which will automatically fail without the SIM inserted. If yours fails, don’t worry! Just insert a SIM card).

UBPorts

The first image I tried on the PinePhone was UBPorts. This is the most complete of the images available as of writing this blogpost. With a few scripts and commands you can get it to make phone calls, make the audio work on the speakers and make it pick up FM radio stations. Keep in mind that these do not work without running the scripts, and the scripts do not persist reboots so you will have to re-run the scripts every boot.

At this point in time, the battery life is pretty bad, as the necessary optimizations have not been added to the image. The phone gets very warm, and the battery lasts for a few hours, but will not last the whole day. If you plan to bring your PinePhone around with you, remember to bring a power bank!

PostMarketOS

PostMarketOS is probably my favourite of the OSs currently available, as it runs all the full desktop programs natively. That being said, more things seem broken on PMOS than on UBPorts and the DEs available are still in pretty early development.

Plasma Mobile on PostmarketOS

Plasma mobile is the DE I am most excited for. It is very fast paced in terms of development and it looks really awesome.

Phosh on PostmarketOS

Phosh, short for ‘Phone Shell’ is a shell based on Gnome created by Purism intended for use on their Librem 5 phone. It seems to work quite nicely, but I found that in some apps the keys were mapped incorrectly, and often the apps would not fit on the screen. A simple workaround for this is to rotate the screen to landscape mode.

Debian

The last Debian image which I tried, loaded with Phosh, seemed to work slightly better than Phosh on PostmarketOS. The battery drain is still an issue and the UI crashed a lot, but more apps seemed to fit the screen in portrait mode and I found myself switching to Landscape mode much less often. The Debian image seemed to have the modem working nicely and I was able to receive and send phone calls without running any scripts which was a nice thing to see. As far as I can tell, SMS doesn’t seem to work at all.

Fedora

The Fedora experience was very similar to Debian, as they were both running Phosh and must have had similar patches.

In conclusion, the PinePhone seems to be coming along quite nicely and I suspect that in 3 or 4 months I will have my SIM card in it and carry it around every day. That is, if we are out of lockdown by then.

-Joe.

PostmarketOS on the Mozilla Flame (t2m-flame)

One of my friends was fortunate enough to get his hands on two Mozilla Flame devices some years ago and gifted one to me just recently. These were devices originally intended for developers and early adopters of the now obsolete Firefox OS (codenamed b2g, or boot to gecko), an operating system using base android tools such as ADB and Fastboot, but instead of booting to Android, booted to an interface on top of Gecko, Firefox’s web engine. Although Firefox OS has been discontinued, the source code live on in the emerging KaiOS, which is an OS for non-touchscreen mobile phones aimed at providing internet and mobile phone access to millions of people who wouldn’t otherwise have it.

PostmarketOS is an Alpine Linux based operating system for phones which aims to achieve a whopping 10 years of updates to every phone it supports once it is stable (at the time of writing it is in pre-alpha). As luck has it, the Mozilla Flame is supported by PostmarketOS! however, as I found out it is not as straightforward as that. The port for the Flame is quite old, from before PmOS supported Armv7, so it is designed around ArmHF. The problem with this is that modern interfaces like KDE’s Plasma Mobile and Purism’s Phosh don’t support ArmHF, so I had to make some modifications to the port. As this is a tutorial, I will show you how to set up the environment and make these changes, although I will warn you that most things don’t work and all it does is boot and allow SSH access in its current state. Please refer to https://wiki.postmarketos.org/wiki/Mozilla_Flame_(t2m-flame) as well, as there is a lot of useful information there.

What you’ll need

  • Root access to a GNU/Linux machine
  • A MicroSD card larger than 4GB
  • A Mozilla Flame
  • Fastboot installed on your computer

How to do it

The first thing you’ll want to do it grab PMBoostrap, PostmarketOS’s bootstrap tool’s source code.

git clone https://gitlab.com/postmarketos/pmbootstrap
cd pmbootstrap

Now you’ll want to run the init script, just to download the device configs and stuff

./pmbootstrap.py init

However, once it asks you to select a device exit it by pressing ctrl+c, because we don’t want it to set everything up with armhf instead of armv7.

Now what we want to do is edit some files to tell the build scripts to compile for armv7 instead of armhf.

nano aports/device/device-t2m-flame/APKBUILD

This will open a text edior (nano) which will allow you to edit the APKBUILD instructions for the device. What you’ll want to do is change line 6 from arch="armhf" to arch="armv7" . Next we will change the device info.

nano aports/device/device-t2m-flame/deviceinfo

Navigate your way to line number 16, and change deviceinfo_arch="armhf" to deviceinfo_arch="armv7". We are not done yet though, as we still have to change the APKBUILDs for the kernel and the firmware.

nano aports/device/linux-t2m-flame/APKBUILD

On line 25, once again change arch="armhf" to arch="armv7"

nano aports/firmware/firmware-t2m-flame/APKBUILD

And on line 6, change arch="armhf" to arch="armv7"

Now we’ve finished all the changes we need to make, we can run pmboostrap init once again, but for real this time. I would recommend not choosing to include the WiFi firmware during this, as I have had problems with it before.

Now we build the image, and flash it on to your SD card. Insert your SD into your computer and type in:

./pmbootstrap.py install --sdcard /dev/mmcblkX

but replacing the mmcblkX with the path of your sdcard. You can list the paths by typing sudo fdisk -l and looking for your SD card.

To get the phone to boot our image, we first need to flash on the postmarketos kernel we just built. Boot the device to fastboot (by holding down vol - and power at the same time) and use this command:

./pmbootstrap.py flasher flash_kernel

Now insert your SD card into your phone, reboot and you’re off. Have fun!