Skip to content

Instantly share code, notes, and snippets.

@tlhakhan
tlhakhan / macos-vmware-fusion-custom-networking.md
Created April 8, 2024 16:07
MacOS: Configuring VMware Fusion's networking

README

  • For VMware Fusion on MacOS
  • Add custom domain names and DNS servers in dhcpd.conf

/Library/Preferences/VMware\ Fusion/networking

  • Edit this networking file for custom DHCP subnet for the NAT network.
  • After updating, run the vmnet-cli commands to refresh the dhcpd.conf file.
  • VMNET_1 is for the Host-only network config.
  • VMNET_8 is for the NAT network config.
@tlhakhan
tlhakhan / ubuntu2004.ipxe
Last active December 21, 2023 15:50
iPXE script for deploying Ubuntu 20.04 autoinstall nocloud-net method
#!ipxe
# ubuntu focal 20.04
# $seedfrom used to find the user-data and meta-data files by nocloud-net provider for cloud-init.
# the trailing slash is important, the cloud-init sticks 'meta-data' or 'user-data' right after it, without prepending a forward slash.
set seedfrom http://repo/files/ubuntu2004/
# $base url is where the vmlinuz and initrd live.
# they were fished out from the live-server iso file. the iso file is also in this directory.
set base http://repo/files/ubuntu2004
@tlhakhan
tlhakhan / task.go
Created November 15, 2021 15:00
task.go
package task
import (
"context"
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"log"
"net/http"
"os/exec"
@tlhakhan
tlhakhan / user-data.yml
Last active June 30, 2023 02:39
Ubuntu 20.04 example autoinstall user-data file
#cloud-config
autoinstall:
version: 1
early-commands:
- systemctl stop ssh # otherwise packer tries to connect and exceed max attempts
- hostnamectl set-hostname ubuntu-00 # update hostname even for the installer environment
- dhclient # re-register the updated hostname
network:
@tlhakhan
tlhakhan / deploy_vm.sh
Last active March 16, 2022 23:09
Deploy ESXi virtual machines
#!/bin/sh
# DESCRIPTION:
# this script will create a virtual machine on an ESXi 6+ hypervisor.
# it will create a small vm to specification from the vmx template config.
# it will create a small thin provisioned disk with 8G as OS drive.
# it will mount an ISO image and have the cdrom ready for install.
#
# pre-reqs: this script needs to be in the root-path of the vmfs datastore where you want to deploy vms.
# pre-reqs: this script needs to have the cwd changed to basedir of this script.
Every 1.0s: cat /proc/spl/kstat/zfs/arcstats | grep evictable | grep -E '^mru|^mfu' batfs0557: Mon Jul 26 10:57:53 2021
mru_evictable_data 4 0
mru_evictable_metadata 4 4096
mru_ghost_evictable_data 4 0
mru_ghost_evictable_metadata 4 0
mfu_evictable_data 4 0
mfu_evictable_metadata 4 0
mfu_ghost_evictable_data 4 0
mfu_ghost_evictable_metadata 4 0
@tlhakhan
tlhakhan / gist:95e4d46c2ea4318f8fbde47388aeb969
Created July 26, 2021 14:56
arcstats during overflow and arc_prune tasks working (zfs_prune)
time read miss miss% dmis dm% pmis pm% mmis mm% arcsz c
08:45:22 13 0 0 0 0 0 0 0 0 64G 64G
08:45:23 1.8K 3 0 1 0 2 66 3 0 64G 64G
08:45:24 469K 2.0K 0 629 0 1.4K 11 2.0K 0 64G 64G
08:45:25 777K 3.9K 0 1.4K 0 2.5K 15 3.9K 0 64G 64G
08:45:26 819K 3.6K 0 1.4K 0 2.2K 15 3.6K 0 64G 64G
08:45:27 235K 1.2K 0 441 0 760 17 1.2K 0 64G 64G
08:45:28 253K 1.3K 0 529 0 736 24 1.3K 0 64G 64G
08:45:29 510K 2.6K 0 897 0 1.7K 17 2.6K 0 64G 64G
08:45:30 37K 118 0 59 0 59 25 118 0 64G 64G
root@batfs0557:~# cat super_cache_scan.bt
#!/bin/env /usr/bin/bpftrace
#include <linux/types.h>
#include <asm-generic/atomic-long.h>
#include <linux/shrinker.h>
kprobe:super_cache_scan {
$sc = (struct shrink_control *) arg1;
@nr_to_scan[$sc->nid, comm, probe] = hist($sc->nr_to_scan);
}
@tlhakhan
tlhakhan / local.sh
Created June 8, 2021 23:05
Append to the /etc/rc.local.d/local.sh script to wait for vusb#s to initialize and then refresh the ESXi host networking to properly register uplinks to vSwitches.
#
# Description: Wait for 3 vusb interfaces to intialize and then refresh the ESXi host network settings.
# Original reference: https://flings.vmware.com/usb-network-native-driver-for-esxi#instructions
#
# Get status of 3 vusb interfaces to be "Up Up Up", see the use of 3 in head -n3 and xargs -n3.
vusb_status=$(esxcli network nic list | grep vusb | awk '{print $5}' | sort | head -n3 | xargs -n3)
# Loop until all 3 vusb interfaces are Up
# Waits a maximum of 20 * 10 seconds before falling through.
@tlhakhan
tlhakhan / transform_vusb.sh
Created June 8, 2021 22:56
Persist vusb to mac address mapping
[root@vs-1:~] esxcli network nic list
Name PCI Device Driver Admin Status Link Status Speed Duplex MAC Address MTU Description
------ ------------ ------ ------------ ----------- ----- ------ ----------------- ---- ------------------------------------------------
vmnic0 0000:00:1f.6 ne1000 Up Up 1000 Full 94:c6:91:a5:40:79 1500 Intel Corporation Ethernet Connection (6) I219-V
vusb0 Pseudo uether Up Up 1000 Full 00:50:b6:1b:f2:79 1500 ASIX Elec. Corp. AX88179
vusb1 Pseudo uether Up Up 1000 Full 00:50:b6:ea:b8:42 1500 ASIX Elec. Corp. AX88179
vusb2 Pseudo uether Up Up 1000 Full 00:50:b6:1e:dc:72 1500 ASIX Elec. Corp. AX88179
[root@vs-1:~] esxcli network nic list | grep vusb | awk '{print $1"_mac="$8}'
vusb0_mac=00:50:b6:1b:f2:79