Skip to content

Instantly share code, notes, and snippets.

@helenchw
Last active February 6, 2025 13:17
Show Gist options
  • Save helenchw/3c2047d15f2390b6ba94c3b33ca79057 to your computer and use it in GitHub Desktop.
Save helenchw/3c2047d15f2390b6ba94c3b33ca79057 to your computer and use it in GitHub Desktop.
Miscellaneous

This is a set of notes on miscellaneous computing-related items, ranging from hardware setup to software tools.

They are mainly for my own reference and hopefully it will also be useful to others in need.

Disk performance

Read

Command:

sudo hdparm -Tt <device name>

Example output (7.2K RPM 1TB SATA HDD):

/dev/sda:
 Timing cached reads:   28196 MB in  1.98 seconds = 14211.59 MB/sec
 Timing buffered disk reads: 578 MB in  3.00 seconds = 192.50 MB/sec

Problems/Issues

Installation on CentOS 7

For CentOS 7 without upgrade to 7.9, the original kernel is too old to support the getrandom() (see the closed issue for boost::uuids here). To resolve the issue, we need to upgrade the kernel via yum and reboot the machine to load the new kernel.

Operating-System-Related

OS Installation

CentOS 7

  • Where to download archived CentOS ISOs?
  • Updating archived CentOS yum repository targets (for CentOS 7.9.2009)
    • Open /etc/yum.repos.d/CentOS-Base.repo
    • Comment all lines starting with 'mirrorlist'
    • Uncomment all lines starting with '#baseurl'
    • For each line starting with 'baseurl', change the part of http://mirror.centos.org/centos/$releasever to http://vault.centos.org/7.9.2009/.
  • Upgrading from 7.x to 7.9
    • Set the yum repository links to vault link of version 7
    • Upgrade everything using yum -y update
    • Reboot to reload the upgraded kernel

Firewalld

  • Setup a new service for port openning (Digital Ocean reference)
    • (With root access for the following steps)
    • Construct a service definition file, e.g., mywebservice.xml under /etc/firewalld/services
    • Input the following contect and replace the service name, port range, and protocol accordingly
      <?xml version="1.0" encoding="utf-8"?>
      <service>
        <short>MyWebService</short>
        <port protocol="tcp" port="11010-11020"/>
        <port protocol="tcp" port="443"/>
      </service>
    • Force the firewall daemon to reload (the service configurations): firewall-cmd --reload
    • Find the zone with the target interface: firewall-cmd --list-all
    • Add the service to the target zone: firewall-cmd --add-service mywebservice --zone=<targetZone> --permanent
    • Reload the firewall daemon: firewall-cmd --reload

Network Gateway Setup

Using iptables

(Reference: https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/4/html/security_guide/s1-firewall-ipt-fwd#s1-firewall-ipt-fwd)

Assume

  • interface for internal network: ens3f0np0
  • interface for external network: eno12399
sudo iptables -A FORWARD -i ens3f0np0 -j ACCEPT
sudo iptables -A FORWARD -o ens3f0np0 -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o eno12399 -j MASQUERADE 

Network-related

Netplan

  • Netplan not working and complaining about a missing module netifaces (because of python version mismatch): Set the perferred python version

    sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1

  • Update the network interface name using Netplan

    • Identify the mac address ("serial") via sudo lshw -C network
    • Add the following to the interface to rename
      match:
        macaddress: <serial>
      set-name: <new-interface-name>

Video processing

  • Check for video length using ffmpeg tools

    ffprobe -i <video_file_path> -show_entries format=duration -v quiet -of csv="p=0"

System Monitoring

Fluentbit (Docker)

For statistics collection using the node metrics input plugin,

  • Incorrect network interfaces: Expose the Docker container to the host network using --network=host
  • Disk read/write size in bytes: Check the device sector size using blockdev --getbsz <dev> and multiple the metric node_disk_read_bytes_total/node_disk_write_bytes_total to get the exact disk traffic volumes

R chart plot

Plot legend only

The example script from https://www.geeksforgeeks.org/draw-ggplot2-legend-without-plot-in-r/

# Load Packages 
library("ggplot2") 
library("grid") 
library("gridExtra") 
library("cowplot") 
  
# Create a DataFrame 
data <- data.frame( 
  Xdata = rnorm(10), Ydata = rnorm(10), 
  LegendData = c("ld-01", "ld-02", "ld-03", 
                 "ld-04", "ld-05", "ld-06", 
                 "ld-07", "ld-08", "ld-09",  
                 "ld-10")) 
  
# Create a Scatter Plot 
gplot <- ggplot(data, aes(Xdata, Ydata, color = LegendData)) +    
  geom_point(size = 7) 
  
# Draw Only Legend without plot 
# Grab legend from gplot 
legend <- get_legend(gplot)                     
  
# Create new plot window 
grid.newpage()                               
  
# Draw Only legend  
grid.draw(legend) 

Code snipplet by Microsoft Copilot

# Create an empty plot
plot(0, type = "n", xlim = c(0, 1), ylim = c(0, 1), xlab = "", ylab = "")

# Add a legend
legend(x = "topright", legend = c("J0", "J2"), lty = c(1, 2), col = c(2, 3), lwd = 2)

PDF Editing

  • PDF Rotation: pdftk (Ubuntu manual)
    • Example: Upside down pdftk <input PDF path> cat 1-endsouth output <output PDF path>
  • PDF Merging: pdfunite (Ubuntu manual)
    • Example: pdfunite <input PDF path> ... <output PDF path>

Notes on Testbed deployment

Install S3 storage CA certificate on Ubuntu

  • Copy the CA certificate to the Ubuntu certificate directory (official guide)
sudo apt-get install -y ca-certificates
sudo cp local-ca.crt /usr/local/share/ca-certificates
sudo update-ca-certificates

Setup Hostname record for S3 storage SSL certificate

In /etc/hosts, add an entry <target ip> nedge-proxy.

MVN

  • Set up http and https proxies in the user MVN profile (.m2/settings.xml) (official guide)
<settings>
  <proxies>
   <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.example.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
    </proxy>
  </proxies>
</settings>

Virtualization related

Libvirt

Libvirt network not working on Feodora 41

  1. Change/Set the following option in /etc/libvirt/network.conf
firewall_backend = “iptables”
  1. Restart the libvirtd service
sudo service libvirtd restart

Reference solution: https://gitlab.com/libvirt/libvirt/-/issues/645

Libvirt Windows Guest Display Resolution Locked

To 'unlock' (i.e., enable resolution adjustment), install the guest tools (drivers) for virtio.

  1. Install the virtio guest tools for Windows (choose stable-virtio): https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/

Reference: https://forum.linuxconfig.org/t/libvirt-vm-screen-size-unable-to-select-resolution-with-ms-windows/8169/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment