Skip to content

Instantly share code, notes, and snippets.

View plembo's full-sized avatar

Phil Lembo plembo

View GitHub Profile
@plembo
plembo / nestedvirtkvm.md
Last active April 23, 2025 09:37
Enable nested virtualization in KVM

Enable nested virtualization in KVM

For those times when you need to run virtualization (e.g. vagrant with VirtualBox) inside a KVM (libvirtd) guest.

The following taken from Enabling nested virtualization in KVM over on Fedora Docs.

  1. Make sure that the Intel-VT-x/AMD-V extensions are enabled in the host machine's BIOS. For Intel:
@plembo
plembo / allow-netaccess-kvm.md
Last active March 7, 2025 16:05
Allow network access to kvm guest

Allow network access to KVM guest

Even with bridged networking, a KVM (libvirtd) guest can't be reached from the network (except by the KVM host machine). The two ways to deal with this on a Debian or Debian derived (e.g. Ubuntu) system are as follows:

Add a ufw FORWARD rule

This solution provides minimal access to bridged guests. It does not disable netfilter on the bridge. It does require the guest to have a static IP address, as it won't be able to receive one from the local network.

Modify /etc/ufw/before.rules to add a FORWARD rule with the guest's IP address:

# allow all traffic to 10.1.0.81
-A FORWARD -d 10.1.0.81 -j ACCEPT
@plembo
plembo / renamekvmmachine.md
Last active August 29, 2022 14:44
Rename a kvm machine

Rename a KVM (libvirtd) virtual machine

Credit to Amos Mibey for his excellent howto, How to Rename KVM Virtual Machine with virsh command. Kifarunix.com, 2 Sept 2018. Retrieved 21 July 2019.

Herein, "oldvmname" is the existing name of the vm, and "newvmname" is what its new name will be.

  1. Shut down target vm.
$ virsh destroy oldvmname
@plembo
plembo / GitFilterBranchFile.md
Created July 22, 2019 13:05
Use git filter-branch to remove file

Use git filter-branch to remove file from repo

File already pushed to github. In this case it's too big and should have been compressed first. This is how to remove it completely. If others have their own copies of repo, will need to coordinate with them.

Issue command from root of local copy of repo:

$ git filter-branch --tree-filter 'rm -f resources/products.json' -- --all
@plembo
plembo / splitlargetarandrecomb.md
Created July 31, 2019 20:05
Split large tar file and recombine

Split a large tar file and recombine

Really large backup files, over 100 M, can be difficult to transfer across networks.

One solution is to split the file up into many smaller files and then recombine.

Example uses a 7.8 GB tar.gz file.

$ split -b 100M wordpress-site.tgz “wordpress-site.tgz.part”
@plembo
plembo / autostart4tk4.md
Last active November 3, 2022 15:54
Autostart for TK4 on Linux

Implement autostart for TK4 on Linux

I'm a big fan of the MVS 3.8j Tur(n)key 4- System, and the excellent tutorial by moshix on his YouTube channel, How to get MVS 3.8 up and running on Linux. In my case, running on an Ubuntu KVM virtual machine. Of course, as a former server sysadmin I really wanted my server to automatically start when my vm booted up. The following is what I did to make that happen.

For my setup I chose to create a normal user on the vm, mvs, to run the server.

The user's home directory was set to /d1/app/mvs.

Following moshix's tutorial, I installed the tur(n)key system to /d1/app/mvs/mvs38.

@plembo
plembo / kvmlinuxconsole.md
Last active August 29, 2022 14:40
Creating a KVM Linux guest from the console

Creating a KVM Linux guest from the console

Example uses Ubuntu 18.04 LTS.

Get console on KVM (libvirtd) host and execute virt-install command:

virt-install \
--name test01 \
--ram 1024 \
@plembo
plembo / enablettys0onkvm.md
Last active August 29, 2022 14:47
Enable ttyS0 on KVM guest

Enable serial console access to a KVM guest

In order to access a KVM (libvirtd) guest using virsh console, you first need to enable a serial console on the guest.

Log into the guest and run the following commands:

$ sudo systemctl enable [email protected]
$ sudo systemctl start [email protected]
@plembo
plembo / setup-vscode.md
Last active April 30, 2025 12:48
Visual Studio Code Setup

Visual Studio Code Setup

Updated 24 April 2025

Notes on setting up Visual Studio Code (vscode). My machines are mostly Linux, but I have also used vscode as my primary editor on the work Windows 10 laptop. Like many of Microsoft's "free" offerings, vscode is always changing, so the location and even existence of settings described here may not be as described below. Questions should be directed to the appropriate subject matter fora on the Internet.

NOTE: I currently use vim for most of my code editing, and the open source Theia IDE (https://theia-ide.org) as my IDE for complex projects. Theia is pretty much a drop-in replacement for vscode, without the latter's proprietary features (that include many popular closed-source extensions from Microsoft).

To install the Fira Code font on Windows, see Manually installing fonts on Linux and Windows. There is a fonts-firacode package for Ubuntu.

@plembo
plembo / force-networkd-config-noreboot.md
Last active June 1, 2024 19:42
Force new systemd-networkd config without reboot

How to force a new systemd-networkd config without reboot

Reference: Stack Exchange: systemd-networkd - how to force new configuration without reboot? (Answer by user 156350). February 13, 2016.

Originally had a Ubuntu 18.04 LTS server configured with a bridge interface called "br0".

Decided to remove it as an unnecessary complexity (it was originally there to service multiple IPs on the same physical interface, but I now only need one IP).

First rewrote /etc/netplan/01-netcfg.yaml to remove bridge and put everything under the ethernet iface,