Skip to content

Instantly share code, notes, and snippets.

View D4rk4's full-sized avatar
🏠
Working from home

Dmitry Galenko D4rk4

🏠
Working from home
View GitHub Profile
@D4rk4
D4rk4 / hyperv-migration-win.md
Created September 24, 2024 10:01 — forked from scyto/hyperv-migration-win.md
Migrating Windows Gen2 VMs from Hyper-V

How To migrate Gen2 Windows VM from Hyper-V

This assumes you have Windows Server 2022 Gen2 VM running on hyper-v that uses gen2 with UEFI and Secure Boot - it should work for win11 but i haven't tested that. This has only tested with a vanilla windows server 2022 VM so far (three times to write guide). I will comment this gist when i manage to move one of my domain controllers.

I suggest creating a fresh test windows VM and use this procedure on that test VM long before you try this on a production VM. And repeat after me 'i will backup all VMs with snapshots AND will backup with backup application before i do this`... ok...

this gist is part of this series

VM preparation

@D4rk4
D4rk4 / 99-disks.rules
Created September 17, 2024 10:31
SAS ZFS-friendly settings via udev
# Performance settings (it's defaults in OEM firmware, but need to by ajusted for NetApp disks)
ACTION=="add|change", KERNEL=="sd[a-z]*", ENV{ID_BUS}="scsi", RUN+="/usr/bin/sdparm -s --clear=RCD /dev/%k"
ACTION=="add|change", KERNEL=="sd[a-z]*", ENV{ID_BUS}="scsi", RUN+="/usr/bin/sdparm -s --clear=DRA /dev/%k"
ACTION=="add|change", KERNEL=="sd[a-z]*", ENV{ID_BUS}="scsi", RUN+="/usr/bin/sdparm -s --set=PERF /dev/%k"
ACTION=="add|change", KERNEL=="sd[a-z]*", ENV{ID_BUS}="scsi", RUN+="/usr/bin/sdparm -s --set=WCE /dev/%k"
# Background media scan (for SAS disks)
ACTION=="add|change", KERNEL=="sd[a-z]*", ENV{ID_BUS}="scsi", RUN+="/usr/bin/sdparm -p bc -s EN_BMS=1 /dev/%k"
ACTION=="add|change", KERNEL=="sd[a-z]*", ENV{ID_BUS}="scsi", RUN+="/usr/bin/sdparm -p bc -s BMS_I=48 /dev/%k"
ACTION=="add|change", KERNEL=="sd[a-z]*", ENV{ID_BUS}="scsi", RUN+="/usr/bin/sdparm -p bc -s MIN_IDLE=2000 /dev/%k"
ACTION=="add|change", KERNEL=="sd[a-z]*", ENV{ID_BUS}="scsi", RUN+="/usr/bin/sdparm -p bc -s MAX_SUSP=500 /dev/%k"

Read-only debugging production server with ProxySQL

ProxySQL settings

docker-compose.yml

  proxysql:
    image: proxysql/proxysql
    ports:
      - 16032:6032
@D4rk4
D4rk4 / mx80_boot.txt
Created May 15, 2021 19:12 — forked from halmartin/mx80_boot.txt
Meraki MX80 wired-14-202005181203-G201ba9ed-rel-gazebo
U-Boot 2009.11-00043-gf4c39d3-serengeti_DEV_1.19.01 (Feb 15 2012 - 10:40:18)
CPU: AMCC PowerPC 460 APM86290 at 1000 MHz PLB=500 MHz
(SOC=1000 AXI=250 AHB=166 APB=83 EBC=100)
Internal PCI arbiter disabled
32 kB I-Cache 32 kB D-Cache
Board: Fullerene-2 - Meraki Fullerene Cloud Managed Router
I2C: ready
DRAM: -2 GB at 800MHz
Default enable MDIO for ETH0
@D4rk4
D4rk4 / ddos_discovery.md
Created February 16, 2021 20:06 — forked from KoeSystems/ddos_discovery.md
DDoS origin discovery

Caveats!! a human brain must be used !!!

First, get ALL your access IPs from your HTTP server

cut -d' ' -f1 /var/log/nginx/access.log | sort | uniq > /tmp/all_ips

Now we can use a docker image to have the IPtoASN API https://iptoasn.com/ running locally

docker run -itd --name my-iptoasn -p 80:53661 ilyaglow/iptoasn-webservice

apiVersion: v1
kind: Namespace
metadata:
name: echoserver
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echoserver
namespace: echoserver
### Keyboard config
d-i debian-installer/locale string en_US.UTF-8
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/xkb-keymap us
d-i keyboard-configuration/xkb-keymap select us
d-i keyboard-configuration/toggle select No toggling
d-i keyboard-configuration/variantcode string American English
### Network configuration
@D4rk4
D4rk4 / gist:a95e90e7db26bec58ac12d4a69d1e78e
Created October 5, 2019 11:44 — forked from andrewlkho/gist:3d05108ddb363243198d93526980522e
Expanding storage on a Raspberry Pi using Amazon S3

I've been playing around with a Raspberry Pi hosted with Mythic Beasts and wanted a way to keep a large number of infrequently-accessed files on the server. A cost-effective place to store such data is on Amazon S3. After looking around at ways to mount an S3 bucket on the Raspberry Pi and have it appear as a regular filesystem, I came across s3backer. This provides a single file, divided into blocks, each of which is stored as an S3 object. A filesystem is mounted onto this file using a loopback mount. This setup has many benefits which are explained well in the README. Here's how to set it up on the Raspberry Pi.

I'm going to assume that you have an S3 bucket mybucket created and a user with credentials to access it. Although not explicitly specified, some of the commands below need to be run as root.

First, install prerequisites (the first line is

@D4rk4
D4rk4 / ton-install.sh
Last active September 15, 2019 12:32
TON full node installation script for Debian 10
#!/bin/bash
export DEBCONF_FRONTEND=noninteractive
apt-get -y purge console-setup
apt-get update
apt-get -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" install -yq libghc-zlib-dev gperf build-essential make wget libreadline-dev git ccache libmicrohttpd-dev libssl-dev cmake libgflags-dev --allow-downgrades --allow-remove-essential --allow-change-held-packages
apt-get -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" dist-upgrade -yq
cd /usr/src
git clone --recurse-submodules -j8 https://github.com/ton-blockchain/ton
mkdir /tmp/ton-build
cd /tmp/ton-build
@D4rk4
D4rk4 / 99-keepwanalive
Last active May 22, 2019 21:15 — forked from navhaxs/99-keepwanalive
openwrt wan auto reconnect hotplug script
#!/bin/bash
# Place me in /etc/hotplug.d/iface/99-keepwanalive
IFNAME='wlan0'
if [ "$ACTION" = "ifdown" -a "$INTERFACE" = "$IFNAME" ]; then
COUNTER=0
PASS=0
while [ $PASS -eq 0 ]