logo
Jiff Slater
🤔 About
✍️ Contact
📚Knowledge
09 May 2021
 

Mounting a local directory in a qemu/kvm virtual machine
28 January 2021

I usually try to run my virtual machines using my existing kernel and this means that any modules I use I have to mount them within the virtual machine. I usually use the 9p mount to achieve this but in some scenarios it’s easier to use the virtual vfat mount type in KVM/QEMU.

With the 9p mount, you can use.

qemu_system_x86_64 -fsdev local,path=/directory,security-model=mapped-xattr,id=9p,readonly -device virtio-9p-pci,mount_tag=9p

And mount it locally with

mount -t 9p -o trans=virtio 9p /guest/directory

You can also use the virtual FAT filesystem.

qemu_system_x86_64 -file=fat:ro:/directory,id=vfat,format=raw,if=none -device usb-storage,drive=vfat

Flashing Mobian to the eMMC from within the PinePhone
17 January 2021

Getting Mobian onto the PinePhone is manageable but the given instructions don’t seem to work on my device. I had to apply to the following patch to get the Python installer to flash succesfully.

Log into the PinePhone over SSH (or use the phone itself, you savage :P).

Download the installer from https://salsa.debian.org/Mobian-team/mobian-installer/-/blob/master/mobian_installer.py

Make the following changes before executing:

  • Remove the references to libparted and py and reference the system libraries instead with import parted and import py.
  • In L307, replace logfn = os.path.join(os.environ["USER_PWD"], "mobian_installer.log") with logfn = os.path.join("/home/mobian", "mobian_installer.log")
Searching and executing for only a set of specific file types by extension
16 January 2021

I recently needed to copy a bunch of videos over a slow performing network and hard disk and didn’t want to copy over extraenous files. I used a combination of rsync and find to make sure that only the files I needed were executed and played.

Sending files over
$ rsync -rv ./ --filter "+ */" --filter "+ *.mp4" --filter "+ *.mkv" --filter "- *" user@host:./

Executing (playing) the files
$ find . -type f -name "*.mkv" -print0 -or -name "*.mp4" -print0 | sort -Rz | xargs -0 -n1 omxplayer -r -o hdmi

Quick break down of the commands.

The -print0 && -0 uses GNU extensions to tell both find and xargs to ignore whitespace and only start a new iteration when there’s a null character (‘\0’). The sort command randomises the output and reads line by line using nul termination ('z'). xargs -n1 means to pass the arguments line by line to the following command.

Scheduling a shutdown with systemd

Occasionally, you’ll make a change in Linux that might be a bit precarious – you commit the change with a hesitation anticipation of a problem or uncertainty on the next reboot. In these cases, it may be desirable to schedule a shutdown if nothing is done within a certain time period.

I do this frequently when I’m testing changes to a Raspberry Pi that doesn’t have an off button. This reduces the likelihood that I need to turn off the device by removing power (a problematic shut-off method that can cause problems with the SD card).

If systemd is available, you can create a new timer that executes after a set amount of time.

We’ll create a systemd unit that executes after the multi-user target has completed.

Create a small script to trigger the auto-reboot.

/usr/local/bin/auto-poweroff.sh
#!/bin/bash
/usr/bin/sleep 60
/sbin/poweroff

/etc/systemd/system/auto-poweroff.service
[Unit]
Description="Automatically power off after a period of time."
Type=oneshot
IgnoreOnIsolate=yes
After=ssh.service

[Service]
ExecStart=/usr/local/bin/auto-poweroff.sh

[Install]
WantedBy=multi-user.target

Finally create the symlink into the multi-user.target directory.

cd /etc/systemd/system/multi-user.target.wants/
ln -s ../auto-poweroff.sh

Manually setting up host only networking with QEMU guest
15 January 2021

By default QEMU makes it very easy to connect a virtual machine to the Internet using the user mode network with -netdev user. However, I’m using a custom configuration that connects my virtual machines to a pfsense instance so I needed to add an extra bridge for host to guest communication.

You can create a local bridge and tap pair on the host by using the iproute2 set of tools.

# ip link add dev bridge00 type bridge
# ip tuntap add tap00 mode tap user $USER group kvm
# ip link set tap00 master bridge00
# ip link set dev bridge00 up
# ip link set dev tap00 up

Now for most use cases, there’s no need to set up some fancy DHCP server on the host to serve a single client so I configure a simple static configuration and add that associated configuration in the guest’s equivalent to rc.local.

(host) # ip addr add 192.168.123.1/24 broadcast 192.168.123.255 dev bridge00

Inside the guest you can give yourself a static IP and communicate to the host like so.

(guest) # ip addr add 192.168.123.2/24 dev ens1

Finally, UP the interface in the guest.

# ip link set dev ens1 up

Now you should be able to SSH or ping the guest on this private network with the virtual machine.

Dynasty by Wedgewood – glass piece in House of Cards
11 October 2020

A bit of an unusual post for me – I was rather fascinated by the sets in House of Cards and really wanted to find which wine glass the Underwood’s used at their dining table.  After a lot of searching it seems it’s the Dynasty pattern by Wedgewood.  An antique piece that seems to be available on Replacements.com.

 

General knowledge and concepts for high-level discussions
22 August 2020

I’ve moved further additions to this page to my /knowledge page.

When discussing complicated topics it can be helpful to have a unified pool of knowledge.  Below is a list of things I try to keep in my conceptual model of the world so I can have fruitful discussions with my peers.

Mathematics

  • Probability distributions and cumulative distribution functions

Sciences

  • Critical exponents near phase transitions: the universal behaviour of physical quantities near continuous phase transitions.
  • Prosaic AI when we reach AGI
    • The idea that we’ll build an AI that doesn’t reveal anything new about humankind or the world.  Similar to the idea of transformative AI.
  • Re-inforcement learning
  • Local hidden variable theory
  • Chaos and non-chaos
    • Dis-order free, localisation
Pinebook Pro Review
13 February 2020

Pinebook Pro Review

Short summary: if you’re on the fence about buying the Pinebook Pro as a supplementary laptop for short trips where extreme performance is not necessary, you’d be hard pressed to find a better option for $200.

I’ve been using the Pinebook Pro regularly as my daily driver for the past couple of weeks and wanted to note down some thoughts. But first, specs of the device:

  • [Compute] Rockchip RK3399 SOC with Mali T860 MP4 GPU.
    • Rockchip contains a dual-core Cortex-A72 and quad-core Cortex-A53 in big.LITTLE configuration.
    • Surprisingly this SOC supports hardware virtualisation.
    • It also supports AArch32/AArch64 with backwards compatibility with Armv7.
    • The RK3399 can handle H.264/H.265/VP9 up to 4Kx2K@60fps which is pretty incredible for such a low power chip.
    • Finally, the embedded GPU can support DX11.1 and OpenGL ES/3.1.
  • [Memory] 4GB Low Power DDR4 RAM.
  • [Display] 14.1” 1080p 60Hz IPS display panel
  • [Power] 10,000mAh LiPo battery with USB-C 15W power delivery support and additional power port (5V 3A).
  • [Storage] 64GB eMMC 5.0, bootable microSD card slot.
  • [Connectivity] WiFi 802.11ac and BT 5.0.
  • [Audio] Stereo speakers, headphone jack, and single microphone.
  • [Camera] Single 1080p/2MP front facing camera in display.
  • [Input] Trackpad and ANSI keyboard.
  • [Boot] 128MB SPI boot flash
  • [I/O] 1 USB type C host controller with DisplayPort 1.2 and Power Delivery; 1 USB Type-C port; 1 USB 3.0 port; 1 USB 2.0 port.

Keyboard

The keyboard is of average quality. I’m using the ANSI version. The keys feel mushy on the way down but have quite a bit of spring back allowing you to type reasonably fast. In a typing test between this device and my Macbook Pro 2018, I found myself to type about 5 to 10 WPM faster on average on the Pinebook Pro. The position of the trackpad means that sometimes you’ll inadvertently move your fingers and trigger mouse movement – which sometimes results in your words being scrambled. Turning off the trackpad when an external mouse is connected can help to resolve this issue. There’s no backlighting on the keys.

Unlike the Macbook Pro, I didn’t experience any issues with repeating keys unless I had the repeat delay set low and the repeat rate set high.

Trackpad

The trackpad is a bit small given the available space on the frame. Precision is poor unless you’re making long swipes across the trackpad. Small, minor adjustments are difficult to position so I’d recommend you set the sensitivity low. I expect there to be iterative updates here to the trackpad firmware that will improve the readings.

Build quality of the case

The PBP comes in a hard metal frame. It’s cool to the touch when the device is off and has a beautiful matte black colour. I have no concerns throwing this device in my backpack or upon a desk as the frame seems very capable of protecting the RockChip innards.

If I had a choice of this frame and a durable plastic one, I’d choose the plastic one for an even lighter laptop.

Performance

The big question about this laptop: the performance. I found that I could comfortably watch 720p videos on YouTube and 480p streams on Twitch with live chat visible. The machine seemed also capable of having two streams side-by-side with occassional, but manageable stuttering on each.

By default the performance settings on Firefox is set to use 8 threads which I think is set a bit high considering that there’s only two BIG CPUs. Switching between 2 and 8 doesn’t seem to change the performance. I use a mixture of uBlock Origin and uBlock Matrix to reduce the amount of scripts running in each tab – again, this only seems to affect the initial page load speed – after the webapp is running I didn’t notice a performance difference.

I haven’t tried running any games on this device and don’t plan to – that’s what my Nintendo Switch is for!

Finally, I noticed some high pitched whining when the device was under load. Usually opening a web browser causes this whine. It’s pretty annoying and something that I hope can be fixed in due time.

Audio

The audio quality is passable and has little distortion across the volume range. I would say it’s good enough to understand a movie but not enough to enjoy a movie. Stick to headphones!

Overall

I’d recommend the Pinebook Pro as a great travel laptop if you primarily work in DevOps or live in the command line. It doesn’t grind to a halt under load – it simply slows down and I think you’ll get used to the reduced speed rather quickly.

I think this laptop’s ideal purpose is to serve as a realistic representation of what 99% of your users experience when they use your webapp. Keep it on your desk as a second laptop for testing performance improvements you’re making.

As a representation of the state of Linux on ARM, you can’t go wrong with this laptop.  It’s battery life is an solid 10 to 12 hours.  Suspend isn’t as power performant as on the Macbook so you’ll be shutting down this machine when you’re not using it.

For the hackers and tinkerers inside all of us, you’d be surprised at how easily you can get up and running.  Just download an image, flash to a USB stick or SD card, insert it into the machine, and boot up.  Run through a 5 minute installation and you’ll have a fresh installation very quickly.  However, be warned that if you have a more esteroic setup (and I mean that from a Linux on ARM perspective), such as LUKS on LVM or custom peripherals you need to get working — you’ll be spending a few days wrapping your head around compiling a custom kernel, getting the initial ramdisk built with all the required modules, and dealing with the quirks (i.e. the separate bootloader partition before the EFI partition).

The PBP wiki has a very thorough guide on the internals of the machine and I think with enough time you can enable any scenario on this device.  The forums are teeming with information and you’ll be entering the space with quite a bit of SME that can give you tips on using the machine.

Buy this machine.

Finalising the return to WordPress from GatsbyJS
20 January 2020

I started publishing a new blog at plkt.io with GatsbyJS back in the second half of 2019. I was rather enamoured by the ability to live completely in the terminal and publish a beautiful website, of course also checked into git. Over time, I found the maintenance burden to be too much due to the plethora of JS packages pulled in by Gatsby. I’d hear of vunerabilities and there would be breaking API changes in some of the packaged I used.

I committed to migrating back to a simple installation of WordPress in November 2019 and now I’ve pretty much finished the migration.

Note that there are plenty of tools to get WordPress data into Gatsby (notwithstanding the use of Gatsby as a front-end for WordPress) but not that many for the other way around. Thankfully, the new Block Editor in WordPress pretty much enables cut and paste into the editor with images and code portions migrated 1:1. If you find any problems with the migration, please leave a comment and let me know.

Now that the content is over to the new site, I’ll be slowly moving over the custom Gatsby theme I created. Once that’s done, I’ll strip the remaining JavaScript from the site – leaving it as an option for people that want to leave comments.

Happy migrations!

Looking forward to the next 10 years!
31 December 2019

Keywords: new year; 2020; new decade; self-host; apache; ansible

Note: Let’s Encrypt has a rather small rate limit that I transgessed when testing the deployment of my plkt.io w/ GatsbyJS container. This means I won’t be able to get a free HTTPS certificate from them until next week. So for the first week of the New Year, this blog will continue to be hosted on GitHub Pages. I’ll remove this note once the migration is complete!

Wow, what a year it has been. If you’re reading this, it means I’ve successfully completed my first New Year’s Resolution of hosting this website on my own web server. It is now live on a VPS at Hetzner complete with a HTTPS certificate signed by Let’s Encrypt. While this isn’t a huge achievement in itself, I’ve done much more than simply copy the static files to /var/www/html.

Short term plans

The journey to self-hosting this blog took longer than anticipated because I spent a lot of time creating a reproducible setup. This means I can recreate the plkt.io deployment on my local machine for testing with Vagrant and have that same configuration be pushed on “production” aka this web server.

To achieve this, I hand-crafted a series of incremental Dockerfiles that build the container serving this page. Starting from Debian, adding in Apache, and then configuring certbot and building the website from JS. I learned alot about setting up infrastructure via code and having single application containers work well. There’s still quite a bit left to do but for now I consider the first phase of my 2020 plan complete!

In Phase II, I’ll be moving from a simple docker run setup to something more glamorous /ahem/ I mean modern. While the site by itself is rather simple, I do plan to expose more services here, with the next in line being a self-hosted git repo at git.plkt.io. This page will serve as the authoritive git repo behind the site with a mirror of course available on GitHub. Kubernetes to replace my manual invocations (and incantations :)) will will be brought in incrementally and as needed over the course of a few months as I standardise how I roll out services on plkt.io. At the moment, I don’t plan to have multiple VMs running so will likely run each Kubernetes node using Linux containers (LXD).

Longer term plans

In Phase III, running concurrently with Phase II, I’ll be migrating from this static website built with GatsbyJS to one served with WordPress. While some might think this an irrational move, I have a lot of trust in WordPress and believe it’s the less maintenance heavy option. I’ll be migrating the entirety of my blog posts over and likely be breaking some URLs in the process. While it is considered faux paus to break links, I consider it a necessary evil as I ship this blog upon a platform that I’m sure will be for the next ten years.

If you did bookmark a page and it no longer works, try the search functionality on Google here or via WordPress if this site has already been migrated.

Phase IV is where this site really starts to become notable and useful. I’ll be adding two major updates that add a bit of interactivity to the site.

First, I’ll be publishing a blog roll of my favourite blogs via an RSS feed and also putting the snippets live on my site. This doesn’t necessarily mean I approve of everything written, rather, I find it as a directory of like-minded thinkers so people browsing this site can continue to find good content.

Second, I’m going to spin up some data funnels where I can start recording events that happen and present them on the site. Examples include: (a) Git activity by people I follow; (b) self-signed tarballs of things that I’m using in production so people have multiple sources of trust for packages; (c) and perhaps even some stock market analysis and trends.

Overall, I think the additions will do well to improve the usefulness of my website as a hub reflecting what I’m working on and what I’m capable of. In addition, it’s one small step closer to making content discovery easier in lieu of search engine dominance and apathy. More to come in this space!

Phase V is still under wraps. As my knowledge around moving workloads to the cloud, containerising applications, and building infrastructure with code improves, I can envision myself start a cloud consulting business for my local region. Nothing finalised yet but something to shoot for in 2020.

Built with Wordpress and Vim
© 2008 to 2020 Antony Jepson