Skip to content

Instantly share code, notes, and snippets.

View plembo's full-sized avatar

Phil Lembo plembo

View GitHub Profile
@plembo
plembo / docker-systemd.md
Last active June 27, 2023 05:52
docker for system containers

Docker for System Containers

Docker is a popular solution for packaging applicatiom containers, but it can work equally as well for building system containers.

I've tried using lxc, and then lxd, for this, but the former requires too much tweaking (e.g. to get networking going, with sparse and outdated documentation), and the latter chases docker in a not-very-serious way. It's also only available as a snap.

The problem with creating system containers with docker is that by default they shut down immediately after creation, because there's no app or service to keep it running.

Solution

To create a docker container from an O/S image that will keep running after creation, use this command:

@plembo
plembo / hwconsolestmhidpi.md
Last active June 29, 2023 20:12
Hardware consoles on tiny monitors

Hardware consoles on tiny monitors and high DPI displays

Introduction

If you have a tiny monitor like the 7-inch that sits on top of my home server, or a high(er) DPI display like the one I just installed in my used Thinkpad X250 (going from 1366x768 to 1920x1080 in 12 inches of screen real estate), you may have wondered how to increase the font size for your hardware console (the physical display attached to the computer) in the absence of a graphical environment like gnome.

Procedure

There's a two part recipe for this:

  1. Install fonts-terminus (the name of the package in Ubuntu).
  2. Reconfigure the console to use a larger Terminus font.
@plembo
plembo / managingpython.md
Last active February 22, 2024 03:16
Managing python

Managing python (for most of us)

I was recently inspired by an article entitled "Relieving your Python packaging pain" to rethink how I manage python on my personal machines. Keep in mind that I'm a systems architect by trade, not a software developer, and so your mileage may vary.

Rules of the game

In the above mentioned article, six basic rules were set out that I can wholeheartedly agree with:

  1. Don't install the latest major version of Python
  2. Use only the python.org installer on Windows and Mac, or official repositories on Linux
  3. Never install or run anything outside of a virtual environment
@plembo
plembo / kvmuefifiles.md
Last active February 27, 2023 22:23
KVM and UEFI firmware

KVM and UEFI Firmware

A couple of notes on KVM guests using UEFI rather than BIOS (currently the default):

  1. On Ubuntu, the ovmf package is a prerequisite for creating KVM guests that use UEFI (sudo apt install ovmf).
  2. Linux and Windows machines use different firmware files from the OVMF collection:
  • Linux guests use /usr/share/OVMF/OVMF_CODE_4M.fd
  • Windows guests use /usr/share/OVMF/OVMF_CODE_4M.ms.fd
@plembo
plembo / pcipassubuntu.md
Last active November 23, 2022 15:10
PCI passthrough for KVM guests on Ubuntu Linux

PCI passthrough for KVM guests on Ubuntu Linux

Some preliminary notes. This document subject to revision and renaming.

Guides

PCI passthrough in general

The following two guides written Mathias Huber by seem to be among the best out there:

Matthias Huber. "All you need to know about PCI passthrough in Windows 11 virtual machines on Ubuntu 22.04 based distributions". MatthiasHuber.com, 27 June 2022, https://mathiashueber.com/passthrough-windows-11-vm-ubuntu-22-04/.

@plembo
plembo / kvmwinsata2virtioubt.md
Last active September 2, 2023 19:01
kvm change windows sata to virtio on ubuntu

Change a SATA boot disk to virtio in a Windows KVM guest on Ubuntu 22.04 LTS

The problem here is that every Linux distro, and releases within distros, does things differently even when it comes to "common" services like qemu-kvm/libvirt.

Not sure why distro publishers continue to insist on that, but it results in a lot of wasted time downstream. My message, if I could get any of them to pay attention, would be: STOP IT!

I recently created a new Windows 11 guest in KVM on my Ubuntu 22 LTS Desktop system. My main motivation was to try running a game my kids had created, which I knew was going to require 3D accelerated graphics (whose installation is a matter for a different gist).

The installation went well. The trick, at least on Ubuntu 22.04's configuration of KVM, was to create a fresh guest and be sure to use the dropdown on the Overview tab to select a UEFI firmware (in my case, OVMF_CODE_4M.ms.fd) and to add an Emulated TPM 2.0 device (pass-through didn't work for me). Note, I did try and fail to

@plembo
plembo / biglittleendians.md
Last active March 2, 2024 18:57
Of Big Endians and Little Endians: File encoding and digital accessibility

Of Big Endians and Little Endians: File encoding and digital accessibility

I figured it out. And learned a valuable lesson. In exploratory data analysis work rule number one is "Read the damn docs. Carefully".

North Carolina's State Board of Elections makes a lot of useful data public. This is probably one of the best ways to ensure electoral integrity, and gives all citizens the ability to see and use data that they've already paid for. The alternative is a relatively closed system like in many north eastern states where only big money interests and their clients, like the major parties, have access to anything close to raw data.

Historical voter registration snapshots are taken at every election, so that analysts and historians can see what the state of the electorate was for each vote.

The state also provides weekly running updates of current voter registrations.

@plembo
plembo / hostwiths3andcloudfront.md
Last active August 6, 2023 05:33
host with s3 and cloudfront

Host a website with AWS S3 and CloudFront

S3 for the files, CloudFront for an HTTPS front end (S3 doesn't do HTTPS). Using Namecheap for DNS. Example site for this gist is named "www.example.com".

Create an S3 bucket

Go to S3 and Create bucket.

Name (www.example.com) bucket, choose region, and accept the defaults.

Upload files and folders

Use GUI or AWS CLI to copy files and folders to bucket.

@plembo
plembo / s3backup.md
Last active December 22, 2022 15:34
S3 Backup

Backup with AWS S3

Amazon Web Services' Simple Storage Service, a/k/a "S3", is a flexible object storage facility that is widely used by government, enterprises, and even small business for serving and backing up files. Creating a storage "bucket" is easy enough, but most consumers find the permissioning system to be indecipherable. That wasn't as much of a problem for me, as I've been through a few rounds of AWS training, including for S3. But it also wasn't straightforward. I'm creating this gist mostly to avoid having to puzzle things out for my next S3 project.

Overview

The goal is to backup files on my home server to an S3 bucket. In the example that follows "example.com" is my home domain.

Third party software

aws-cli is the official command-line tool for AWS.

rclone is "rsync for cloud storage", a reliable and efficient tool for synchronizing storage nodes. Instructions for

@plembo
plembo / nosnap.md
Last active February 16, 2024 16:40

Removing snaps from Ubuntu 22.04 LTS

I don't currently use snaps, and have had to work hard at avoiding them [1]. So far the effort has been worth it, because Ubuntu has continued to provide a stable desktop Linux system that is compatible with a broad range of modern hardware.

Getting rid of snaps in Ubuntu 22.04 LTS is basically a 4 step process:

1. Remove snapd

$ sudo snap remove --purge firefox
$ sudo snap remove --purge snap-store
$ sudo snap remove --purge gnome-3-38-2004