Skip to content

Instantly share code, notes, and snippets.

View amontalban's full-sized avatar

Andres Montalban amontalban

View GitHub Profile
@amontalban
amontalban / prevent-host-driver-in-pci-pass.md
Created July 28, 2023 16:31 — forked from kiler129/prevent-host-driver-in-pci-pass.md
Definitely prevent stubborn devices from being bound by the host driver in PCI passthrough scenario

Scenario

You're running a KVM-based virtualization. You want to do PCI/PCIe passthrough of some device. You don't want it to attach to the host OS at all.

Your device looks like that:

00:1f.2 SATA controller [0106]: Intel Corporation 6 Series/C200 Series Chipset Family SATA AHCI Controller [8086:1c02] (rev 05)
	Subsystem: Hewlett-Packard Company 6 Series/C200 Series Chipset Family 6 port Desktop SATA AHCI Controller [103c:330d]
	Kernel driver in use: ahci
	Kernel modules: ahci
@amontalban
amontalban / attach-elastic-network-interface.sh
Last active September 7, 2020 04:32
Attach an ENI (Elastic Network Interface) to an instance
#!/usr/bin/env bash
# This script assigns Elastic Network Interface (ENI) passed as argument to current instance.
# The goal of this script is to attach an ENI to a single instance running in an ASG for example.
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
PROG_NAME=$(basename $0)
AWSCLI=$(which aws)
JQ=$(which jq)
[ 12.822046] [talos] pulling installer container image: "docker.io/autonomy/installer:v0.4.0-alpha.8"
[ 12.823971] [talos] service[system-containerd](Running): Health check successful
[ 23.299965] 2020/03/27 14:46:51 WARNING: failed to find ESP: no device found with label ESP
[ 23.305061] 2020/03/27 14:46:51 partitioning /dev/sda - ESP
[ 23.307866] 2020/03/27 14:46:51 partitioning /dev/sda - EPHEMERAL
[ 23.310756] 2020/03/27 14:46:51 formatting partition /dev/sda1 - ESP as fat
[ 23.320723] 2020/03/27 14:46:51 formatting partition /dev/sda2 - EPHEMERAL as xfs
[ 23.333162] XFS (sda2): Mounting V5 Filesystem
[ 23.339765] XFS (sda2): Ending clean mount
[ 23.341096] xfs filesystem being mounted at /var supports timestamps until 2038 (0x7fffffff)
[ 0.000000] Linux version 5.4.5-talos (@buildkitsandbox) (gcc version 8.3.0 (GCC)) #1 SMP Thu Dec 19 22:23:41 UTC 2019
[ 0.000000] Command line: BOOT_IMAGE=talos/vmlinuz page_poison=1 slab_nomerge slub_debug=P pti=on random.trust_cpu=on console=tty0 console=ttyS0 printk.devkmsg=on talos.config=http://192.168.50.2:8091/files/talos/init.yaml talos.platform=metal initrd=talos/initramfs.xz BOOTIF=01-08-00-27-6d-dc-cc
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[ 0.000000] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256
[ 0.000000] x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format.
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[ 0.000000] BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] r
#!/usr/bin/env bash
# Copyright RackN 2020
set -ex
env
echo "Starting Talos install"
# Get access and who we are.
{{ template "setup.tmpl" .}}
drpcli machines meta set $RS_UUID key color to yellow
drpcli machines meta set $RS_UUID key icon to ship
Log for Job: c8852785-0d4a-4603-b31d-46d09320e4c4
Starting task talos-init:talos-init:talos-init on d08-00-27-6d-dc-cc.ca1.us.acme.com
Job c8852785-0d4a-4603-b31d-46d09320e4c4 is running with elevated permissions ["files post,get *"]
Starting command ./talos-init-talos-init.sh.tmpl
Command running
+ env
MAC=08:00:27:6d:dc:cc

Keybase proof

I hereby claim:

  • I am amontalban on github.
  • I am amontalban (https://keybase.io/amontalban) on keybase.
  • I have a public key ASBVuyy86pSfE1aTOyN8eD8eFP0pfgRpPXl4qRUeez_TBgo

To claim this, I am signing this object:

Andres-Montalban:~ andres$ brew install tfenv
==> Downloading https://github.com/tfutils/tfenv/archive/v1.0.2.tar.gz
Already downloaded: /Users/andres/Library/Caches/Homebrew/downloads/57d000da62948b9bc641a5c4d5aeb1b82c7951025a1c6205baf0ffcc1c2cc5d3--tfenv-1.0.2.tar.gz
🍺 /usr/local/Cellar/tfenv/1.0.2: 20 files, 29.2KB, built in 4 seconds
Andres-Montalban:~ andres$ tfenv install latest
+ [tfenv:22] '[' -z '' ']'
++++ [tfenv:23] readlink_f /usr/local/bin/tfenv
++++ [tfenv:10] local target_file=/usr/local/bin/tfenv
++++ [tfenv:11] local file_name
++++ [tfenv:13] '[' /usr/local/bin/tfenv '!=' '' ']'
Andres-MBP2019:~ andres$ kubectl describe pod virt-handler-rhw7v -n kubevirt
Name: virt-handler-rhw7v
Namespace: kubevirt
Priority: 0
Node: minikube/10.0.2.15
Start Time: Wed, 21 Aug 2019 16:09:25 -0300
Labels: app.kubernetes.io/managed-by=kubevirt-operator
controller-revision-hash=75d5544dd
kubevirt.io=virt-handler
pod-template-generation=1
su -m
pkg update -f
pkg upgrade -y
pkg install -y sudo bash git go-1.12.6,1 python3-3_3 python27-2.7.16_1 python2 py27-invoke-1.2.0_1 py36-invoke-1.2.0_1 py27-pip py36-pip py27-yaml py36-yaml cmake tmux htop
tmux
bash
mkdir ~/.gopkg
export GOPATH=/root/.gopkg
export PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/usr/local/go/bin:/root/.gopkg/bin"
go get github.com/golang/dep