User Tools

Site Tools


scraps


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
scraps [2022/10/18 18:58] – created - external edit 127.0.0.1scraps [2025/03/13 13:08] (current) millerjs
Line 1: Line 1:
 ====== Scraps ====== ====== Scraps ======
 +
 Bits and pieces I want to be able to grab quickly. This page will change frequently. Bits and pieces I want to be able to grab quickly. This page will change frequently.
  
 ===== Disable power button shutdown ===== ===== Disable power button shutdown =====
 +
 edit /etc/systemd/logind.conf edit /etc/systemd/logind.conf
  
 uncomment HandPowerKey, set to ignore uncomment HandPowerKey, set to ignore
  
 +===== Get & Set date w/ epoch time =====
 +
 +Get from good machine:
 +
 +<code>date +%s</code>
 +
 +
 +Set on another:
 +<code>date -s '@1705865491'</code>
 +===== Image and Compress Disk =====
 +<code>
 +dd if=/dev/sda bs=100M | pv -ptera -s500G | lz4 > backup-name.dd.lz4
 +</code>
 +(-s500G refers to the image size, for estimates)
 +
 +Mount the whole disk image: (have to un-lz4 first ofc)
 +
 +<code>
 +kpartx -a -v myimage.disk
 +
 +mount /dev/mapper/loop0p1 /mnt/myimage
 +</code>
 +
 +Then, to unmount:
 +
 +<code>
 +umount /mnt/myimage
 +
 +kpartx -d -v myimage.disk
 +</code>
 ===== ntplogtemp ===== ===== ntplogtemp =====
 +
 <code> <code>
 #!/bin/bash #!/bin/bash
Line 15: Line 48:
 sed -i 's/LM0/CPU/g' /chronyLogs/temps sed -i 's/LM0/CPU/g' /chronyLogs/temps
 sed -i 's/LM1/CPU/g' /chronyLogs/temps sed -i 's/LM1/CPU/g' /chronyLogs/temps
 +
 </code> </code>
  
-===== Quick Pi ID =====+===== cycle systemd logs ===== 
 +<code>sudo journalctl --rotate ; sudo journalctl --vacuum-time=1s</code> 
 + 
 +==== show systemd logs from boot ==== 
 +<code>sudo journalctl -b</code> 
 + 
 +===== Raspberry Pi ===== 
 +==== Quick Pi ID ==== 
 Easy way to get a quick visual indicator to ID a Pi you're remoted into: Easy way to get a quick visual indicator to ID a Pi you're remoted into:
  
 Blink pwr LED at 1Hz: Blink pwr LED at 1Hz:
-<code>echo timer | sudo tee /sys/class/leds/led1/trigger</code>+ 
 +<code> 
 +echo timer | sudo tee /sys/class/leds/led1/trigger 
 + 
 +</code>
  
 Set pwr LED back to monitor voltage: Set pwr LED back to monitor voltage:
-<code>echo input | sudo tee /sys/class/leds/led1/trigger</code>+<code>
  
 +echo input | sudo tee /sys/class/leds/led1/trigger
  
-===== Raspberry Pi Heartbeat =====+</code> 
 + 
 +==== Heartbeat LED ===
 set in config.txt set in config.txt
-<code file=config.txt>+ 
 +<code configtxt>
 dtparam=act_led_trigger=heartbeat dtparam=act_led_trigger=heartbeat
 +
 </code> </code>
  
 +==== Grow partition on first boot ====
 +Add to the end of /boot/cmdline.txt
  
 +<code>
 +quiet init=/usr/lib/raspi-config/init_resize.sh
 +</code>
 ===== chronyc tracking ===== ===== chronyc tracking =====
 +
 -m flag combines commands. For example: sources -v, tracking, sourcestats -v -m flag combines commands. For example: sources -v, tracking, sourcestats -v
 <code> <code>
 +
 chronyc -m 'sources -v' tracking 'sourcestats -v' chronyc -m 'sources -v' tracking 'sourcestats -v'
 +
 </code> </code>
  
 ===== DHCP and Static IP on the same interface ===== ===== DHCP and Static IP on the same interface =====
 +
 Ubuntu Server 20.04, should apply to netplan in general. Ubuntu Server 20.04, should apply to netplan in general.
  
Line 57: Line 117:
         addresses:         addresses:
           - 172.16.0.2           - 172.16.0.2
 +
 </code> </code>
  
 ===== Find files under certain size and move them ===== ===== Find files under certain size and move them =====
 +
 <code> <code>
 find . -type f -size -150M -exec mv {} ../junk \; find . -type f -size -150M -exec mv {} ../junk \;
 +
 </code> </code>
- 
  
 ===== nmap testers ===== ===== nmap testers =====
 +
 NTP NTP
 +
 <code> <code>
 sudo nmap -sU -p 123 --script ntp-info 172.16.1.6 sudo nmap -sU -p 123 --script ntp-info 172.16.1.6
 +
 </code> </code>
  
 DHCP DHCP
 +
 <code> <code>
 sudo nmap -sU -p 67 --script=dhcp-discover 172.16.0.2 sudo nmap -sU -p 67 --script=dhcp-discover 172.16.0.2
 +
 </code> </code>
 +
 ===== Standalone certbot DNS ===== ===== Standalone certbot DNS =====
 +
 <code> <code>
-sudo certbot certonly --manual --preferred-challenges dns -d webgis.syninf.net</code>+sudo certbot certonly --manual --preferred-challenges dns -d webgis.syninf.net 
 + 
 +</code>
  
 ===== rsync incremental copy ===== ===== rsync incremental copy =====
-https://www.redhat.com/sysadmin/sync-rsync+ 
 +[[https://www.redhat.com/sysadmin/sync-rsync|https://www.redhat.com/sysadmin/sync-rsync]]
 <code> <code>
 +
 sudo rsync -avuP /mnt/data/media/ /mnt/six/media/ sudo rsync -avuP /mnt/data/media/ /mnt/six/media/
 +
 </code> </code>
  
 ===== Add NTP Server to PiHole DHCP ===== ===== Add NTP Server to PiHole DHCP =====
 +
 <code> <code>
 echo 'dhcp-option=42,172.16.0.2' | sudo tee /etc/dnsmasq.d/42-pihole-dhcp-ntp.conf echo 'dhcp-option=42,172.16.0.2' | sudo tee /etc/dnsmasq.d/42-pihole-dhcp-ntp.conf
 +
 </code> </code>
  
 Restart pihole Restart pihole
 <code> <code>
 +
 sudo service pihole-FTL reload sudo service pihole-FTL reload
 +
 +</code>
 +
 +===== Build LinuxPTP on Alpine =====
 +Enable community repository 
 +
 +install deps
 +<code>apk add alpine-sdk linux-headers bsd-compat-headers </code>
 +
 +<code>git clone git://git.code.sf.net/p/linuxptp/code linuxptp</code>
 +
 +<code>make ; make install</code>
 +
 +===== Cycle Chrony Logs =====
 +<code>
 +#!/bin/bash
 +# chrony log rotation
 +
 +cd /var/log/chrony
 +
 +mv measurements.log measurements.$(date +"%Y%m%d").log
 +mv statistics.log statistics.$(date +"%Y%m%d").log
 +mv tracking.log tracking.$(date +"%Y%m%d").log
 +
 +sync
 +
 +chronyc cyclelogs
 +</code>
 +
 +===== chrony.conf ptp as pps refclock =====
 +<code>
 +server time-a.nist.gov
 +server time-a-wwv.nist.gov
 +
 +refclock SHM 0 poll 3 refid GPS
 +refclock PHC /dev/ptp0:extpps:nocrossts:pin=0 width 0.1 refid PHC pps
 +
 +logdir /var/log/chrony
 +log statistics tracking measurements
 +
 +driftfile /var/lib/chrony/chrony.drift
 +
 +dumpdir /etc/chrony/dump
 +
 +rtcsync
 +
 +allow
 +cmdallow
 +</code>
 +
 +===== Set NIC to promiscuous mode at boot =====
 +Using systemd:
 +
 +`/etc/systemd/system/promisc-eth0.service`
 +
 +<code>
 +[Unit]
 +Description=Control promiscuous mode for interface eth0
 +After=network.target
 +
 +[Service]
 +Type=oneshot
 +ExecStart=/usr/bin/ip link set eth0 promisc on
 +ExecStop=/usr/bin/ip link set eth0 promisc off
 +RemainAfterExit=yes
 +
 +[Install]
 +WantedBy=multi-user.target
 +</code>
 +
 +===== Proxmox =====
 +==== re-number VM ====
 +
 +1) shut down VM
 +2) rename the storage
 +<code>zfs rename pool1/vms/vm-112-disk-0 pool1/vms/vm-1001-disk-0</code>
 +3) rename the configuration file
 +<code>
 +export vgNAME=vg-images newVMID=173 oldVMID=175 ;  \
 +sed -i "s/$oldVMID/$newVMID/g" /etc/pve/qemu-server/$oldVMID.conf; mv /etc/pve/qemu-server/$oldVMID.conf /etc/pve/qemu-server/$newVMID.conf; \
 +unset vgNAME newVMID oldVMID;
 </code> </code>
scraps.1666119538.txt.gz · Last modified: 2024/11/14 02:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki