Skip to content

Instantly share code, notes, and snippets.

View plembo's full-sized avatar

Phil Lembo plembo

View GitHub Profile
@plembo
plembo / pcipassubuntu.md
Last active October 22, 2024 21:42
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 20, 2024 03:16
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

Removing snaps from Ubuntu 22.04 LTS

NOTE: Removing snapd may impact the operation of Ubuntu Pro.

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
@plembo
plembo / czrocksdiskclone.md
Last active August 7, 2024 00:59
Clonezilla Rocks Ubuntu boot SSD to NVME

Cloning a Ubuntu boot SSD to NVME

Getting short of space on a 120G boot/root SSD on Ubuntu Server, decided to replace it with a bigger NVME (IDE) 250G drive.

Using the latest Clonezilla, the process was really painless. After cloning, there was still over 100G unallocated space on the larger drive for expansion of a new parition. The paritions of the clone had the same disk UUIDs and flags as the original.

  1. Checked disk and partition sizes using lsblk.
  2. Downloaded latest Stable iso from https://clonezilla.org/downloads.php.
  3. Get a 1G or more USB stick and burn the iso onto it using Startup Disk Creator.
  4. Installed the NVME drive onto the motherboard.
@plembo
plembo / vnstater4.md
Last active July 24, 2023 05:20
vnstat on EdgeRouter 4

vnstat on EdgeRouter 4

Installation

First setup Debian system package repo (Ubiquiti Support and Help Center). For EdgeOS 2.x this will be the repo for Debian 9 "Stretch".

$ configure
# set system package repository stretch components 'main contrib non-free'
# set system package repository stretch distribution stretch
# set system package repository stretch url http://http.us.debian.org/debian
@plembo
plembo / createkvmstoragepool.md
Last active November 13, 2024 17:38
Create the default KVM storage pool for images

Create the default KVM storage pool for images

Some distributions create the defaut KVM (libvirtd) storage pool for images when they install KVM, others do this upon the creation of the first KVM guest. Creating the default pool from scratch is pretty straightforward. Here's how to do it with virsh.

First verify there is no existing default pool:

$ virsh pool-list --all
 Name      State    Autostart
-----------------------------
@plembo
plembo / relocatelibvirtimages.md
Last active April 18, 2025 07:59
Relocate kvm images directory

Relocate an existing libvirtd (KVM) images directory

By default, KVM (libvirtd) images on Ubuntu and most other Linux distributions are found in /var/lib/libvirt/images. This can be inconvenient if you don't have a separate /var partition that can grow over time to accommodate multiple large images.

You can simply rename the images folder to something else and then symlink to a larger space with it (e.g. ln -s /data1/libvirt/images /var/lib/libvirt/images). That's what I used to do.

But that can lead to all sorts of unanticipated trouble. The right way to have your images on a bigger disk is to change the path for libvirt's default storage pool to a partition on that big disk, which is logically where KVM is going to create them.

First check to make sure a default pool exists: